Dear All,
I am a new comer to the octave andI tried to write an .cc file about the
addition of two integral matrices. But there are still too many warning
when i mkoctfile it...
I would be so grateful for any help. Another, my octave release is
2.1.73 under cygwin, is anyone know how to update to 2.9.8...I download
the 2.9.8 file, but how to install?
Thank you very much!
Best Regards,
Weisheng
#include <octave/oct.h>
DEFUN_DLD (addoctmat, args, ,
"The addition of two spreaded matrices.")
{
octave_value retval;
const Matrix Am = args(0).matrix_value();
double *A = Am.fortran_vec();
int mrows = Am.rows();
int ncols = Am.cols();
const Matrix Bm = args(1).matrix_value();
double *B = Bm.fortran_vec();
const Matrix resAddm (mrows, ncols);
double *resAdd = resAddm.fortran_vec();
resAdd[0] = 0.0;
for (int i = 0; i < mrows; i++)
{
for (int j = 0; j < ncols; j++)
{
*(resAdd+j*mrows+i) = *(Am+j*mrows+i) + *(Bm+j*mrows+i);
}
}
retval = resAddm;
return retval;
}
And, if I donot use the pointer, is seems better...but still donot
work.....
#include <octave/oct.h>
DEFUN_DLD (addoctmatr, args, ,
"The addition of two spreaded matrices.")
{
octave_value retval;
const Matrix Am = args(0).matrix_value();
int mrows = Am.rows();
int ncols = Am.cols();
const Matrix Bm = args(1).matrix_value();
const Matrix resAddm (mrows, ncols);
for(int i = 1; i <= mrows; i++)
{
for(int j = 1; j <= ncols; j++)
{
resAddm(i,j) = Am(i,j) + Bm(i,j);
}
}
retval = resAddm;
return retval;
}
_________________________________________________________________
与联机的朋友进行交流,请使用 Live Messenger;
http://get.live.com/messenger/overview
------------------------------------------------------------------------
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave