[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Contributing a kron function
From: |
etienne grossmann |
Subject: |
Contributing a kron function |
Date: |
Fri, 22 Oct 1999 20:21:26 +0100 (WEST) |
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
- Contributing a kron function,
etienne grossmann <=