BlitzArray
The BlitzArray is a wrapper for the
blitz++ Array class; it
provides compatibility with cvmlcpp.
Interface
The interface of BlitzArray should be fully compatible with that of
blitz::array.
To use the BlitzArray, either include it before including other parts of the
cvmlcpp, or define USE_BLITZ during compilation.
Example
3D Fourier Transform
#include <cvmlcpp/base/BlitzArray>
#include <cvmlcpp/signal/Fourier>
using namespace cvmlcpp;
// Have a blitz++ array
blitz::Array<int, 3> a(3, 4, 5);
std::fill(a.begin(), a.end(), 7);
// Create a wrapper around "a" for cvmlcpp-compatibility
BlitzArray<int, 3> ba(a);
assert( (3*4*5*7) == std::accumulate(ba.begin(), ba.end(), 0));
// Create output directly as a wrapper
BlitzArray<std::complex<double>, 3> ba_fft;
// Compute 3D-Fourier tranform with "fftw"
doDFT(ba, ba_fft);
// Use ba_fft as any other blitz++ array
...
Problem with Constructors
The following code will not compile:
BlitzArray<std::complex<double>, 3> bc(3, 4, 5);
blitz::Array<std::complex<double>, 3> c(bc); /* Doesn't work */
The reason is that the compiler will not use the desired constructor, and
compilation will be aborted. Hence, you must always create a
blitz::Array<...> first, and create a BlitzArray<...>
after that.
|