[eigen] how to create a "virtual" array or matrix? |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: [eigen] how to create a "virtual" array or matrix?*From*: David Roundy <roundyd@xxxxxxxxxxxxxxxxxxxxxxx>*Date*: Mon, 7 Jun 2010 12:20:09 -0700*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=NKJPuS5yt2AmoFxj0OMST2821R6E2ShaUZLy+ftuAuY=; b=WngwJbqRySZRRFfa/MoRX/y0DphitWIjpgNs7k8m9qnrh6x76JJRABZKu1nrYh5T86 iAqBB+AELacfYRpCJsPaDIHefiphrSGF49ccQy6SDhIZsoGKN9DP1mttBvJ6Kjehs02e 4A3TpHi96/zj+Mgtd3Hm+S0g5fsChd9jNmOtg=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=mZdHK7SI6UfSicyhYjb5WdWtV5XCiHy7oaxLtTAblH8P7WwRygBtsP4KwftLMPrwfv ddfyPLyI6tDIFJu8De+O6DS/hhGkDLLQtphETwQGve+2O0kmztgDp0nF4TQAe/zXKdxC jP8AJBpepzdIWUg94L/+xyHsqqN+ziIlyEbUc=

Hi all, I'd like to create an object that describes an easily-computable array. In particular, I want to work with some vectors describing functions of position. In order to easily manipulate these, I'd like to create an object containing the value $|\vec{r}|^2$. I could, of course, fill a vector with this value, but that would be a waste of memory, since it's really cheap to compute. And these vectors will eventually end up being quite large (maybe a GB or so), so I'd prefer not to allocate the memory. In the past, I'd have just written a loop to sum over all positions, but that leads to ugly and hard-to-maintain code, since a non-trivial loop then shows up many times in the code (there's a bit of trickiness involving finding the Wigner-Seitz cell). And it seems that template expressions provide almost precisely what I want. Is there a class that does this, e.g. something like class VirtualMatrix<...? { VirtualMatrix(double (*func)(int, int)); } which could just take a function of indices and turns it into a matrix? If there isn't something like this built into eigen, would it be easy to create? I've tried (briefly) to create a new class deriving MatrixBase, but immediately ran into trouble. Perhaps I just know too little about C++ templates to use eigen effectively. :( David Roundy

**Follow-Ups**:**Re: [eigen] how to create a "virtual" array or matrix?***From:*Carlos Becker

**Re: [eigen] how to create a "virtual" array or matrix?***From:*Benoit Jacob

**Re: [eigen] how to create a "virtual" array or matrix?***From:*Manoj Rajagopalan

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] runtime API to configure the cache/blocking parameters** - Next by Date:
**Re: [eigen] how to create a "virtual" array or matrix?** - Previous by thread:
**Re: [eigen] runtime API to configure the cache/blocking parameters** - Next by thread:
**Re: [eigen] how to create a "virtual" array or matrix?**

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