Creating an Octave Matrix by reference

Jan Albersmeyer jan.albersmeyer at iwr.uni-heidelberg.de
Tue Mar 24 10:37:50 CDT 2009


Hi !

I use Octave in connection with my own C++ codes, usually by wrapping my
objects in corresponding new Octave types and supplying interfaces for
interaction by overloading subsref / subsagn of the new type. When I
want to get matrix type data out of my C++ code, I usually create an
Octave Matrix, copy the data from my data structs to the Matrix an
return it to Octave.

Now I asked myself if it would be possible ( without adapting the Octave
core Matrix class ) also to create an Octave Matrix by referencing my
existing data structs ( which are also col-major stored matrices ),
without copying it.  This would also imply that Octave would not try to
manage the memory of this matrix.
Browsing the sources, I just saw that the Matrix ( dataPointer, nRows,
nCols ) constructor is private, and something like a Matrix (
dataPointer, nRows, leadingDimension, nCols ) constructor does not seem
to exist.

Does anybody know if it is possible to achieve this behaviour ?

Thanks in advance,

Jan


P.S.: It would not matter if it is only possible with a more general
array class instead of a Matrix.


More information about the Help-octave mailing list