shark::blas::vector< T > Class Template Reference

A dense vector of values of type T. More...

#include <shark/LinAlg/BLAS/vector.hpp>

+ Inheritance diagram for shark::blas::vector< T >:

Public Types

typedef array_type::const_reference const_reference
 
typedef array_type::reference reference
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef index_type const * const_index_pointer
 
typedef index_type index_pointer
 
typedef dense_tag storage_category
 
typedef elementwise_tag evaluation_category
 
typedef dense_storage_iterator< value_type > iterator
 
typedef dense_storage_iterator< value_type const > const_iterator
 

Public Member Functions

 vector ()
 Constructor of a vector By default it is empty, i.e. size()==0. More...
 
 vector (size_type size)
 Constructor of a vector with a predefined size By default, its elements are initialized to 0. More...
 
template<class Iter >
 vector (Iter begin, Iter end)
 Constructs the vector from a predefined range. More...
 
 vector (const array_type &data)
 Constructor of a vector by copying from another container This type has the generic name array_typ within the vector definition. More...
 
 vector (size_type size, const value_type &init)
 Constructor of a vector with a predefined size and a unique initial value. More...
 
 vector (vector const &v)
 Copy-constructor of a vector. More...
 
template<class E >
 vector (vector_expression< E > const &e)
 Copy-constructor of a vector from a vector_expression Depending on the vector_expression, this constructor can have the cost of the computations of the expression (trivial to say it, but it is to take into account in your complexity calculations). More...
 
size_type size () const
 Return the size of the vector. More...
 
pointer storage ()
 Returns the pointer to the beginning of the vector storage. More...
 
const_pointer storage () const
 Returns the pointer to the beginning of the vector storage. More...
 
difference_type stride () const
 Returns the stride between the elements in storage() More...
 
size_type max_size () const
 Return the maximum size of the data container. Return the upper bound (maximum size) on the data container. Depending on the container, it can be bigger than the current size of the vector. More...
 
bool empty () const
 Return true if the vector is empty (size==0) More...
 
void resize (size_type size)
 Resize the vector. More...
 
const_reference operator() (index_type i) const
 Return a const reference to the element \(i\) Return a const reference to the element \(i\). With some compilers, this notation will be faster than operator[]. More...
 
reference operator() (index_type i)
 Return a reference to the element \(i\) Return a reference to the element \(i\). With some compilers, this notation will be faster than operator[]. More...
 
const_reference operator[] (index_type i) const
 Return a const reference to the element \(i\). More...
 
reference operator[] (index_type i)
 Return a reference to the element \(i\). More...
 
reference front ()
 Returns the first element of the vector. More...
 
const_reference front () const
 Returns the first element of the vector. More...
 
reference back ()
 Returns the last element of the vector. More...
 
const_reference back () const
 Returns the last element of the vector. More...
 
void push_back (value_type const &element)
 resizes the vector by appending a new element to the end. this invalidates storage More...
 
void clear ()
 Clear the vector, i.e. set all values to the zero value. More...
 
vectoroperator= (vector const &v)
 Assign a full vector (RHS-vector) to the current vector (LHS-vector) Assign a full vector (RHS-vector) to the current vector (LHS-vector). This method does not create any temporary. More...
 
template<class C >
vectoroperator= (vector_container< C > const &v)
 Assign a full vector (RHS-vector) to the current vector (LHS-vector) Assign a full vector (RHS-vector) to the current vector (LHS-vector). This method does not create any temporary. More...
 
template<class E >
vectoroperator= (vector_expression< E > const &e)
 Assign the result of a vector_expression to the vector Assign the result of a vector_expression to the vector. More...
 
const_iterator cbegin () const
 return an iterator on the first element of the vector More...
 
const_iterator cend () const
 return an iterator after the last element of the vector More...
 
const_iterator begin () const
 return an iterator on the first element of the vector More...
 
const_iterator end () const
 return an iterator after the last element of the vector More...
 
iterator begin ()
 Return an iterator on the first element of the vector. More...
 
iterator end ()
 Return an iterator at the end of the vector. More...
 
iterator set_element (iterator pos, index_type index, value_type value)
 
iterator clear_element (iterator pos)
 
iterator clear_range (iterator start, iterator end)
 
void reserve (size_type)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int file_version)
 
- Public Member Functions inherited from shark::blas::vector_container< vector< T > >
const container_type & operator() () const
 
container_type & operator() ()
 
- Public Member Functions inherited from shark::blas::vector_expression< E >
const expression_type & operator() () const
 
expression_type & operator() ()
 

Friends

void swap (vector &v1, vector &v2)
 Swap the content of two vectors. More...
 

Detailed Description

template<class T>
class shark::blas::vector< T >

A dense vector of values of type T.

For a \(n\)-dimensional vector \(v\) and \(0\leq i < n\) every element \(v_i\) is mapped to the \(i\)-th element of the container. A storage type A can be specified which defaults to unbounded_array. Elements are constructed by A, which need not initialise their value.

Template Parameters
Ttype of the objects stored in the vector (like int, double, complex,...)
AThe type of the storage array of the vector. Default is unbounded_array<T>. <bounded_array<T> and std::vector<T> can also be used

Definition at line 50 of file vector.hpp.

Member Typedef Documentation

§ const_index_pointer

template<class T>
typedef index_type const* shark::blas::vector< T >::const_index_pointer

Definition at line 67 of file vector.hpp.

§ const_iterator

template<class T>
typedef dense_storage_iterator<value_type const> shark::blas::vector< T >::const_iterator

Definition at line 262 of file vector.hpp.

§ const_pointer

template<class T>
typedef const T* shark::blas::vector< T >::const_pointer

Definition at line 64 of file vector.hpp.

§ const_reference

template<class T>
typedef array_type::const_reference shark::blas::vector< T >::const_reference

Definition at line 61 of file vector.hpp.

§ evaluation_category

template<class T>
typedef elementwise_tag shark::blas::vector< T >::evaluation_category

Definition at line 74 of file vector.hpp.

§ index_pointer

template<class T>
typedef index_type shark::blas::vector< T >::index_pointer

Definition at line 68 of file vector.hpp.

§ iterator

template<class T>
typedef dense_storage_iterator<value_type> shark::blas::vector< T >::iterator

Definition at line 261 of file vector.hpp.

§ pointer

template<class T>
typedef T* shark::blas::vector< T >::pointer

Definition at line 63 of file vector.hpp.

§ reference

template<class T>
typedef array_type::reference shark::blas::vector< T >::reference

Definition at line 62 of file vector.hpp.

§ storage_category

template<class T>
typedef dense_tag shark::blas::vector< T >::storage_category

Definition at line 73 of file vector.hpp.

Constructor & Destructor Documentation

§ vector() [1/7]

template<class T>
shark::blas::vector< T >::vector ( )
inline

Constructor of a vector By default it is empty, i.e. size()==0.

Definition at line 80 of file vector.hpp.

§ vector() [2/7]

template<class T>
shark::blas::vector< T >::vector ( size_type  size)
inlineexplicit

Constructor of a vector with a predefined size By default, its elements are initialized to 0.

Parameters
sizeinitial size of the vector

Definition at line 85 of file vector.hpp.

§ vector() [3/7]

template<class T>
template<class Iter >
shark::blas::vector< T >::vector ( Iter  begin,
Iter  end 
)
inline

Constructs the vector from a predefined range.

Definition at line 89 of file vector.hpp.

§ vector() [4/7]

template<class T>
shark::blas::vector< T >::vector ( const array_type &  data)
inline

Constructor of a vector by copying from another container This type has the generic name array_typ within the vector definition.

Parameters
datacontainer of type A

Definition at line 94 of file vector.hpp.

§ vector() [5/7]

template<class T>
shark::blas::vector< T >::vector ( size_type  size,
const value_type &  init 
)
inline

Constructor of a vector with a predefined size and a unique initial value.

Parameters
sizeof the vector
initvalue to assign to each element of the vector

Definition at line 99 of file vector.hpp.

§ vector() [6/7]

template<class T>
shark::blas::vector< T >::vector ( vector< T > const &  v)
inline

Copy-constructor of a vector.

Parameters
vis the vector to be duplicated

Definition at line 103 of file vector.hpp.

§ vector() [7/7]

template<class T>
template<class E >
shark::blas::vector< T >::vector ( vector_expression< E > const &  e)
inline

Copy-constructor of a vector from a vector_expression Depending on the vector_expression, this constructor can have the cost of the computations of the expression (trivial to say it, but it is to take into account in your complexity calculations).

Parameters
ethe vector_expression which values will be duplicated into the vector

Definition at line 110 of file vector.hpp.

Member Function Documentation

§ back() [1/2]

template<class T>
reference shark::blas::vector< T >::back ( )
inline

Returns the last element of the vector.

Definition at line 208 of file vector.hpp.

§ back() [2/2]

template<class T>
const_reference shark::blas::vector< T >::back ( ) const
inline

Returns the last element of the vector.

Definition at line 212 of file vector.hpp.

§ begin() [1/2]

template<class T>
const_iterator shark::blas::vector< T >::begin ( ) const
inline

return an iterator on the first element of the vector

Definition at line 275 of file vector.hpp.

§ begin() [2/2]

template<class T>
iterator shark::blas::vector< T >::begin ( )
inline

Return an iterator on the first element of the vector.

Definition at line 285 of file vector.hpp.

§ cbegin()

template<class T>
const_iterator shark::blas::vector< T >::cbegin ( ) const
inline

return an iterator on the first element of the vector

Definition at line 265 of file vector.hpp.

Referenced by shark::blas::vector< std::size_t >::begin().

§ cend()

template<class T>
const_iterator shark::blas::vector< T >::cend ( ) const
inline

return an iterator after the last element of the vector

Definition at line 270 of file vector.hpp.

Referenced by shark::blas::vector< std::size_t >::end().

§ clear()

template<class T>
void shark::blas::vector< T >::clear ( )
inline

Clear the vector, i.e. set all values to the zero value.

Definition at line 222 of file vector.hpp.

§ clear_element()

template<class T>
iterator shark::blas::vector< T >::clear_element ( iterator  pos)
inline

Definition at line 302 of file vector.hpp.

§ clear_range()

template<class T>
iterator shark::blas::vector< T >::clear_range ( iterator  start,
iterator  end 
)
inline

Definition at line 310 of file vector.hpp.

§ empty()

template<class T>
bool shark::blas::vector< T >::empty ( ) const
inline

Return true if the vector is empty (size==0)

Returns
true if empty, false otherwise

Definition at line 159 of file vector.hpp.

Referenced by shark::blas::vector< std::size_t >::serialize().

§ end() [1/2]

template<class T>
const_iterator shark::blas::vector< T >::end ( ) const
inline

return an iterator after the last element of the vector

Definition at line 280 of file vector.hpp.

Referenced by shark::blas::vector< std::size_t >::clear_element(), and shark::blas::vector< std::size_t >::clear_range().

§ end() [2/2]

template<class T>
iterator shark::blas::vector< T >::end ( )
inline

Return an iterator at the end of the vector.

Definition at line 290 of file vector.hpp.

§ front() [1/2]

template<class T>
reference shark::blas::vector< T >::front ( )
inline

Returns the first element of the vector.

Definition at line 200 of file vector.hpp.

§ front() [2/2]

template<class T>
const_reference shark::blas::vector< T >::front ( ) const
inline

Returns the first element of the vector.

Definition at line 204 of file vector.hpp.

§ max_size()

template<class T>
size_type shark::blas::vector< T >::max_size ( ) const
inline

Return the maximum size of the data container. Return the upper bound (maximum size) on the data container. Depending on the container, it can be bigger than the current size of the vector.

Definition at line 153 of file vector.hpp.

§ operator()() [1/2]

template<class T>
const_reference shark::blas::vector< T >::operator() ( index_type  i) const
inline

Return a const reference to the element \(i\) Return a const reference to the element \(i\). With some compilers, this notation will be faster than operator[].

Parameters
iindex of the element

Definition at line 176 of file vector.hpp.

§ operator()() [2/2]

template<class T>
reference shark::blas::vector< T >::operator() ( index_type  i)
inline

Return a reference to the element \(i\) Return a reference to the element \(i\). With some compilers, this notation will be faster than operator[].

Parameters
iindex of the element

Definition at line 183 of file vector.hpp.

§ operator=() [1/3]

template<class T>
vector& shark::blas::vector< T >::operator= ( vector< T > const &  v)
inline

Assign a full vector (RHS-vector) to the current vector (LHS-vector) Assign a full vector (RHS-vector) to the current vector (LHS-vector). This method does not create any temporary.

Parameters
vis the source vector container
Returns
a reference to a vector (i.e. the destination vector)

Definition at line 234 of file vector.hpp.

Referenced by shark::blas::permutation_matrix::operator=().

§ operator=() [2/3]

template<class T>
template<class C >
vector& shark::blas::vector< T >::operator= ( vector_container< C > const &  v)
inline

Assign a full vector (RHS-vector) to the current vector (LHS-vector) Assign a full vector (RHS-vector) to the current vector (LHS-vector). This method does not create any temporary.

Parameters
vis the source vector container
Returns
a reference to a vector (i.e. the destination vector)

Definition at line 244 of file vector.hpp.

§ operator=() [3/3]

template<class T>
template<class E >
vector& shark::blas::vector< T >::operator= ( vector_expression< E > const &  e)
inline

Assign the result of a vector_expression to the vector Assign the result of a vector_expression to the vector.

Parameters
eis a const reference to the vector_expression
Returns
a reference to the resulting vector

Definition at line 254 of file vector.hpp.

§ operator[]() [1/2]

template<class T>
const_reference shark::blas::vector< T >::operator[] ( index_type  i) const
inline

Return a const reference to the element \(i\).

Parameters
iindex of the element

Definition at line 189 of file vector.hpp.

§ operator[]() [2/2]

template<class T>
reference shark::blas::vector< T >::operator[] ( index_type  i)
inline

Return a reference to the element \(i\).

Parameters
iindex of the element

Definition at line 195 of file vector.hpp.

§ push_back()

template<class T>
void shark::blas::vector< T >::push_back ( value_type const &  element)
inline

resizes the vector by appending a new element to the end. this invalidates storage

Definition at line 217 of file vector.hpp.

§ reserve()

template<class T>
void shark::blas::vector< T >::reserve ( size_type  )
inline

Definition at line 316 of file vector.hpp.

§ resize()

template<class T>
void shark::blas::vector< T >::resize ( size_type  size)
inline

Resize the vector.

Parameters
sizenew size of the vector

Definition at line 165 of file vector.hpp.

Referenced by shark::blas::vector< std::size_t >::operator=(), shark::blas::vector< std::size_t >::serialize(), and shark::MultiNomialDistribution::update().

§ serialize()

template<class T>
template<class Archive >
void shark::blas::vector< T >::serialize ( Archive &  ar,
const unsigned int  file_version 
)
inline

Serialize a vector into and archive as defined in Boost

Parameters
arArchive object. Can be a flat file, an XML file or any other stream
file_versionOptional file version (not yet used)

Definition at line 332 of file vector.hpp.

§ set_element()

template<class T>
iterator shark::blas::vector< T >::set_element ( iterator  pos,
index_type  index,
value_type  value 
)
inline

Definition at line 295 of file vector.hpp.

§ size()

§ storage() [1/2]

§ storage() [2/2]

template<class T>
const_pointer shark::blas::vector< T >::storage ( ) const
inline

Returns the pointer to the beginning of the vector storage.

Grants low-level access to the vectors internals. Elements storage()[0]...storage()[size()-1] are valid.

Definition at line 134 of file vector.hpp.

§ stride()

template<class T>
difference_type shark::blas::vector< T >::stride ( ) const
inline

Returns the stride between the elements in storage()

In general elements of dense storage entities are spaced like storage()[i*stride()] for i=1,...,size()-1 However for vector strid is guaranteed to be 1.

Definition at line 143 of file vector.hpp.

Friends And Related Function Documentation

§ swap

template<class T>
void swap ( vector< T > &  v1,
vector< T > &  v2 
)
friend

Swap the content of two vectors.

Parameters
v1is the first vector. It takes values from v2
v2is the second vector It takes values from v1

Definition at line 321 of file vector.hpp.

Referenced by shark::blas::vector< std::size_t >::operator=().


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