VSIPL++ Vector objects represent one-dimensional sets of data.
The type of values stored in the vector is given by the first template argument.
Examples:
Vector<scalar_f>
Vector<double>
Vector<cscalar_f>
Vector<complex<double> >
Optionally, the physical storage format can be controlled by the
second template argument, which specifies the block type used to represent
the data. If this is not specified, the default block type of
Dense is used, which represents data stored in
contiguous memory.
Example:
Vector<float, Dense<1, float> >
Dense<1,
float> storage.Vectors can also be of type const_Vector, in which
case their values cannot be modified directly.
Vectors are created by declaring an object of type
Vector. The following constructors exist:
Vector<float> A(size)
Vector<float> A(size, value)
value.Vector<float> A(block)
Vector<float> A(vector)
A and vector have the same
block type, a reference (alias) is created. Otherwise a
copy is performed.)Vectors of const_Vector type can only be
constructed from existing Vectors with the block and vector
constructor forms.
The following operations can be performed on a vector in order to determine various attributes.
A.size()
A.size(d)
dth dimension. Since vectors are
one-dimensional, this is only defined for d = 0,
and size(0) == size().A.length()
A.size().A.block()
The following operations can be performed on a vector to read values from or write values to particular elements of the vector.
A(n)
nth
value of a vector. Unless the vector is
a const_vector, this can be used both to read values
from the vector and to write values to it.A.get(n)
nth value of a vector. This is
generally more efficient than A(n) for retrieving the
values of an elements.A.put(n, value)
nth value of a vector to
value. As with A.get(n), this is
generally more efficient than using A(n).VSIPL++ allows subviews of vectors to be created. A subview represents a subset of the original vector. The subview aliases the original vector, that is changes to the subview will be reflected in the original vector, and visa versa.
A(Domain<1>(start, stride, size))
A. The subview is of
size size. The nth element of the subview refers to
the start + n*stride element
of A.A.get(Domain<1>(start, stride, size))
const_Vector subview
of A.The subview type of a vector type allows for the creation of variables that reference subviews of a vector. For example,
Vector<scalar_f>::subview_type A = view(Domain<1>(f, s, l));
will create a variable A that references the
given subdomain of view. Thus, modifying
elements of A will modify the corresponding
elements of view and visa versa.
The underlying storage is reference-counted,
and it will not be deallocated until all references have been destroyed.
Thus, even if view is destroyed, the elements of
A will continue to be valid until it is destroyed as
well.
It is also possible to declare constant subview variables that cannot
be modified directly, thus preventing unexpected alterations to the primary
vector. These are declared with const_subview_type, as
(for instance)
Vector<scalar_f>::const_subview_type A = view(Domain<1>(f, s, l));
There are two additional subview functions for vectors of complex numbers:
real(A)
imag(A)
Reference variables for the real and imaginary variables have the
types Vector<T>::realview_type and
Vector<T>::imagview_type, respectively, or
Vector<T>::const_realview_type and
Vector<T>::const_imagview_type for subviews that
cannot be directly modified.