Table of Contents
In VSIPL++, simple operators are typically defined as functions that act on view objects, and either modify their arguments or return the result as another view object. For example, the elementwise addition operator can be invoked on two vectors by
Vector<float> A(10, 3.0f), B(10, 5.0f), Z(10); Z = add(A, B);
Some simple operations are also defined by overloading the arithmetic operators; for instance, the above addition could also have been written as
Z = A + B;
VSIPL++ also includes several operator classes. These are more complicated operators that must allocate internal working memory, or contain of a setup phase that may be reusable. These include FFTs (for which the allocation of working memory and the definition of the twiddle factors can be reused for repeated applications to views with the same dimensions) and matrix solvers (which may decompose a matrix and can then use that decomposition repeatedly with differing right-hand sides). Constructing an object of an operator class performs this setup work, and the object can then be applied to view objects in a manner analogous to a function.
For example, an object corresponding to a 1024-element FFT operator with complex float arguments and no scaling can be defined by
Fft<const_Vector, complex<float>, complex<float>, fft_fwd, by_value> fft_obj(1024, 1.f);
Once defined, this can be used (to compute Z as the
Fourier transform of A) as
Vector<complex<float> > A(1024, 1.0f), Z(1024); fft_obj(A, Z);