The TinyVector class provides a small, lightweight vector object whose size is known at compile time.  It is included via the header <blitz/tinyvec.h>.

Note that TinyVector lives in the blitz namespace, so you will need to refer to it as blitz::TinyVector, or use the directive using namespace blitz;.

The Blitz++ Array object uses TinyVector internally, so if you include <blitz/array.h>, the TinyVector header is automatically included.  However, to use TinyVector expressions, you will need to include <blitz/tinyvec-et.h>.

Template parameters and types
=============================

The TinyVector<T,N> class has two template parameters:

T
     is the numeric type of the vector (float, double, int, complex<float>, etc.;

N
     is the number of elements in the vector.

Inside the TinyVector class, these types are declared:

T_numtype
     is the numeric type stored in the vector (the template parameter T)

T_vector
     is the vector type TinyVector<T,N>.

iterator
     is an STL-style iterator.

constIterator
     is an STL-style const iterator.

Constructors
============

     TinyVector();

The elements of the vector are left uninitialized.

     TinyVector(const TinyVector<T,N>& x);

The elements of vector x are copied.

     TinyVector(T value);

All elements are initialized to value.

     TinyVector(T value1, T value2, ...);

The vector is initialized with the list of values given. These constructors are provided for up to N=11.

Member functions
================

     TinyVector<T,N>::iterator                   begin();
     TinyVector<T,N>::const_iterator             begin() const;

Returns an STL-style iterator for the vector, positioned at the beginning of the data.

     TinyVector<T,N>::iterator                   end();
     TinyVector<T,N>::const_iterator             end() const;

Returns an STL-style iterator for the vector, positioned at the end of the data.

     T_numtype* [restrict]                       data();
     const T_numtype* [restrict]                 data() const;

Returns a pointer to the first element in the vector.

     int                                         length() const;

Returns the length of the vector (the template parameter N).

     T_numtype                                   operator()(int i) const;
     T_numtype&                                  operator()(int i);
     T_numtype                                   operator[](int i) const;
     T_numtype&                                  operator[](int i);

Returns the ith element of the vector.  If the code is compiled with debugging enabled (-DBZ_DEBUG), bounds checking is performed.

Assignment operators
====================

The assignment operators =, +=, -=, *=, /=, %=, ^=, &=, |=, >>= and <<= are all provided.  The right hand side of an assignment may be a scalar of type T_numtype, a TinyVector of any type but the same size, or a vector expression.

Expressions
===========

Expressions involving tiny vectors may contain any combination of the operators

     + - * / % ^ & | >> <<

with operands of type TinyVector, scalar, or vector expressions. The usual math functions (see the Array documentation) are supported on TinyVector.  Please note that to use TinyVector expressions, you will need to include header <blitz/tinyvec-et.h> in your code.

Global functions
================

     dot(TinyVector, TinyVector);
     dot(vector-expr, TinyVector);
     dot(TinyVector, vector-expr);
     dot(vector-expr, vector-expr);

These functions calculate a dot product between TinyVectors (or vector expressions).  The result is a scalar; the type of the scalar follows the usual type promotion rules.

     product(TinyVector);

Returns the product of all the elements in the vector.

     sum(TinyVector);

Returns the sum of the elements in the vector.

     TinyVector<T,3> cross(TinyVector<T,3> x, TinyVector<T,3> y);

Returns the cross product of x and y.

Arrays of TinyVector
====================

TinyVectors may be used as an Array element type, just like any other concrete numerical data type such as the built-in type double.  Such an Array of TinyVector elements constitutes a multicomponent Array, with the number of Array components being equal to the length of the TinyVectors.  Please see Array multi for further information.

Input/output
============

     ostream& operator<<(ostream&, const TinyVector<T,N>& x);

This function outputs a TinyVector onto a stream.  Here's an illustration of the format for a length 3 vector:

     [        0.5       0.2       0.9 ]