[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stack and append
From: |
Eduardo Gallestey |
Subject: |
Re: stack and append |
Date: |
Wed, 16 Jun 1999 11:14:23 +1000 |
heberf wrote:
>
> I need a faster implementation of the kronecker product. The one that comes
> with octave is in linear-algebra/kron.m and it's not suitable for me because
> my
> problem involves many large matrices. I'm trying to rewrite it as an oct
> file.
>
> A few weeks ago there was some discussion on this list of using stack and
> append
> as defined in dMatrix.h. I'm pretty poor at C++ and I can't tell from reading
> that file how to implement it. Could someone point out a function where
> either
> of these are used or send a few lines of an oct file so I can see how to do
> it?
>
> Much thanks,
> Heber Farnsworth
>
> ---------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL. To ensure
> that development continues, see www.che.wisc.edu/octave/giftform.html
> Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
> ---------------------------------------------------------------------
I have a general question with respect to that. Maybe I am wrong but,
wouldn't it be more efficient if we allocate all the space for "x" at
once, at the beginning of the function? I mean, like this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function x = mykron (a, b)
if (nargin == 2)
[m, n] = size (b);
[ma, na] = size (a);
x=zeros(ma*m,na*n);
for jj = 1:na
j_vec=n*(jj-1)+1:n*jj;
for ii = 1:ma
x(m*(ii-1)+1:m*ii,j_vec) = a(ii,jj)*b;;
endfor
endfor
else
usage ("kron (a, b)");
endif
endfunction
%%%%%%%%%%%%%%%%%%%%%%%%%
Eduardo
---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL. To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------