pb with oct file, return a matrix
John W. Eaton
jwe at octave.org
Wed Apr 22 10:50:51 CDT 2009
On 22-Apr-2009, Alain Baeckeroot wrote:
| I wrote a DEFUN_DLD and have trouble to return a matrix, it segfault
| at return retval or in main program M=boucle_cc(...)!
| I tried to run in gdb (and mkoctfile -g) but it does not help me.
|
| I think i have exactly copied a working DEFUN_DLD i have which
| returns a matrix, but ...
|
| Any help/hint/url is welcome :-)
| Alain
|
| ------------------------------------------------------
| Here is the code (with printf for debugging)
| DEFUN_DLD( boucle_cc, args, nargout, "usage : rMat = boucle_cc(..)\n") {
| int NDATA=10000;
| Matrix rMat(NDATA, 22); // results
| octave_value_list retval; // list of return values
|
| ...compute and put everything in rMat...
|
| printf(" ici boucle_cc 7, avant retval(0)= rMat\n");
| printf(" rMat(0,0) = %lf, (9999,21) = %lf;\n", rMat(0,0), rMat(9999,21) );
| retval(0) = rMat;
| printf(" ici boucle_cc 8, avant return retval\n");
| return retval;
| }
Does it work if you simplify your function to be just the following:
DEFUN_DLD( boucle_cc, args, nargout, "usage : rMat = boucle_cc(..)\n") {
int NDATA=10000;
Matrix rMat(NDATA, 22, 0.0); // results
octave_value_list retval; // list of return values
retval(0) = rMat;
return retval;
}
? If so, then I'd guess that you have some problem in the
| ...compute and put everything in rMat...
part. Given the error message you see, I'd guess that you are writing
outside the bounds of the rMat array. But that's just a guess.
jwe
More information about the Help-octave
mailing list