Re: [eigen] Returning an expression unifying two types of matrices

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Nov 24, 2011 8:19 AM, "Jens Mueller" <jens.k.mueller@xxxxxx> wrote:
>
> Hi,
>
> I'm facing a problem and don't know how to approach it.
> In my code I have many expressions of the form y.transpose() * getG() *
> y, where y is a column vector of length n and getG() returns a reference
> to a nxn matrix.
> Sometimes I know that G is diagonal (at run-time) and I'd like to use
> this information when evaluating the expressions (storing a diagonal is
> also much cheaper).
> I need to store G somewhere to return it. But G is either a full matrix
> or a diagonal matrix. So what do I store?

Store neither. Pass vector y into a method that, like getG, knows how to compute either inner product _expression_ (using G diagonal or full efficiently). Return the scalar result.

- Rhys



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/