[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Contributing a kron function
From: |
heberf |
Subject: |
Re: Contributing a kron function |
Date: |
Fri, 22 Oct 1999 15:51:16 -0500 (CDT) |
I haven't done any of that unfortunately but I'd be happy to help.
Heber
On Fri, 22 Oct 1999, etienne grossmann wrote:
> Hello,
>
> let's say I were to contribute a builtin kron function, based on
> Heber's code :
>
> ======================================================================
> #include <octave/oct.h>
> #include "config.h"
> #include "oct-obj.h"
> #include "oct-map.h"
> #include "defun-dld.h"
> #include "toplev.h"
>
> DEFUN_DLD (newkron, args, ,"Faster Kronecker Product")
> {
>
> octave_value_list retval;
>
> Matrix A = args(0).matrix_value();
> Matrix B = args(1).matrix_value();
>
> int ra = A.rows();
> int ca = A.columns();
> int rb = B.rows();
> int cb = B.columns();
> int r = ra*rb;
> int c = ca*cb;
> Matrix tmpmat(rb,cb,0);
> Matrix C(r,c,0);
> for (int i=0; i<ra; i++)
> {
> for (int j=0; j<ca; j++)
> {
> tmpmat = A(i,j)*B;
> C = C.insert(tmpmat,i*rb,j*cb);
> }
> }
> retval(0) = octave_value(C);
> return retval;
>
> }
> ======================================================================
>
> I guess I would have to add another function for 2 ComplexMatrix
> arguments. Right?
>
> And put it in a "src/DLD-FUNCTIONS/kron.cc"
>
> And add kron.cc to the definition of DLD_XSRC in src/Makefile.in
>
> Does that sound correct? Is there a better place (e.g. in data.cc)
> to define such a function?
>
> Other things that could be useful would include a little test suite,
> I guess (any preferred format for that?).
>
> Heber, have you already done a all/some of the above?
>
> Cheers,
>
> Etienne
>