All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Types | List of all members
blaze::StaticVector< Type, N, TF > Class Template Reference

Efficient implementation of a fixed-sized vector.The StaticVector class template is the representation of a fixed-size vector with statically allocated elements of arbitrary type. The type of the elements, the number of elements and the transpose flag of the vector can be specified via the three template parameters: More...

#include <StaticVector.h>

Inherits blaze::DenseVector< StaticVector< Type, N, TF >, TF >, and blaze::AlignedStorage< Type >.

Public Types

enum  { vectorizable = IsVectorizable<Type>::value }
 Compilation flag for intrinsic optimization. More...
 
enum  { canAlias = 0 }
 Compilation flag for the detection of aliasing effects. More...
 
typedef StaticVector< Type, N, TF > This
 Type of this StaticVector instance.
 
typedef This ResultType
 Result type for expression template evaluations.
 
typedef StaticVector< Type, N,!TF > TransposeType
 Transpose type for expression template evaluations.
 
typedef Type ElementType
 Type of the vector elements.
 
typedef IT::Type IntrinsicType
 Intrinsic type of the vector elements.
 
typedef const Type & ReturnType
 Return type for expression template evaluations.
 
typedef const StaticVectorCompositeType
 Data type for composite expression templates.
 
typedef Type & Reference
 Reference to a non-constant vector value.
 
typedef const Type & ConstReference
 Reference to a constant vector value.
 
typedef Type * Iterator
 Iterator over non-constant elements.
 
typedef const Type * ConstIterator
 Iterator over constant elements.
 
typedef CMathTrait< Type >::Type LengthType
 Vector length return type.
 
typedef VT VectorType
 Type of the vector.
 

Public Member Functions

VectorTypeoperator~ ()
 Conversion operator for non-constant vectors.
 
const VectorTypeoperator~ () const
 Conversion operator for constant vectors.
 
Constructors
 StaticVector ()
 The default constructor for StaticVector.
 
 StaticVector (const Type &init)
 Constructor for a homogenous initialization of all elements.
 
 StaticVector (const StaticVector &v)
 The copy constructor for StaticVector.
 
template<typename Other >
 StaticVector (const StaticVector< Other, N, TF > &v)
 Conversion constructor from different StaticVector instances.
 
template<typename VT >
 StaticVector (const Vector< VT, TF > &v)
 Conversion constructor from different vectors.
 
template<typename Other >
 StaticVector (const Other(&rhs)[N])
 Array initialization of all vector elements.
 
 StaticVector (const Type &v1, const Type &v2)
 Constructor for 2-dimensional vectors.
 
 StaticVector (const Type &v1, const Type &v2, const Type &v3)
 Constructor for 3-dimensional vectors.
 
 StaticVector (const Type &v1, const Type &v2, const Type &v3, const Type &v4)
 Constructor for 4-dimensional vectors.
 
 StaticVector (const Type &v1, const Type &v2, const Type &v3, const Type &v4, const Type &v5)
 Constructor for 5-dimensional vectors.
 
 StaticVector (const Type &v1, const Type &v2, const Type &v3, const Type &v4, const Type &v5, const Type &v6)
 Constructor for 6-dimensional vectors.
 
Data access functions
Reference operator[] (size_t index)
 Subscript operator for the direct access to the vector elements.
 
ConstReference operator[] (size_t index) const
 Subscript operator for the direct access to the vector elements.
 
Type * data ()
 Low-level data access to the vector elements.
 
const Type * data () const
 Low-level data access to the vector elements.
 
Iterator begin ()
 Returns an iterator to the first element of the static vector.
 
ConstIterator begin () const
 Returns an iterator to the first element of the static vector.
 
ConstIterator cbegin () const
 Returns an iterator to the first element of the static vector.
 
Iterator end ()
 Returns an iterator just past the last element of the static vector.
 
ConstIterator end () const
 Returns an iterator just past the last element of the static vector.
 
ConstIterator cend () const
 Returns an iterator just past the last element of the static vector.
 
Assignment operators
StaticVectoroperator= (Type rhs)
 Homogenous assignment to all vector elements.
 
StaticVectoroperator= (const StaticVector &rhs)
 Copy assignment operator for StaticVector.
 
template<typename Other >
StaticVectoroperator= (const StaticVector< Other, N, TF > &rhs)
 Assignment operator for different StaticVector instances.
 
template<typename VT >
StaticVectoroperator= (const Vector< VT, TF > &rhs)
 Assignment operator for different vectors.
 
template<typename Other >
StaticVectoroperator= (const Other(&rhs)[N])
 Array assignment to all vector elements.
 
template<typename VT >
StaticVectoroperator+= (const Vector< VT, TF > &rhs)
 Addition assignment operator for the addition of a vector ( $ \vec{a}+=\vec{b} $).
 
template<typename VT >
StaticVectoroperator-= (const Vector< VT, TF > &rhs)
 Subtraction assignment operator for the subtraction of a vector ( $ \vec{a}-=\vec{b} $).
 
template<typename VT >
StaticVectoroperator*= (const Vector< VT, TF > &rhs)
 Multiplication assignment operator for the multiplication of a vector ( $ \vec{a}*=\vec{b} $).
 
template<typename Other >
EnableIf< IsNumeric< Other >
, StaticVector >::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a vector and a scalar value ( $ \vec{a}*=s $).
 
template<typename Other >
EnableIf< IsNumeric< Other >
, StaticVector >::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a vector by a scalar value ( $ \vec{a}/=s $).
 
Utility functions
size_t size () const
 Returns the current size/dimension of the vector.
 
size_t nonZeros () const
 Returns the number of non-zero elements in the vector.
 
void reset ()
 Reset to the default initial values.
 
LengthType length () const
 Calculation of the vector length $|\vec{a}|$.
 
Type sqrLength () const
 Calculation of the vector square length $|\vec{a}|^2$.
 
StaticVectornormalize ()
 Normalization of the vector ( $|\vec{a}|=1$).
 
const StaticVector getNormalized () const
 Calculation of the normalized vector ( $|\vec{a}|=1$).
 
template<typename Other >
StaticVectorscale (Other scalar)
 Scaling of the vector by the scalar value scalar ( $ \vec{a}*=s $).
 
Type min () const
 Returns the smallest element of the vector.
 
Type max () const
 Returns the largest element of the vector.
 
void swap (StaticVector &v)
 Swapping the contents of two static vectors.
 
Expression template evaluation functions
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the vector is aliased with the given address alias.
 
IntrinsicType get (size_t index) const
 Access to the intrinsic elements of the vector.
 
template<typename VT >
DisableIf< VectorizedAssign
< VT > >::Type 
assign (const DenseVector< VT, TF > &rhs)
 Default implementation of the assignment of a dense vector.
 
template<typename VT >
EnableIf< VectorizedAssign< VT >
>::Type 
assign (const DenseVector< VT, TF > &rhs)
 
template<typename VT >
void assign (const SparseVector< VT, TF > &rhs)
 Default implementation of the assignment of a sparse vector.
 
template<typename VT >
DisableIf< VectorizedAddAssign
< VT > >::Type 
addAssign (const DenseVector< VT, TF > &rhs)
 Default implementation of the addition assignment of a dense vector.
 
template<typename VT >
EnableIf< VectorizedAddAssign
< VT > >::Type 
addAssign (const DenseVector< VT, TF > &rhs)
 
template<typename VT >
void addAssign (const SparseVector< VT, TF > &rhs)
 Default implementation of the addition assignment of a sparse vector.
 
template<typename VT >
DisableIf< VectorizedSubAssign
< VT > >::Type 
subAssign (const DenseVector< VT, TF > &rhs)
 Default implementation of the subtraction assignment of a dense vector.
 
template<typename VT >
EnableIf< VectorizedSubAssign
< VT > >::Type 
subAssign (const DenseVector< VT, TF > &rhs)
 
template<typename VT >
void subAssign (const SparseVector< VT, TF > &rhs)
 Default implementation of the subtraction assignment of a sparse vector.
 
template<typename VT >
DisableIf
< VectorizedMultAssign< VT >
>::Type 
multAssign (const DenseVector< VT, TF > &rhs)
 Default implementation of the multiplication assignment of a dense vector.
 
template<typename VT >
EnableIf< VectorizedMultAssign
< VT > >::Type 
multAssign (const DenseVector< VT, TF > &rhs)
 
template<typename VT >
void multAssign (const SparseVector< VT, TF > &rhs)
 Default implementation of the multiplication assignment of a sparse vector.
 

Private Types

enum  { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size }
 Alignment adjustment.
 
typedef IntrinsicTrait< Type > IT
 Intrinsic trait for the vector element type.
 

Private Attributes

Member variables
Type v_ [NN]
 The statically allocated vector elements.
 

Detailed Description

template<typename Type, size_t N, bool TF = defaultTransposeFlag>
class blaze::StaticVector< Type, N, TF >

Efficient implementation of a fixed-sized vector.

The StaticVector class template is the representation of a fixed-size vector with statically allocated elements of arbitrary type. The type of the elements, the number of elements and the transpose flag of the vector can be specified via the three template parameters:

template< typename Type, size_t N, bool TF >

These contiguously stored elements can be direclty accessed with the subscript operator. The numbering of the vector elements is

\[\left(\begin{array}{*{4}{c}} 0 & 1 & \cdots & N-1 \\ \end{array}\right)\]

The use of StaticVector is very natural and intuitive. All operations (addition, subtraction, multiplication, scaling, ...) can be performed on all possible combinations of dense and sparse vectors with fitting element types. The following example gives an impression of the use of a 2-dimensional StaticVector:

StaticVector<double,2UL> a, // Default initialized 2D vectors
a[0] = 1.0; // Initialization of the first element
a[1] = 2.0; // Initialization of the second element
StaticVector<double,2UL> b( 3.0, 2.0 ); // Directly initialized 2D vector
CompressedVector<float> c( 4.0F ); // Empty single precision vector
StaticVector<double,2UL> d; // Default constructed static vector
StaticMatrix<double,2UL,2UL> A; // Default constructed static row-major matrix
d = a + b; // Vector addition between vectors of equal element type
d = a - c; // Vector subtraction between vector of different element type
d = a * b; // Component-wise vector multiplication
a *= 2.0; // In-place scaling of vector
d = a * 2.0; // Scaling of vector a
d = 2.0 * a; // Scaling of vector a
d += a - b; // Addition assignment
d -= a + c; // Subtraction assignment
d *= a * b; // Multiplication assignment
double scalar = trans( a ) * b; // Scalar/dot/inner product between two vectors
A = a * trans( b ); // Outer product between two vectors

Member Typedef Documentation

template<typename Type, size_t N, bool TF = defaultTransposeFlag>
typedef CMathTrait<Type>::Type blaze::StaticVector< Type, N, TF >::LengthType

Vector length return type.

Return type of the StaticVector<Type,N,TF>::length function.

Member Enumeration Documentation

template<typename Type, size_t N, bool TF = defaultTransposeFlag>
anonymous enum

Compilation flag for intrinsic optimization.

The vectorizable compilation flag indicates whether expressions the vector is involved in can be optimized via intrinsics. In case the element type of the vector is a vectorizable data type, the vectorizable compilation flag is set to true, otherwise it is set to false.

template<typename Type, size_t N, bool TF = defaultTransposeFlag>
anonymous enum

Compilation flag for the detection of aliasing effects.

This compilation switch indicates whether this type potentially causes compuation errors due to aliasing effects. In case the type can cause aliasing effects, the canAlias switch is set to true, otherwise it is set to false.

Constructor & Destructor Documentation

template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( )
inlineexplicit

The default constructor for StaticVector.

All vector elements are initialized to the default value (i.e. 0 for integral data types).

template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( const Type &  init)
inlineexplicit

Constructor for a homogenous initialization of all elements.

Parameters
initInitial value for all vector elements.
template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( const StaticVector< Type, N, TF > &  v)
inline

The copy constructor for StaticVector.

Parameters
vVector to be copied.

The copy constructor is explicitly defined in order to enable/facilitate NRV optimization.

template<typename Type , size_t N, bool TF>
template<typename Other >
blaze::StaticVector< Type, N, TF >::StaticVector ( const StaticVector< Other, N, TF > &  v)
inline

Conversion constructor from different StaticVector instances.

Parameters
vVector to be copied.
template<typename Type , size_t N, bool TF>
template<typename VT >
blaze::StaticVector< Type, N, TF >::StaticVector ( const Vector< VT, TF > &  v)
inline

Conversion constructor from different vectors.

Parameters
vVector to be copied.
Exceptions
std::invalid_argumentInvalid setup of static vector.

This constructor initializes the static vector from the given vector. In case the size of the given vector does not match the size of the static vector (i.e. is not N), a std::invalid_argument exception is thrown.

template<typename Type , size_t N, bool TF>
template<typename Other >
blaze::StaticVector< Type, N, TF >::StaticVector ( const Other(&)  rhs[N])
inlineexplicit

Array initialization of all vector elements.

Parameters
rhsN-dimensional array for the initialization.

This assignment operator offers the option to directly initialize the elements of the vector:

const double init[2] = { 1.0, 2.0 };

The vector is initialized with the given values. Missing values are initialized with zero.

template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( const Type &  v1,
const Type &  v2 
)
inline

Constructor for 2-dimensional vectors.

Parameters
v1The initializer for the first vector element.
v2The initializer for the second vector element.

This constructor offers the option to create 2-dimensional vectors with specific elements:

template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( const Type &  v1,
const Type &  v2,
const Type &  v3 
)
inline

Constructor for 3-dimensional vectors.

Parameters
v1The initializer for the first vector element.
v2The initializer for the second vector element.
v3The initializer for the third vector element.

This constructor offers the option to create 3-dimensional vectors with specific elements:

template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( const Type &  v1,
const Type &  v2,
const Type &  v3,
const Type &  v4 
)
inline

Constructor for 4-dimensional vectors.

Parameters
v1The initializer for the first vector element.
v2The initializer for the second vector element.
v3The initializer for the third vector element.
v4The initializer for the fourth vector element.

This constructor offers the option to create 4-dimensional vectors with specific elements:

template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( const Type &  v1,
const Type &  v2,
const Type &  v3,
const Type &  v4,
const Type &  v5 
)
inline

Constructor for 5-dimensional vectors.

Parameters
v1The initializer for the first vector element.
v2The initializer for the second vector element.
v3The initializer for the third vector element.
v4The initializer for the fourth vector element.
v5The initializer for the fifth vector element.

This constructor offers the option to create 5-dimensional vectors with specific elements:

blaze::StaticVector<int,5> v( 1, 2, 3, 4, 5 );
template<typename Type , size_t N, bool TF>
blaze::StaticVector< Type, N, TF >::StaticVector ( const Type &  v1,
const Type &  v2,
const Type &  v3,
const Type &  v4,
const Type &  v5,
const Type &  v6 
)
inline

Constructor for 6-dimensional vectors.

Parameters
v1The initializer for the first vector element.
v2The initializer for the second vector element.
v3The initializer for the third vector element.
v4The initializer for the fourth vector element.
v5The initializer for the fifth vector element.
v6The initializer for the sixth vector element.

This constructor offers the option to create 6-dimensional vectors with specific elements:

blaze::StaticVector<int,6> v( 1, 2, 3, 4, 5, 6 );

Member Function Documentation

template<typename Type , size_t N, bool TF>
template<typename VT >
EnableIf< typename StaticVector< Type, N, TF >::BLAZE_TEMPLATE VectorizedAddAssign< VT > >::Type blaze::StaticVector< Type, N, TF >::addAssign ( const DenseVector< VT, TF > &  rhs)
inline

Default implementation of the addition assignment of a dense vector.

Intrinsic optimized implementation of the addition assignment of a dense vector.

Parameters
rhsThe right-hand side dense vector to be added.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
template<typename VT >
void blaze::StaticVector< Type, N, TF >::addAssign ( const SparseVector< VT, TF > &  rhs)
inline

Default implementation of the addition assignment of a sparse vector.

Parameters
rhsThe right-hand side sparse vector to be added.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
template<typename VT >
EnableIf< typename StaticVector< Type, N, TF >::BLAZE_TEMPLATE VectorizedAssign< VT > >::Type blaze::StaticVector< Type, N, TF >::assign ( const DenseVector< VT, TF > &  rhs)
inline

Default implementation of the assignment of a dense vector.

Intrinsic optimized implementation of the assignment of a dense vector.

Parameters
rhsThe right-hand side dense vector to be assigned.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
template<typename VT >
void blaze::StaticVector< Type, N, TF >::assign ( const SparseVector< VT, TF > &  rhs)
inline

Default implementation of the assignment of a sparse vector.

Parameters
rhsThe right-hand side sparse vector to be assigned.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::Iterator blaze::StaticVector< Type, N, TF >::begin ( )
inline

Returns an iterator to the first element of the static vector.

Returns
Iterator to the first element of the static vector.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::ConstIterator blaze::StaticVector< Type, N, TF >::begin ( ) const
inline

Returns an iterator to the first element of the static vector.

Returns
Iterator to the first element of the static vector.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::ConstIterator blaze::StaticVector< Type, N, TF >::cbegin ( ) const
inline

Returns an iterator to the first element of the static vector.

Returns
Iterator to the first element of the static vector.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::ConstIterator blaze::StaticVector< Type, N, TF >::cend ( ) const
inline

Returns an iterator just past the last element of the static vector.

Returns
Iterator just past the last element of the static vector.
template<typename Type , size_t N, bool TF>
Type * blaze::StaticVector< Type, N, TF >::data ( )
inline

Low-level data access to the vector elements.

Returns
Pointer to the internal element storage.
template<typename Type , size_t N, bool TF>
const Type * blaze::StaticVector< Type, N, TF >::data ( ) const
inline

Low-level data access to the vector elements.

Returns
Pointer to the internal element storage.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::Iterator blaze::StaticVector< Type, N, TF >::end ( )
inline

Returns an iterator just past the last element of the static vector.

Returns
Iterator just past the last element of the static vector.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::ConstIterator blaze::StaticVector< Type, N, TF >::end ( ) const
inline

Returns an iterator just past the last element of the static vector.

Returns
Iterator just past the last element of the static vector.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::IntrinsicType blaze::StaticVector< Type, N, TF >::get ( size_t  index) const
inline

Access to the intrinsic elements of the vector.

Parameters
indexAccess index. The index has to be in the range $[0..N-1]$.
Returns
Reference to the accessed values.

This function offers a direct access to the intrinsic elements of the vector. It must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.

template<typename Type , size_t N, bool TF>
const StaticVector< Type, N, TF > blaze::StaticVector< Type, N, TF >::getNormalized ( ) const
inline

Calculation of the normalized vector ( $|\vec{a}|=1$).

Returns
The normalized vector.

The function returns the normalized vector. This operation is only defined for floating point vectors. The attempt to use this function for an integral vector results in a compile time error.

template<typename Type , size_t N, bool TF>
template<typename Other >
bool blaze::StaticVector< Type, N, TF >::isAliased ( const Other *  alias) const
inline

Returns whether the vector is aliased with the given address alias.

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this vector, false if not.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::LengthType blaze::StaticVector< Type, N, TF >::length ( ) const
inline

Calculation of the vector length $|\vec{a}|$.

Returns
The length of the vector.

This function calculates the actual length of the vector. The return type of the length() function depends on the actual type of the vector instance:

Type LengthType
float float
integral data types and double double
long double long double

Note: This operation is only defined for built-in data types. In case Type is a user defined data type the attempt to use the length() function results in a compile time error!

template<typename Type , size_t N, bool TF>
Type blaze::StaticVector< Type, N, TF >::max ( ) const
inline

Returns the largest element of the vector.

Returns
The largest vector element.
template<typename Type , size_t N, bool TF>
Type blaze::StaticVector< Type, N, TF >::min ( ) const
inline

Returns the smallest element of the vector.

Returns
The smallest vector element.
template<typename Type , size_t N, bool TF>
template<typename VT >
EnableIf< typename StaticVector< Type, N, TF >::BLAZE_TEMPLATE VectorizedMultAssign< VT > >::Type blaze::StaticVector< Type, N, TF >::multAssign ( const DenseVector< VT, TF > &  rhs)
inline

Default implementation of the multiplication assignment of a dense vector.

Intrinsic optimized implementation of the multiplication assignment of a dense vector.

Parameters
rhsThe right-hand side dense vector to be multiplied.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
template<typename VT >
void blaze::StaticVector< Type, N, TF >::multAssign ( const SparseVector< VT, TF > &  rhs)
inline

Default implementation of the multiplication assignment of a sparse vector.

Parameters
rhsThe right-hand side sparse vector to be multiplied.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
size_t blaze::StaticVector< Type, N, TF >::nonZeros ( ) const
inline

Returns the number of non-zero elements in the vector.

Returns
The number of non-zero elements in the vector.

Note that the number of non-zero elements is always less than or equal to the current size of the vector.

template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::normalize ( )
inline

Normalization of the vector ( $|\vec{a}|=1$).

Returns
Reference to the vector.

Normalization of the vector to a length of 1. This operation is only defined for floating point vectors. The attempt to use this function for an integral vector results in a compile time error.

template<typename Type , size_t N, bool TF>
template<typename VT >
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator*= ( const Vector< VT, TF > &  rhs)
inline

Multiplication assignment operator for the multiplication of a vector ( $ \vec{a}*=\vec{b} $).

Parameters
rhsThe right-hand side vector to be multiplied with the vector.
Returns
Reference to the vector.
Exceptions
std::invalid_argumentVector sizes do not match.

In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.

template<typename Type , size_t N, bool TF>
template<typename Other >
EnableIf< IsNumeric< Other >, StaticVector< Type, N, TF > >::Type & blaze::StaticVector< Type, N, TF >::operator*= ( Other  rhs)
inline

Multiplication assignment operator for the multiplication between a vector and a scalar value ( $ \vec{a}*=s $).

Parameters
rhsThe right-hand side scalar value for the multiplication.
Returns
Reference to the vector.
template<typename Type , size_t N, bool TF>
template<typename VT >
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator+= ( const Vector< VT, TF > &  rhs)
inline

Addition assignment operator for the addition of a vector ( $ \vec{a}+=\vec{b} $).

Parameters
rhsThe right-hand side vector to be added to the vector.
Returns
Reference to the vector.
Exceptions
std::invalid_argumentVector sizes do not match.

In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.

template<typename Type , size_t N, bool TF>
template<typename VT >
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator-= ( const Vector< VT, TF > &  rhs)
inline

Subtraction assignment operator for the subtraction of a vector ( $ \vec{a}-=\vec{b} $).

Parameters
rhsThe right-hand side vector to be subtracted from the vector.
Returns
Reference to the vector.
Exceptions
std::invalid_argumentVector sizes do not match.

In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.

template<typename Type , size_t N, bool TF>
template<typename Other >
EnableIf< IsNumeric< Other >, StaticVector< Type, N, TF > >::Type & blaze::StaticVector< Type, N, TF >::operator/= ( Other  rhs)
inline

Division assignment operator for the division of a vector by a scalar value ( $ \vec{a}/=s $).

Parameters
rhsThe right-hand side scalar value for the division.
Returns
Reference to the vector.

Note: A division by zero is only checked by an user assert.

template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator= ( Type  rhs)
inline

Homogenous assignment to all vector elements.

Parameters
rhsScalar value to be assigned to all vector elements.
Returns
Reference to the assigned vector.
template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator= ( const StaticVector< Type, N, TF > &  rhs)
inline

Copy assignment operator for StaticVector.

Parameters
rhsVector to be copied.
Returns
Reference to the assigned vector.

Explicit definition of a copy assignment operator for performance reasons.

template<typename Type , size_t N, bool TF>
template<typename Other >
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator= ( const StaticVector< Other, N, TF > &  rhs)
inline

Assignment operator for different StaticVector instances.

Parameters
rhsVector to be copied.
Returns
Reference to the assigned vector.
template<typename Type , size_t N, bool TF>
template<typename VT >
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator= ( const Vector< VT, TF > &  rhs)
inline

Assignment operator for different vectors.

Parameters
rhsVector to be copied.
Returns
Reference to the assigned vector.
Exceptions
std::invalid_argumentInvalid assignment to static vector.

This constructor initializes the vector as a copy of the given vector. In case the size of the given vector is not N, a std::invalid_argument exception is thrown.

template<typename Type , size_t N, bool TF>
template<typename Other >
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::operator= ( const Other(&)  rhs[N])
inline

Array assignment to all vector elements.

Parameters
rhsN-dimensional array for the assignment.
Returns
Reference to the assigned vector.

This assignment operator offers the option to directly set all elements of the vector:

const double init[2] = { 1.0, 2.0 };
v = init;

The vector is initialized with the given values. Missing values are initialized with zero.

template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::Reference blaze::StaticVector< Type, N, TF >::operator[] ( size_t  index)
inline

Subscript operator for the direct access to the vector elements.

Parameters
indexAccess index. The index has to be in the range $[0..N-1]$.
Returns
Reference to the accessed value.

In case BLAZE_USER_ASSERT() is active, this operator performs an index check.

template<typename Type , size_t N, bool TF>
StaticVector< Type, N, TF >::ConstReference blaze::StaticVector< Type, N, TF >::operator[] ( size_t  index) const
inline

Subscript operator for the direct access to the vector elements.

Parameters
indexAccess index. The index has to be in the range $[0..N-1]$.
Returns
Reference-to-const to the accessed value.

In case BLAZE_USER_ASSERT() is active, this operator performs an index check.

template<typename VT, bool TF>
VectorType& blaze::Vector< VT, TF >::operator~ ( )
inlineinherited

Conversion operator for non-constant vectors.

Returns
Reference of the actual type of the vector.
template<typename VT, bool TF>
const VectorType& blaze::Vector< VT, TF >::operator~ ( ) const
inlineinherited

Conversion operator for constant vectors.

Returns
Const reference of the actual type of the vector.
template<typename Type , size_t N, bool TF>
void blaze::StaticVector< Type, N, TF >::reset ( )
inline

Reset to the default initial values.

Returns
void
template<typename Type , size_t N, bool TF>
template<typename Other >
StaticVector< Type, N, TF > & blaze::StaticVector< Type, N, TF >::scale ( Other  scalar)
inline

Scaling of the vector by the scalar value scalar ( $ \vec{a}*=s $).

Parameters
scalarThe scalar value for the vector scaling.
Returns
Reference to the vector.
template<typename Type , size_t N, bool TF>
size_t blaze::StaticVector< Type, N, TF >::size ( ) const
inline

Returns the current size/dimension of the vector.

Returns
The size of the vector.
template<typename Type , size_t N, bool TF>
Type blaze::StaticVector< Type, N, TF >::sqrLength ( ) const
inline

Calculation of the vector square length $|\vec{a}|^2$.

Returns
The square length of the vector.

This function calculates the actual square length of the vector.

Note: This operation is only defined for built-in data types. In case Type is a user defined data type the attempt to use the length() function results in a compile time error!

template<typename Type , size_t N, bool TF>
template<typename VT >
EnableIf< typename StaticVector< Type, N, TF >::BLAZE_TEMPLATE VectorizedSubAssign< VT > >::Type blaze::StaticVector< Type, N, TF >::subAssign ( const DenseVector< VT, TF > &  rhs)
inline

Default implementation of the subtraction assignment of a dense vector.

Intrinsic optimized implementation of the subtraction assignment of a dense vector.

Parameters
rhsThe right-hand side dense vector to be subtracted.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
template<typename VT >
void blaze::StaticVector< Type, N, TF >::subAssign ( const SparseVector< VT, TF > &  rhs)
inline

Default implementation of the subtraction assignment of a sparse vector.

Parameters
rhsThe right-hand side sparse vector to be subtracted.
Returns
void

This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename Type , size_t N, bool TF>
void blaze::StaticVector< Type, N, TF >::swap ( StaticVector< Type, N, TF > &  v)
inline

Swapping the contents of two static vectors.

Parameters
vThe vector to be swapped.
Returns
void
Exceptions
no-throwguarantee.

Member Data Documentation

template<typename Type, size_t N, bool TF = defaultTransposeFlag>
Type blaze::StaticVector< Type, N, TF >::v_[NN]
private

The statically allocated vector elements.

Access to the vector values is gained via the subscript operator. The order of the elements is

\[\left(\begin{array}{*{4}{c}} 0 & 1 & \cdots & N-1 \\ \end{array}\right)\]


The documentation for this class was generated from the following file: