Classes | Public Types | Public Member Functions | Private Types | List of all members
blaze::CustomVector< Type, AF, PF, TF > Class Template Reference

Efficient implementation of a customizable vector. More...

#include <CustomVector.h>

Inherits blaze::DenseVector< CustomVector< Type, AF, PF, TF >, TF >.

Classes

struct  Rebind
 Rebind mechanism to obtain a CustomVector with different data/element type. More...
 

Public Types

enum  { vectorizable = IsVectorizable<Type>::value }
 Compilation flag for intrinsic optimization. More...
 
enum  { smpAssignable = !IsSMPAssignable<Type>::value }
 Compilation flag for SMP assignments. More...
 
typedef CustomVector< Type, AF, PF, TF > This
 Type of this CustomVector instance.
 
typedef DynamicVector< Type, TF > ResultType
 Result type for expression template evaluations.
 
typedef DynamicVector< Type,!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 CustomVectorCompositeType
 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 * Pointer
 Pointer to a non-constant vector value.
 
typedef const Type * ConstPointer
 Pointer to a constant vector value.
 
typedef DenseIterator< Type, AF > Iterator
 Iterator over non-constant elements.
 
typedef DenseIterator< const Type, AF > ConstIterator
 Iterator over constant elements.
 
typedef VT VectorType
 Type of the vector.
 

Public Member Functions

template<typename Other , size_t N>
CustomVector< Type, AF, PF, TF > & operator= (const Other(&array)[N])
 Array assignment to all vector elements. More...
 
template<typename VT >
CustomVector< Type, AF, PF, TF > & operator= (const Vector< VT, TF > &rhs)
 Assignment operator for different vectors. More...
 
template<typename VT >
CustomVector< Type, AF, PF, TF > & operator+= (const Vector< VT, TF > &rhs)
 Addition assignment operator for the addition of a vector ( $ \vec{a}+=\vec{b} $). More...
 
template<typename VT >
CustomVector< Type, AF, PF, TF > & operator-= (const Vector< VT, TF > &rhs)
 Subtraction assignment operator for the subtraction of a vector ( $ \vec{a}-=\vec{b} $). More...
 
template<typename VT >
CustomVector< Type, AF, PF, TF > & operator*= (const Vector< VT, TF > &rhs)
 Multiplication assignment operator for the multiplication of a vector ( $ \vec{a}*=\vec{b} $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >, CustomVector< Type, AF, PF, TF > >::Type & operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a vector and a scalar value ( $ \vec{a}*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >, CustomVector< Type, AF, PF, TF > >::Type & operator/= (Other rhs)
 Division assignment operator for the division of a vector by a scalar value ( $ \vec{a}/=s $). More...
 
template<typename Other >
CustomVector< Type, AF, PF, TF > & scale (const Other &scalar)
 Scaling of the vector by the scalar value scalar ( $ \vec{a}=\vec{b}*s $). More...
 
template<typename VT >
DisableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedAssign< VT > >::Type assign (const DenseVector< VT, TF > &rhs)
 Default implementation of the assignment of a dense vector. More...
 
template<typename VT >
EnableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedAssign< VT > >::Type assign (const DenseVector< VT, TF > &rhs)
 Intrinsic optimized implementation of the assignment of a dense vector. More...
 
template<typename VT >
DisableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedAddAssign< VT > >::Type addAssign (const DenseVector< VT, TF > &rhs)
 Default implementation of the addition assignment of a dense vector. More...
 
template<typename VT >
EnableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedAddAssign< VT > >::Type addAssign (const DenseVector< VT, TF > &rhs)
 Intrinsic optimized implementation of the addition assignment of a dense vector. More...
 
template<typename VT >
DisableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedSubAssign< VT > >::Type subAssign (const DenseVector< VT, TF > &rhs)
 Default implementation of the subtraction assignment of a dense vector. More...
 
template<typename VT >
EnableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedSubAssign< VT > >::Type subAssign (const DenseVector< VT, TF > &rhs)
 Intrinsic optimized implementation of the subtraction assignment of a dense vector. More...
 
template<typename VT >
DisableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedMultAssign< VT > >::Type multAssign (const DenseVector< VT, TF > &rhs)
 Default implementation of the multiplication assignment of a dense vector. More...
 
template<typename VT >
EnableIf< typename CustomVector< Type, AF, PF, TF >::BLAZE_TEMPLATE VectorizedMultAssign< VT > >::Type multAssign (const DenseVector< VT, TF > &rhs)
 Intrinsic optimized implementation of the multiplication assignment of a dense vector. More...
 
BLAZE_ALWAYS_INLINE VectorTypeoperator~ ()
 Conversion operator for non-constant vectors. More...
 
BLAZE_ALWAYS_INLINE const VectorTypeoperator~ () const
 Conversion operator for constant vectors. More...
 
Constructors
 CustomVector ()
 The default constructor for CustomVector.
 
 CustomVector (Type *ptr, size_t n)
 Constructor for an unpadded custom vector of size n. More...
 
 CustomVector (Type *ptr, size_t n, size_t nn)
 Constructor for a padded custom vector of size n and capacity nn. More...
 
template<typename Deleter >
 CustomVector (Type *ptr, size_t n, Deleter d)
 Constructor for an unpadded custom vector of size n. More...
 
template<typename Deleter >
 CustomVector (Type *ptr, size_t n, size_t nn, Deleter d)
 Constructor for a padded custom vector of size n and capacity nn. More...
 
 CustomVector (const CustomVector &v)
 The copy constructor for CustomVector. More...
 
Data access functions
Reference operator[] (size_t index)
 Subscript operator for the direct access to the vector elements. More...
 
ConstReference operator[] (size_t index) const
 Subscript operator for the direct access to the vector elements. More...
 
Reference at (size_t index)
 Checked access to the vector elements. More...
 
ConstReference at (size_t index) const
 Checked access to the vector elements. More...
 
Pointer data ()
 Low-level data access to the vector elements. More...
 
ConstPointer data () const
 Low-level data access to the vector elements. More...
 
Iterator begin ()
 Returns an iterator to the first element of the custom vector. More...
 
ConstIterator begin () const
 Returns an iterator to the first element of the custom vector. More...
 
ConstIterator cbegin () const
 Returns an iterator to the first element of the custom vector. More...
 
Iterator end ()
 Returns an iterator just past the last element of the custom vector. More...
 
ConstIterator end () const
 Returns an iterator just past the last element of the custom vector. More...
 
ConstIterator cend () const
 Returns an iterator just past the last element of the custom vector. More...
 
Assignment operators
template<typename Other , size_t N>
CustomVectoroperator= (const Other(&array)[N])
 
CustomVectoroperator= (const Type &rhs)
 Homogenous assignment to all vector elements. More...
 
CustomVectoroperator= (const CustomVector &rhs)
 Copy assignment operator for CustomVector. More...
 
template<typename VT >
CustomVectoroperator= (const Vector< VT, TF > &rhs)
 
template<typename VT >
CustomVectoroperator+= (const Vector< VT, TF > &rhs)
 
template<typename VT >
CustomVectoroperator-= (const Vector< VT, TF > &rhs)
 
template<typename VT >
CustomVectoroperator*= (const Vector< VT, TF > &rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >, CustomVector >::Type & operator*= (Other rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >, CustomVector >::Type & operator/= (Other rhs)
 
Utility functions
size_t size () const
 Returns the size/dimension of the vector. More...
 
size_t capacity () const
 Returns the maximum capacity of the vector. More...
 
size_t nonZeros () const
 Returns the number of non-zero elements in the vector. More...
 
void reset ()
 Reset to the default initial values. More...
 
void clear ()
 Clearing the vector to its default state. More...
 
template<typename Other >
CustomVectorscale (const Other &scalar)
 
void swap (CustomVector &v)
 Swapping the contents of two vectors. More...
 
Resource management functions
void reset (Type *ptr, size_t n)
 Resets the custom vector and replaces the array of elements with the given array. More...
 
void reset (Type *ptr, size_t n, size_t nn)
 Resets the custom vector and replaces the array of elements with the given array. More...
 
template<typename Deleter >
void reset (Type *ptr, size_t n, Deleter d)
 Resets the custom vector and replaces the array of elements with the given array. More...
 
template<typename Deleter >
void reset (Type *ptr, size_t n, size_t nn, Deleter d)
 Resets the custom vector and replaces the array of elements with the given array. More...
 
Expression template evaluation functions
template<typename Other >
bool canAlias (const Other *alias) const
 Returns whether the vector can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the vector is aliased with the given address alias. More...
 
bool isAligned () const
 Returns whether the vector is properly aligned in memory. More...
 
bool canSMPAssign () const
 Returns whether the vector can be used in SMP assignments. More...
 
BLAZE_ALWAYS_INLINE IntrinsicType load (size_t index) const
 Load of an intrinsic element of the vector. More...
 
BLAZE_ALWAYS_INLINE IntrinsicType loada (size_t index) const
 Aligned load of an intrinsic element of the vector. More...
 
BLAZE_ALWAYS_INLINE IntrinsicType loadu (size_t index) const
 Unaligned load of an intrinsic element of the vector. More...
 
BLAZE_ALWAYS_INLINE void store (size_t index, const IntrinsicType &value)
 Store of an intrinsic element of the vector. More...
 
BLAZE_ALWAYS_INLINE void storea (size_t index, const IntrinsicType &value)
 Aligned store of an intrinsic element of the vector. More...
 
BLAZE_ALWAYS_INLINE void storeu (size_t index, const IntrinsicType &value)
 Unaligned store of an intrinsic element of the dense vector. More...
 
BLAZE_ALWAYS_INLINE void stream (size_t index, const IntrinsicType &value)
 Aligned, non-temporal store of an intrinsic element of the dense vector. More...
 
template<typename VT >
DisableIf< VectorizedAssign< VT > >::Type assign (const DenseVector< VT, TF > &rhs)
 
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. More...
 
template<typename VT >
DisableIf< VectorizedAddAssign< VT > >::Type addAssign (const DenseVector< VT, TF > &rhs)
 
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. More...
 
template<typename VT >
DisableIf< VectorizedSubAssign< VT > >::Type subAssign (const DenseVector< VT, TF > &rhs)
 
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. More...
 
template<typename VT >
DisableIf< VectorizedMultAssign< VT > >::Type multAssign (const DenseVector< VT, TF > &rhs)
 
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. More...
 

Private Types

typedef IntrinsicTrait< Type > IT
 Intrinsic trait for the vector element type.
 

Private Attributes

Member variables
size_t size_
 The size/dimension of the custom vector.
 
boost::shared_array< Type > v_
 The custom array of elements. More...
 

Detailed Description

template<typename Type, bool AF, bool PF, bool TF = defaultTransposeFlag>
class blaze::CustomVector< Type, AF, PF, TF >

Efficient implementation of a customizable vector.

General

The CustomVector class template provides the functionality to represent an external array of elements of arbitrary type and a fixed size as a native Blaze dense vector data structure. Thus in contrast to all other dense vector types a custom vector does not perform any kind of memory allocation by itself, but it is provided with an existing array of element during construction. A custom vector can therefore be considered an alias to the existing array.

The type of the elements, the properties of the given array of elements and the transpose flag of the vector can be specified via the following four template parameters:

template< typename Type, bool AF, bool PF, bool TF >

The following examples give an impression of several possible types of custom vectors:

// Definition of a custom column vector for unaligned, unpadded integer arrays
typedef CustomVector<int,unaligned,unpadded,columnVector> UnalignedUnpadded;
// Definition of a custom column vector for unaligned but padded 'float' arrays
typedef CustomVector<float,unaligned,padded,columnVector> UnalignedPadded;
// Definition of a custom row vector for aligned, unpadded 'double' arrays
typedef CustomVector<double,aligned,unpadded,rowVector> AlignedUnpadded;
// Definition of a custom row vector for aligned, padded 'complex<double>' arrays
typedef CustomVector<complex<double>,aligned,padded,rowVector> AlignedPadded;


Special Properties of Custom Vectors

In comparison with the remaining Blaze dense vector types CustomVector has several special characteristics. All of these result from the fact that a custom vector is not performing any kind of memory allocation, but instead is given an existing array of elements. The following sections discuss all of these characteristics:

  1. Memory Management
  2. Copy Operations
  3. Alignment
  4. Padding


Memory Management

The CustomVector class template acts as an adaptor for an existing array of elements. As such it provides everything that is required to use the array just like a native Blaze dense vector data structure. However, this flexibility comes with the price that the user of a custom vector is responsible for the resource management.

When constructing a custom vector there are two choices: Either a user manually manages the array of elements outside the custom vector, or alternatively passes the responsibility for the memory management to an instance of CustomVector. In the second case the CustomVector class employs shared ownership between all copies of the custom vector, which reference the same array.

The following examples give an impression of several possible types of custom vectors:

// Definition of a 3-dimensional custom vector with unaligned, unpadded and externally
// managed integer array. Note that the std::vector must be guaranteed to outlive the
// custom vector!
std::vector<int> vec( 3UL );
CustomVector<int,unaligned,unpadded> a( &vec[0], 3UL );
// Definition of a custom row vector with size 3 for unaligned, unpadded integer arrays.
// The responsibility for the memory management is passed to the custom vector by
// providing a deleter of type 'blaze::ArrayDelete' that is used during the destruction
// of the custom vector.
CustomVector<int,unaligned,unpadded,rowVector> b( new int[3], 3UL, ArrayDelete() );
// Definition of a custom vector with size 3 and capacity 16 with aligned and padded
// integer array. The memory management is passed to the custom vector by providing a
// deleter of type 'blaze::Deallocate'.
CustomVector<int,aligned,padded> c( allocate<int>( 16UL ), 3UL, 16UL, Deallocate() );

It is possible to pass any type of deleter to the constructor. The deleter is only required to provide a function call operator that can be passed the pointer to the managed array. As an example the following code snipped shows the implementation of two native Blaze deleters blaze::ArrayDelete and blaze::Deallocate:

namespace blaze {
struct ArrayDelete
{
template< typename Type >
inline void operator()( Type ptr ) const { boost::checked_array_delete( ptr ); }
};
struct Deallocate
{
template< typename Type >
inline void operator()( Type ptr ) const { deallocate( ptr ); }
};
} // namespace blaze


Copy Operations

As with all dense vectors it is possible to copy construct a custom vector:

typedef CustomVector<int,unaligned,unpadded> CustomType;
std::vector<int> vec( 5UL, 10 ); // Vector of 5 integers of the value 10
CustomType a( &vec[0], 5UL ); // Represent the std::vector as Blaze dense vector
a[1] = 20; // Also modifies the std::vector
CustomType b( a ); // Creating a copy of vector a
b[2] = 20; // Also affect vector a and the std::vector

It is important to note that a custom vector acts as a reference to the specified array. Thus the result of the copy constructor is a new custom vector that is referencing and representing the same array as the original custom vector. In case a deleter has been provided to the first custom vector, both vectors share the responsibility to destroy the array when the last vector goes out of scope.

In contrast to copy construction, just as with references, copy assignment does not change which array is referenced by the custom vector, but modifies the values of the array:

std::vector<int> vec2( 5UL, 4 ); // Vector of 5 integers of the value 4
CustomType c( &vec2[0], 5UL ); // Represent the std::vector as Blaze dense vector
a = c; // Copy assignment: Set all values of vector a and b to 4.


Alignment

In case the custom vector is specified as aligned the passed array must be guaranteed to be aligned according to the requirements of the used instruction set (SSE, AVX, ...). For instance, if AVX is active an array of integers must be 32-bit aligned:

int* array = blaze::allocate<int>( 5UL ); // Needs to be 32-bit aligned
CustomVector<int,aligned,unpadded> a( array, 5UL, Deallocate() );

In case the alignment requirements are violated, a std::invalid_argument exception is thrown.


Padding

Adding padding elements to the end of an array can have a significant impact on performance. For instance, assuming that AVX is available, then two aligned, padded, 3-dimensional vectors of double precision values can be added via a single intrinsic addition instruction:

typedef CustomVector<double,aligned,padded> CustomType;
// Creating padded custom vectors of size 3 and a capacity of 4
CustomType a( allocate<double>( 4UL ), 3UL, 4UL, Deallocate() );
CustomType b( allocate<double>( 4UL ), 3UL, 4UL, Deallocate() );
CustomType c( allocate<double>( 4UL ), 3UL, 4UL, Deallocate() );
// ... Initialization
c = a + b; // AVX-based vector addition

In this example, maximum performance is possible. However, in case no padding elements are inserted, a scalar addition has to be used:

typedef CustomVector<double,aligned,unpadded> CustomType;
// Creating unpadded custom vector of size 3
CustomType a( allocate<double>( 3UL ), 3UL, Deallocate() );
CustomType b( allocate<double>( 3UL ), 3UL, Deallocate() );
CustomType c( allocate<double>( 3UL ), 3UL, Deallocate() );
// ... Initialization
c = a + b; // Scalar vector addition

Note the different number of constructor parameters for unpadded and padded custom vectors: In contrast to unpadded vectors, where during the construction only the size of the array has to be specified, during the construction of a padded custom vector it is additionally necessary to explicitly specify the capacity of the array.

The number of padding elements is required to be sufficient with respect to the available instruction set: In case of an aligned padded custom vector the added padding elements must guarantee that the capacity is greater or equal than the size and a multiple of the intrinsic vector width. In case of unaligned padded vectors the number of padding elements can be greater or equal the number of padding elements of an aligned padded custom vector. In case the padding is insufficient with respect to the available instruction set, a std::invalid_argument exception is thrown.

Please also note that Blaze will zero initialize the padding elements in order to achieve maximum performance!


Arithmetic Operations

The use of custom vectors in arithmetic operations is designed to be as natural and intuitive as possible. All operations (addition, subtraction, multiplication, scaling, ...) can be expressed similar to a text book representation. Also, custom vectors can be combined with all other dense and sparse vectors and matrices. The following example gives an impression of the use of CustomVector:

// Non-initialized custom column vector of size 2. All given arrays are considered to be
// unaligned and unpadded. The memory is managed via 'ArrayDelete'.
CustomVector<double,unaligned,unpadded> a( new double[2], 2UL, ArrayDelete() );
a[0] = 1.0; // Initialization of the first element
a[1] = 2.0; // Initialization of the second element
// Non-initialized custom column vector of size 2 and capacity 4. All given arrays are required
// to be properly aligned and padded. The memory is managed via 'Deallocate'.
CustomVector<double,aligned,padded> b( allocate<double>( 4UL ), 2UL, 4UL, Deallocate() );
b = 2.0; // Homogeneous initialization of all elements
CompressedVector<float> c( 2 ); // Empty sparse single precision vector
DynamicVector<double> d; // Default constructed dynamic vector
DynamicMatrix<double> A; // Default constructed row-major matrix
d = a + b; // Vector addition between custom vectors of equal element type
d = a - c; // Vector subtraction between a dense and sparse vector with different element types
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 Enumeration Documentation

template<typename Type, bool AF, bool PF, 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 an intrinsic data type, the vectorizable compilation flag is set to true, otherwise it is set to false.

template<typename Type, bool AF, bool PF, bool TF = defaultTransposeFlag>
anonymous enum

Compilation flag for SMP assignments.

The smpAssignable compilation flag indicates whether the vector can be used in SMP (shared memory parallel) assignments (both on the left-hand and right-hand side of the assignment).

Constructor & Destructor Documentation

template<typename Type , bool AF, bool PF, bool TF>
blaze::CustomVector< Type, AF, PF, TF >::CustomVector ( Type *  ptr,
size_t  n 
)
inlineexplicit

Constructor for an unpadded custom vector of size n.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This constructor creates an unpadded custom vector of size n. The construction fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...).

In all failure cases a std::invalid_argument exception is thrown.

Note
This constructor is NOT available for padded custom vectors!
The custom vector does NOT take responsibility for the given array of elements!
template<typename Type , bool AF, bool PF, bool TF>
blaze::CustomVector< Type, AF, PF, TF >::CustomVector ( Type *  ptr,
size_t  n,
size_t  nn 
)
inlineexplicit

Constructor for a padded custom vector of size n and capacity nn.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
nnThe maximum size of the given array.
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This constructor creates a padded custom vector of size n and capacity nn. The construction fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...);
  • ... the specified capacity nn is insufficient for the given data type Type and the available instruction set.

In all failure cases a std::invalid_argument exception is thrown.

Note
This constructor is NOT available for unpadded custom vectors!
The custom vector does NOT take responsibility for the given array of elements!
template<typename Type , bool AF, bool PF, bool TF>
template<typename Deleter >
blaze::CustomVector< Type, AF, PF, TF >::CustomVector ( Type *  ptr,
size_t  n,
Deleter  d 
)
inlineexplicit

Constructor for an unpadded custom vector of size n.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
dThe deleter to destroy the array of elements.
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This constructor creates an unpadded custom vector of size n. The construction fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...).

In all failure cases a std::invalid_argument exception is thrown.

Note
This constructor is NOT available for padded custom vectors!
template<typename Type , bool AF, bool PF, bool TF>
template<typename Deleter >
blaze::CustomVector< Type, AF, PF, TF >::CustomVector ( Type *  ptr,
size_t  n,
size_t  nn,
Deleter  d 
)
inlineexplicit

Constructor for a padded custom vector of size n and capacity nn.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
nnThe maximum size of the given array.
dThe deleter to destroy the array of elements.
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This constructor creates a padded custom vector of size n and capacity nn. The construction fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...);
  • ... the specified capacity nn is insufficient for the given data type Type and the available instruction set.

In all failure cases a std::invalid_argument exception is thrown.

Note
This constructor is NOT available for unpadded custom vectors!
template<typename Type , bool AF, bool PF, bool TF>
blaze::CustomVector< Type, AF, PF, TF >::CustomVector ( const CustomVector< Type, AF, PF, TF > &  v)
inline

The copy constructor for CustomVector.

Parameters
vVector to be copied.

The copy constructor initializes the custom vector as an exact copy of the given custom vector.

Member Function Documentation

template<typename Type , bool AF, bool PF, bool TF>
template<typename VT >
void blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
DisableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::addAssign ( const DenseVector< VT, TF > &  rhs)
inline

Default 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
EnableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::addAssign ( const DenseVector< VT, TF > &  rhs)
inline

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 , bool AF, bool PF, bool TF>
template<typename VT >
void blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
DisableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::assign ( const DenseVector< VT, TF > &  rhs)
inline

Default 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
EnableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::assign ( const DenseVector< VT, TF > &  rhs)
inline

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 , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::Reference blaze::CustomVector< Type, AF, PF, TF >::at ( size_t  index)
inline

Checked 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.
Exceptions
std::out_of_rangeInvalid vector access index.

In contrast to the subscript operator this function always performs a check of the given access index.

template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::ConstReference blaze::CustomVector< Type, AF, PF, TF >::at ( size_t  index) const
inline

Checked 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.
Exceptions
std::out_of_rangeInvalid vector access index.

In contrast to the subscript operator this function always performs a check of the given access index.

template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::Iterator blaze::CustomVector< Type, AF, PF, TF >::begin ( )
inline

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

Returns
Iterator to the first element of the custom vector.
template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::ConstIterator blaze::CustomVector< Type, AF, PF, TF >::begin ( ) const
inline

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

Returns
Iterator to the first element of the custom vector.
template<typename Type , bool AF, bool PF, bool TF>
template<typename Other >
bool blaze::CustomVector< Type, AF, PF, TF >::canAlias ( const Other *  alias) const
inline

Returns whether the vector can alias with the given address alias.

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this vector, false if not.

This function returns whether the given address can alias with the vector. In contrast to the isAliased() function this function is allowed to use compile time expressions to optimize the evaluation.

template<typename Type , bool AF, bool PF, bool TF>
bool blaze::CustomVector< Type, AF, PF, TF >::canSMPAssign ( ) const
inline

Returns whether the vector can be used in SMP assignments.

Returns
true in case the vector can be used in SMP assignments, false if not.

This function returns whether the vector can be used in SMP assignments. In contrast to the smpAssignable member enumeration, which is based solely on compile time information, this function additionally provides runtime information (as for instance the current size of the vector).

template<typename Type , bool AF, bool PF, bool TF>
size_t blaze::CustomVector< Type, AF, PF, TF >::capacity ( ) const
inline

Returns the maximum capacity of the vector.

Returns
The capacity of the vector.
template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::ConstIterator blaze::CustomVector< Type, AF, PF, TF >::cbegin ( ) const
inline

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

Returns
Iterator to the first element of the custom vector.
template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::ConstIterator blaze::CustomVector< Type, AF, PF, TF >::cend ( ) const
inline

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

Returns
Iterator just past the last element of the custom vector.
template<typename Type , bool AF, bool PF, bool TF>
void blaze::CustomVector< Type, AF, PF, TF >::clear ( )
inline

Clearing the vector to its default state.

Returns
void

This function clears the vector to its default state. In case the vector has been passed the responsibility to manage the given array, it disposes the resource via the specified deleter.

template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::Pointer blaze::CustomVector< Type, AF, PF, TF >::data ( )
inline

Low-level data access to the vector elements.

Returns
Pointer to the internal element storage.

This function returns a pointer to the internal storage of the custom vector.

template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::ConstPointer blaze::CustomVector< Type, AF, PF, TF >::data ( ) const
inline

Low-level data access to the vector elements.

Returns
Pointer to the internal element storage.

This function returns a pointer to the internal storage of the custom vector.

template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::Iterator blaze::CustomVector< Type, AF, PF, TF >::end ( )
inline

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

Returns
Iterator just past the last element of the custom vector.
template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::ConstIterator blaze::CustomVector< Type, AF, PF, TF >::end ( ) const
inline

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

Returns
Iterator just past the last element of the custom vector.
template<typename Type , bool AF, bool PF, bool TF>
template<typename Other >
bool blaze::CustomVector< Type, AF, PF, 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.

This function returns whether the given address is aliased with the vector. In contrast to the canAlias() function this function is not allowed to use compile time expressions to optimize the evaluation.

template<typename Type , bool AF, bool PF, bool TF>
bool blaze::CustomVector< Type, AF, PF, TF >::isAligned ( ) const
inline

Returns whether the vector is properly aligned in memory.

Returns
true in case the vector is aligned, false if not.

This function returns whether the vector is guaranteed to be properly aligned in memory, i.e. whether the beginning and the end of the vector are guaranteed to conform to the alignment restrictions of the element type Type.

template<typename Type , bool AF, bool PF, bool TF>
BLAZE_ALWAYS_INLINE CustomVector< Type, AF, PF, TF >::IntrinsicType blaze::CustomVector< Type, AF, PF, TF >::load ( size_t  index) const

Load of an intrinsic element of the vector.

Parameters
indexAccess index. The index must be smaller than the number of vector elements.
Returns
The loaded intrinsic element.

This function performs a load of a specific intrinsic element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the intrinsic element. 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.

template<typename Type , bool AF, bool PF, bool TF>
BLAZE_ALWAYS_INLINE CustomVector< Type, AF, PF, TF >::IntrinsicType blaze::CustomVector< Type, AF, PF, TF >::loada ( size_t  index) const

Aligned load of an intrinsic element of the vector.

Parameters
indexAccess index. The index must be smaller than the number of vector elements.
Returns
The loaded intrinsic element.

This function performs an aligned load of a specific intrinsic element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the intrinsic element. 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.

template<typename Type , bool AF, bool PF, bool TF>
BLAZE_ALWAYS_INLINE CustomVector< Type, AF, PF, TF >::IntrinsicType blaze::CustomVector< Type, AF, PF, TF >::loadu ( size_t  index) const

Unaligned load of an intrinsic element of the vector.

Parameters
indexAccess index. The index must be smaller than the number of vector elements.
Returns
The loaded intrinsic element.

This function performs an unaligned load of a specific intrinsic element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the intrinsic element. 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.

template<typename Type , bool AF, bool PF, bool TF>
template<typename VT >
void blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
DisableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::multAssign ( const DenseVector< VT, TF > &  rhs)
inline

Default 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
EnableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::multAssign ( const DenseVector< VT, TF > &  rhs)
inline

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 , bool AF, bool PF, bool TF>
size_t blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
CustomVector<Type,AF,PF,TF>& blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename Other >
EnableIf< IsNumeric<Other>, CustomVector<Type,AF,PF,TF> >::Type& blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
CustomVector<Type,AF,PF,TF>& blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
CustomVector<Type,AF,PF,TF>& blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename Other >
EnableIf< IsNumeric<Other>, CustomVector<Type,AF,PF,TF> >::Type& blaze::CustomVector< Type, AF, PF, 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 , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF > & blaze::CustomVector< Type, AF, PF, TF >::operator= ( const 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 , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF > & blaze::CustomVector< Type, AF, PF, TF >::operator= ( const CustomVector< Type, AF, PF, TF > &  rhs)
inline

Copy assignment operator for CustomVector.

Parameters
rhsVector to be copied.
Returns
Reference to the assigned vector.
Exceptions
std::invalid_argumentVector sizes do not match.

The vector is initialized as a copy of the given vector. In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.

template<typename Type, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename Other , size_t N>
CustomVector<Type,AF,PF,TF>& blaze::CustomVector< Type, AF, PF, TF >::operator= ( const Other(&)  array[N])
inline

Array assignment to all vector elements.

Parameters
arrayN-dimensional array for the assignment.
Returns
Reference to the assigned vector.
Exceptions
std::invalid_argumentInvalid array size.

This assignment operator offers the option to directly set all elements of the vector. The following example demonstrates this by means of an unaligned, unpadded custom vector:

using blaze::unaliged;
const int array[4] = { 1, 2, 3, 4 };
const int init[4] = { 5, 6, 7 };
CustomVector<double,unaligned,unpadded> v( array, 4UL );
v = init;

The vector is assigned the values from the given array. Missing values are initialized with default values (as e.g. the fourth element in the example). Note that the size of the array must match the size of the custom vector. Otherwise a std::invalid_argument exception is thrown. Also note that after the assignment array will have the same entries as init.

template<typename Type, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
CustomVector<Type,AF,PF,TF>& blaze::CustomVector< Type, AF, PF, 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_argumentVector sizes do not match.

The vector is initialized as a copy of the given vector. In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.

template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::Reference blaze::CustomVector< Type, AF, PF, 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.

This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access index.

template<typename Type , bool AF, bool PF, bool TF>
CustomVector< Type, AF, PF, TF >::ConstReference blaze::CustomVector< Type, AF, PF, 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 the accessed value.

This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access index.

template<typename VT, bool TF>
BLAZE_ALWAYS_INLINE 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>
BLAZE_ALWAYS_INLINE 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 , bool AF, bool PF, bool TF>
void blaze::CustomVector< Type, AF, PF, TF >::reset ( )
inline

Reset to the default initial values.

Returns
void
template<typename Type , bool AF, bool PF, bool TF>
void blaze::CustomVector< Type, AF, PF, TF >::reset ( Type *  ptr,
size_t  n 
)
inline

Resets the custom vector and replaces the array of elements with the given array.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
Returns
void
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This function resets the custom vector to the given array of elements of size n. The function fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...).

In all failure cases a std::invalid_argument exception is thrown.

Note
This function is NOT available for padded custom vectors!
In case a deleter was specified, the previously referenced array will only be destroyed when the last custom vector referencing the array goes out of scope.
The custom vector does NOT take responsibility for the new array of elements!
template<typename Type , bool AF, bool PF, bool TF>
void blaze::CustomVector< Type, AF, PF, TF >::reset ( Type *  ptr,
size_t  n,
size_t  nn 
)
inline

Resets the custom vector and replaces the array of elements with the given array.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
nnThe maximum size of the given array.
Returns
void
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This function resets the custom vector to the given array of elements of size n and capacity nn. The function fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...);
  • ... the specified capacity nn is insufficient for the given data type Type and the available instruction set.

In all failure cases a std::invalid_argument exception is thrown.

Note
This function is NOT available for unpadded custom vectors!
In case a deleter was specified, the previously referenced array will only be destroyed when the last custom vector referencing the array goes out of scope.
The custom vector does NOT take responsibility for the new array of elements!
template<typename Type , bool AF, bool PF, bool TF>
template<typename Deleter >
void blaze::CustomVector< Type, AF, PF, TF >::reset ( Type *  ptr,
size_t  n,
Deleter  d 
)
inline

Resets the custom vector and replaces the array of elements with the given array.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
dThe deleter to destroy the array of elements.
Returns
void
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This function resets the custom vector to the given array of elements of size n. The function fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...).

In all failure cases a std::invalid_argument exception is thrown.

Note
This function is NOT available for padded custom vectors!
In case a deleter was specified, the previously referenced array will only be destroyed when the last custom vector referencing the array goes out of scope.
template<typename Type , bool AF, bool PF, bool TF>
template<typename Deleter >
void blaze::CustomVector< Type, AF, PF, TF >::reset ( Type *  ptr,
size_t  n,
size_t  nn,
Deleter  d 
)
inline

Resets the custom vector and replaces the array of elements with the given array.

Parameters
ptrThe array of elements to be used by the vector.
nThe number of array elements to be used by the custom vector.
nnThe maximum size of the given array.
dThe deleter to destroy the array of elements.
Returns
void
Exceptions
std::invalid_argumentInvalid setup of custom vector.

This function resets the custom vector to the given array of elements of size n and capacity nn. The function fails if ...

  • ... the passed pointer is NULL;
  • ... the alignment flag AF is set to aligned, but the passed pointer is not properly aligned according to the available instruction set (SSE, AVX, ...);
  • ... the specified capacity nn is insufficient for the given data type Type and the available instruction set.

In all failure cases a std::invalid_argument exception is thrown.

Note
This function is NOT available for unpadded custom vectors!
In case a deleter was specified, the previously referenced array will only be destroyed when the last custom vector referencing the array goes out of scope.
template<typename Type, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename Other >
CustomVector<Type,AF,PF,TF>& blaze::CustomVector< Type, AF, PF, TF >::scale ( const Other &  scalar)
inline

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

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

Returns the size/dimension of the vector.

Returns
The size of the vector.
template<typename Type , bool AF, bool PF, bool TF>
BLAZE_ALWAYS_INLINE void blaze::CustomVector< Type, AF, PF, TF >::store ( size_t  index,
const IntrinsicType value 
)

Store of an intrinsic element of the vector.

Parameters
indexAccess index. The index must be smaller than the number of vector elements.
valueThe intrinsic element to be stored.
Returns
void

This function performs a store of a specific intrinsic element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the intrinsic element. 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.

template<typename Type , bool AF, bool PF, bool TF>
BLAZE_ALWAYS_INLINE void blaze::CustomVector< Type, AF, PF, TF >::storea ( size_t  index,
const IntrinsicType value 
)

Aligned store of an intrinsic element of the vector.

Parameters
indexAccess index. The index must be smaller than the number of vector elements.
valueThe intrinsic element to be stored.
Returns
void

This function performs an aligned store of a specific intrinsic element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the intrinsic element. 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.

template<typename Type , bool AF, bool PF, bool TF>
BLAZE_ALWAYS_INLINE void blaze::CustomVector< Type, AF, PF, TF >::storeu ( size_t  index,
const IntrinsicType value 
)

Unaligned store of an intrinsic element of the dense vector.

Parameters
indexAccess index. The index must be smaller than the number of vector elements.
valueThe intrinsic element to be stored.
Returns
void

This function performs an unaligned store of a specific intrinsic element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the intrinsic element. 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.

template<typename Type , bool AF, bool PF, bool TF>
BLAZE_ALWAYS_INLINE void blaze::CustomVector< Type, AF, PF, TF >::stream ( size_t  index,
const IntrinsicType value 
)

Aligned, non-temporal store of an intrinsic element of the dense vector.

Parameters
indexAccess index. The index must be smaller than the number of vector elements.
valueThe intrinsic element to be stored.
Returns
void

This function performs an aligned, non-temporal store of a specific intrinsic element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the intrinsic element. 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.

template<typename Type , bool AF, bool PF, bool TF>
template<typename VT >
void blaze::CustomVector< Type, AF, PF, 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
DisableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::subAssign ( const DenseVector< VT, TF > &  rhs)
inline

Default 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, bool AF, bool PF, bool TF = defaultTransposeFlag>
template<typename VT >
EnableIf< typename CustomVector<Type,AF,PF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type blaze::CustomVector< Type, AF, PF, TF >::subAssign ( const DenseVector< VT, TF > &  rhs)
inline

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 , bool AF, bool PF, bool TF>
void blaze::CustomVector< Type, AF, PF, TF >::swap ( CustomVector< Type, AF, PF, TF > &  v)
inline

Swapping the contents of two vectors.

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

Member Data Documentation

template<typename Type, bool AF, bool PF, bool TF = defaultTransposeFlag>
boost::shared_array<Type> blaze::CustomVector< Type, AF, PF, TF >::v_
private

The custom array of elements.

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

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


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