Boost logo

Boost :

From: Michael Tegtmeyer (tegtmeye_at_[hidden])
Date: 2007-05-23 13:07:44


Some time ago I posted a message to this list about interest in a static-sized
version of cvalarray. I'll include the original message for reference. I
received some emails stating that there was interest. The implementation has
been in the sandbox for some time now. I'd like to guage interest again to
determine if it is worth working to add to boost.

The implementation has not been boostified because it is in active use here
where I work (autotool land) so if there is interest, some additional work
needs to be done to absorb the boost framework.

The implementation is complete without any known bugs. There is only one header
but you can go though the normal ./configure, make, make install to put it
somewhere. Tests can be run using 'make check' and documentation is in the doc
directory.

Of additional interest since my previous post: the implementation will now
automaticallty unroll all numeric ops at compile time (subject to the compiler)
up to a predefined array size.

My original post:

Hello,

I am trying to guage interest in a fixed sized version of valarray. I
frequently found myself using small(-ish) compile-time known sized
numeric arrays that don't justify the overhead of operator new in
std::valarray but needed the math interface that valarray provided. I
wrote a static-sized version of valarray for this purpose. It is modeled
after std::valarray and implements about 90% of valarray's interface
(obviously resizing is not included, neither is gslice due to the result
not being known at compile time). Examples of it's use are:

float _v[10] = {...};
size_t _i[5] = {...};

cvalarray<float,10> v1(_v);
cvalarray<float,5> v2 = v1[cslice<0,5,2>()];
v1[cslice<0,3,3>()] = 0.0f;

cvalarray<size_t,5> ind(_i);
cvalarray<float,5> cvalB = v1[ind];

v2 *= (v2 + v1) / 2.0;
//all of the usual math ops

I have a complete implementation that models std::valarray in every
possible way (with compile-time known limitations) including
expression-template support for the numeric ops. My testing indicates a
decent performance increase over gcc4's valarray for small number of
elements <1000.

If anyone has any interest, I'll put together some docs and throw it in
the sandbox.

Mike Tegtmeyer


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk