Passing diagonal matrix to an *.oct function
Jaroslav Hajek
highegg at gmail.com
Fri Mar 6 04:10:32 CST 2009
On Fri, Mar 6, 2009 at 10:48 AM, José Luis García Pallero
<jgpallero at gmail.com> wrote:
> Hi,
> I'm trying to pass a diagonal matrix to an c++ function, but I don't know
> the method for conversion from the octave_value class. I've tried with
> DiagMatrix a=args(0).diagmatrix_value(), .diagonal_matrix_value(),
> .matrix_value(), but all fails. Wich is the correct form?
> Thanks
>
Since the support is still kind of experimental, there's no such
method in octave_value interface. What you need is to dynamic_cast the
reference to the proper subclass and query that:
const octave_diag_matrix& dmref = dynamic_cast<const
octave_diag_matrix&> (args(0).get_rep ());
DiagMatrix a = dmref.diag_matrix_value ();
Admittedly, it's clumsy (CAST_CONV_ARG macro helps a little). Maybe
these methods should be added? What should they return for other
values? Should they just fail?
cheers
--
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