A dense vector of values of type T
.
More...
#include <shark/LinAlg/BLAS/vector.hpp>
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... | |
vector & | operator= (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 > | |
vector & | operator= (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 > | |
vector & | operator= (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) |
![]() | |
const container_type & | operator() () const |
container_type & | operator() () |
![]() | |
const expression_type & | operator() () const |
expression_type & | operator() () |
Friends | |
void | swap (vector &v1, vector &v2) |
Swap the content of two vectors. More... | |
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.
T | type of the objects stored in the vector (like int, double, complex,...) |
A | The 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.
typedef index_type const* shark::blas::vector< T >::const_index_pointer |
Definition at line 67 of file vector.hpp.
typedef dense_storage_iterator<value_type const> shark::blas::vector< T >::const_iterator |
Definition at line 262 of file vector.hpp.
typedef const T* shark::blas::vector< T >::const_pointer |
Definition at line 64 of file vector.hpp.
typedef array_type::const_reference shark::blas::vector< T >::const_reference |
Definition at line 61 of file vector.hpp.
typedef elementwise_tag shark::blas::vector< T >::evaluation_category |
Definition at line 74 of file vector.hpp.
typedef index_type shark::blas::vector< T >::index_pointer |
Definition at line 68 of file vector.hpp.
typedef dense_storage_iterator<value_type> shark::blas::vector< T >::iterator |
Definition at line 261 of file vector.hpp.
typedef T* shark::blas::vector< T >::pointer |
Definition at line 63 of file vector.hpp.
typedef array_type::reference shark::blas::vector< T >::reference |
Definition at line 62 of file vector.hpp.
typedef dense_tag shark::blas::vector< T >::storage_category |
Definition at line 73 of file vector.hpp.
|
inline |
Constructor of a vector By default it is empty, i.e. size()==0
.
Definition at line 80 of file vector.hpp.
|
inlineexplicit |
Constructor of a vector with a predefined size By default, its elements are initialized to 0.
size | initial size of the vector |
Definition at line 85 of file vector.hpp.
|
inline |
Constructs the vector from a predefined range.
Definition at line 89 of file vector.hpp.
|
inline |
Constructor of a vector by copying from another container This type has the generic name array_typ
within the vector definition.
data | container of type A |
Definition at line 94 of file vector.hpp.
|
inline |
Constructor of a vector with a predefined size and a unique initial value.
size | of the vector |
init | value to assign to each element of the vector |
Definition at line 99 of file vector.hpp.
|
inline |
Copy-constructor of a vector.
v | is the vector to be duplicated |
Definition at line 103 of file vector.hpp.
|
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).
e | the vector_expression which values will be duplicated into the vector |
Definition at line 110 of file vector.hpp.
|
inline |
Returns the last element of the vector.
Definition at line 208 of file vector.hpp.
|
inline |
Returns the last element of the vector.
Definition at line 212 of file vector.hpp.
|
inline |
return an iterator on the first element of the vector
Definition at line 275 of file vector.hpp.
|
inline |
Return an iterator on the first element of the vector.
Definition at line 285 of file vector.hpp.
|
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().
|
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().
|
inline |
Clear the vector, i.e. set all values to the zero
value.
Definition at line 222 of file vector.hpp.
|
inline |
Definition at line 302 of file vector.hpp.
|
inline |
Definition at line 310 of file vector.hpp.
|
inline |
Return true if the vector is empty (size==0
)
true
if empty, false
otherwise Definition at line 159 of file vector.hpp.
Referenced by shark::blas::vector< std::size_t >::serialize().
|
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().
|
inline |
Return an iterator at the end of the vector.
Definition at line 290 of file vector.hpp.
|
inline |
Returns the first element of the vector.
Definition at line 200 of file vector.hpp.
|
inline |
Returns the first element of the vector.
Definition at line 204 of file vector.hpp.
|
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.
|
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
[].
i | index of the element |
Definition at line 176 of file vector.hpp.
|
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
[].
i | index of the element |
Definition at line 183 of file vector.hpp.
|
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.
v | is the source vector container |
Definition at line 234 of file vector.hpp.
Referenced by shark::blas::permutation_matrix::operator=().
|
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.
v | is the source vector container |
Definition at line 244 of file vector.hpp.
|
inline |
Assign the result of a vector_expression to the vector Assign the result of a vector_expression to the vector.
e | is a const reference to the vector_expression |
Definition at line 254 of file vector.hpp.
|
inline |
Return a const reference to the element \(i\).
i | index of the element |
Definition at line 189 of file vector.hpp.
|
inline |
Return a reference to the element \(i\).
i | index of the element |
Definition at line 195 of file vector.hpp.
|
inline |
resizes the vector by appending a new element to the end. this invalidates storage
Definition at line 217 of file vector.hpp.
|
inline |
Definition at line 316 of file vector.hpp.
|
inline |
Resize the vector.
size | new 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().
|
inline |
Serialize a vector into and archive as defined in Boost
ar | Archive object. Can be a flat file, an XML file or any other stream |
file_version | Optional file version (not yet used) |
Definition at line 332 of file vector.hpp.
|
inline |
Definition at line 295 of file vector.hpp.
|
inline |
Return the size of the vector.
Definition at line 120 of file vector.hpp.
Referenced by shark::blas::vector< std::size_t >::back(), shark::blas::vector< std::size_t >::cend(), shark::blas::vector< std::size_t >::end(), shark::blas::vector< std::size_t >::operator=(), shark::blas::vector< std::size_t >::serialize(), shark::blas::vector< std::size_t >::storage(), shark::blas::swap_columns(), shark::blas::swap_columns_inverted(), shark::blas::swap_full(), shark::blas::swap_full_inverted(), shark::blas::swap_rows(), and shark::blas::swap_rows_inverted().
|
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 127 of file vector.hpp.
Referenced by shark::blas::vector< std::size_t >::back(), shark::blas::vector< std::size_t >::begin(), shark::blas::vector< std::size_t >::cbegin(), shark::blas::vector< std::size_t >::cend(), shark::blas::vector< std::size_t >::end(), shark::blas::vector< std::size_t >::front(), shark::blas::vector< std::size_t >::operator()(), and shark::blas::vector< std::size_t >::serialize().
|
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.
|
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.
Swap the content of two vectors.
v1 | is the first vector. It takes values from v2 |
v2 | is 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=().