On Wed, 2005-06-08 at 14:08 +0200, Alfons Adriaensen wrote:
typedef
list<Foo> Foos;
Valid point, there are occasions where you can do this sort of thing.
But when we are talking about large data sets and heavy use, it could
lead to some nasty surprises. For small data sets, it doesn't matter
much.
Using C++ and/or templates doesn't necessarily make anything any slower,
but improves readability.
For example, if you would like to multiply some dataset with window...
With libDSP you can do:
typedef float sample_t;
clDSPVector<sample_t> vData;
clDSPVector<sample_t> vWindow;
vWindow.WinHamming(1024);
...
vData.Set(pSrcBuf, 1024);
vData *= vWindow;
This would perform the multiply using handwritten asm SIMD routines.
And you can still access the individual samples by using vData[n]
without significant performance penalty compared to a simple float
array. And I say "significant" here just because it also performs bounds
checking. It could be made even equally fast by changing the operator[]
implementation.
I think the above is much clearer and faster to use than calling equal C
functions (which also exist). And you can easily change it to use
doubles instead of floats just by changing the typedef.
--
Jussi Laako <jussi.laako(a)pp.inet.fi>