Passing diagonal matrix to an *.oct function
José Luis García Pallero
jgpallero at gmail.com
Fri Mar 6 05:06:25 CST 2009
I need diagonal matrices for store weighting matrices. I usually use row or
column vectors, but if octave supports diagonal matrices, I would like use
them for clarify the code.
2009/3/6 Jaroslav Hajek <highegg at gmail.com>
> On Fri, Mar 6, 2009 at 11:39 AM, Jaroslav Hajek <highegg at gmail.com> wrote:
> > 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.
> >
>
> I've pushed the changes to savannah.
>
> Just out of curiosity, what's the application? Why do you want to
> treat diagonal matrices specially in the oct file?
>
> --
> RNDr. Jaroslav Hajek
> computing expert & GNU Octave developer
> Aeronautical Research and Test Institute (VZLU)
> Prague, Czech Republic
> url: www.highegg.matfyz.cz
>
--
*****************************************
José Luis García Pallero
jgpallero at gmail.com
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20090306/30ab6fbc/attachment.html
More information about the Help-octave
mailing list