Re: [eigen] Returning an expression unifying two types of matrices
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] Returning an expression unifying two types of matrices
• From: Rhys Ulerich <rhys.ulerich@xxxxxxxxx>
• Date: Thu, 24 Nov 2011 13:39:15 -0600
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=w0sX6thsa2snWhnDdS//s953HLQxsBUr/5O8ivjD+pg=; b=Go5/cf7pxDKhQpl3M9euqo7xZgMSD2006wdfbche+imkhFi5I1SuiM2AnrTcoK7uW3 GWCdb4cmRey5cAHh3bGwWAixNE6SjigkuXEHAbQq6G1Y4Z0uV1355ymklDJ+tmHTDBSL BVci4LdFtnD7wAhDxdhutL41ZND1McD47yhJA=

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/