Passing diagonal matrix to an *.oct function
Jaroslav Hajek
highegg at gmail.com
Fri Mar 6 04:39:06 CST 2009
On Fri, Mar 6, 2009 at 11:30 AM, José Luis García Pallero
<jgpallero at gmail.com> wrote:
> Your method:
>
> const octave_diag_matrix& dmref = dynamic_cast<const octave_diag_matrix&>
> (args(0).get_rep ());
> DiagMatrix a = dmref.diag_matrix_value ();
>
> fails at compile time. The error is:
>
> error: expected initializer before ‘&’ token
> error: ‘dmref’ was not declared in this scope
>
You need to #include the proper header, of course. In this case,
"ov-re-diag.h". But I'm just adding the diagonal query methods, so
stay tuned.
> I can work with a trick. I can pass a column vector to my function instead a
> diagonal matrix and initialize the DiagMatrix in the oct function:
>
> DiagMatrix a(args(0).column_vector_value());
>
> Can I think that this method produces a waste of memory because the original
> array is duplicated?
No. A shallow copy will be used. But it won't work for a rectangular
diagonal matrix.
> I suppose that diag_matrix_value_method() must be added, as matrix_value(),
> column_vector_value(), etc. They can return an error in situatios of
> conflict, like Matrix a=args(0).colum_vector_value(), for example.
>
> Thanks
>
Agreed. I'll add them.
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Help-octave
mailing list