Re: [eigen] how to create a "virtual" array or matrix? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] how to create a "virtual" array or matrix?
- From: David Roundy <roundyd@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 7 Jun 2010 13:27:38 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=VjivUzGrPSfu36Jaiu3C/NF0FZnOA53c0pwwpBvkOXo=; b=YbTpb6KJsjWslXciVUu3hQRGHJffYZG8mrqfu+jtSJqWgF6MFrMl+bmU4swl76tTEe +7LLunpJ6eyBrRx31cxcd3Q7+US0OcM0ZSuit34OSwM/gsWUk3xjarD4vM9p4en8opjD xAB/Ouakuiy9fq3+1V7nwd04+Mu4HKI09/stI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=gpRAuu3Gz0bEUOPO5pZxbeT4YdzaOvEV0GIGgxbUdR5opPvuV40OgXmjB0kZ2EbOut xJ5X2XHhHpO9Bztj0nuCPq4ILLv/SfdOmQB7O5paRhy8Bn2oht7tuaCb+nfHdMYc3klc dj/clUypSvqtG7EoYzmyaMz3Q523R3fHo6/MQ=
I think I wasn't very clear. I am using a VectorXd to store the
number density (of a fluid), which is a function of position, so I
maintain a mapping from indices in the vector to points on a 3D grid
in space.
class Grid : public VectorXd {
public:
explicit Grid(Lattice lat, int nx, int ny, int nz)
...
};
I would like to represent the magnitude of the position at each point
(or the x component of the position, or whatever) without storing any
(large) data, since it's easy to compute on the fly.
David
On Mon, Jun 7, 2010 at 12:52 PM, Carlos Becker <carlosbecker@xxxxxxxxx> wrote:
> Hi David, I am not sure if I am understanding but you want to do. But, if
> you have your vectors already allocated somewhere you can use the Map
> function of Eigen to map that memory into an Eigen matrix without
> duplicating it so you can do something like:
> Map<MatrixXf> vectors( startingPointer, numRows, numCols );
> float totalSum = vectors.array().square().colwise().sum();
> (I haven't tested this code but this is the idea)
> You can also map a single vector since the solution above would be mapping
> several of them. Also take into account if you are using row- or
> column-major alignment.
> I hope it helps,