Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

boost::numeric::ublas::vector< T, A > Class Template Reference

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

Inherits vector_container< vector< T, A > >.

Inherited by boost::numeric::ublas::permutation_matrix< T, A >.

List of all members.

Classes

class  const_iterator
class  iterator

Public Types

typedef A::size_type size_type
typedef A::difference_type difference_type
typedef T value_type
typedef type_traits< T >
::const_reference 
const_reference
typedef T & reference
typedef T * pointer
typedef const T * const_pointer
typedef A array_type
typedef const vector_reference
< const self_type
const_closure_type
typedef vector_reference
< self_type
closure_type
typedef self_type vector_temporary_type
typedef dense_tag storage_category
typedef reverse_iterator_base
< const_iterator
const_reverse_iterator
typedef reverse_iterator_base
< iterator
reverse_iterator

Public Member Functions

BOOST_UBLAS_INLINE vector ()
 Constructor of a vector By default it is empty, i.e. size()==0.
BOOST_UBLAS_INLINE vector (size_type size)
 Constructor of a vector with a predefined size By default, its elements are initialized to 0.
BOOST_UBLAS_INLINE vector (size_type size, 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.
BOOST_UBLAS_INLINE 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.
BOOST_UBLAS_INLINE vector (size_type size, const value_type &init)
 Constructor of a vector with a predefined size and a unique initial value.
BOOST_UBLAS_INLINE vector (const vector &v)
 Copy-constructor of a vector.
template<class AE >
BOOST_UBLAS_INLINE vector (const vector_expression< AE > &ae)
 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).
BOOST_UBLAS_INLINE 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.
BOOST_UBLAS_INLINE bool empty () const
 Return true if the vector is empty (size==0).
BOOST_UBLAS_INLINE size_type size () const
 Return the size of the vector.
BOOST_UBLAS_INLINE const
array_type & 
data () const
 Return a const reference to the container. Useful to access data directly for specific type of container.
BOOST_UBLAS_INLINE array_type & data ()
 Return a reference to the container. Useful to speed-up write operations to the data in very specific case.
BOOST_UBLAS_INLINE void resize (size_type size, bool preserve=true)
 Resize the vector Resize the vector to a new size. If preserve is true, data are copied otherwise data are lost. If the new size is bigger, the remaining values are filled in with the initial value (0 by default) in the case of unbounded_array, which is the container by default. If the new size is smaller, last values are lost. This behaviour can be different if you explicitely specify another type of container.
BOOST_UBLAS_INLINE pointer find_element (size_type i)
 Return a pointer to the element $i$.
BOOST_UBLAS_INLINE const_pointer find_element (size_type i) const
 Return a const pointer to the element $i$.
BOOST_UBLAS_INLINE const_reference operator() (size_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 [i].
BOOST_UBLAS_INLINE reference operator() (size_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 [i].
BOOST_UBLAS_INLINE const_reference operator[] (size_type i) const
 Return a const reference to the element $i$.
BOOST_UBLAS_INLINE reference operator[] (size_type i)
 Return a reference to the element $i$.
BOOST_UBLAS_INLINE reference insert_element (size_type i, const_reference t)
 Set element $i$ to the value t.
BOOST_UBLAS_INLINE void erase_element (size_type i)
 Set element $i$ to the zero value.
BOOST_UBLAS_INLINE void clear ()
 Clear the vector, i.e. set all values to the zero value.
BOOST_UBLAS_INLINE vectoroperator= (const vector &v)
 Assign a full vector (RHS-vector) to the current vector (LHS-vector).
template<class C >
BOOST_UBLAS_INLINE vectoroperator= (const vector_container< C > &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.
BOOST_UBLAS_INLINE vectorassign_temporary (vector &v)
 Assign a full vector (RHS-vector) to the current vector (LHS-vector).
template<class AE >
BOOST_UBLAS_INLINE vectoroperator= (const vector_expression< AE > &ae)
 Assign the result of a vector_expression to the vector Assign the result of a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
template<class AE >
BOOST_UBLAS_INLINE vectorassign (const vector_expression< AE > &ae)
 Assign the result of a vector_expression to the vector Assign the result of a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
template<class AE >
BOOST_UBLAS_INLINE vectoroperator+= (const vector_expression< AE > &ae)
 Assign the sum of the vector and a vector_expression to the vector Assign the sum of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. A temporary is created for the computations.
template<class C >
BOOST_UBLAS_INLINE vectoroperator+= (const vector_container< C > &v)
 Assign the sum of the vector and a vector_expression to the vector Assign the sum of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. No temporary is created. Computations are done and stored directly into the resulting vector.
template<class AE >
BOOST_UBLAS_INLINE vectorplus_assign (const vector_expression< AE > &ae)
 Assign the sum of the vector and a vector_expression to the vector Assign the sum of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. No temporary is created. Computations are done and stored directly into the resulting vector.
template<class AE >
BOOST_UBLAS_INLINE vectoroperator-= (const vector_expression< AE > &ae)
 Assign the difference of the vector and a vector_expression to the vector Assign the difference of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. A temporary is created for the computations.
template<class C >
BOOST_UBLAS_INLINE vectoroperator-= (const vector_container< C > &v)
 Assign the difference of the vector and a vector_expression to the vector Assign the difference of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. No temporary is created. Computations are done and stored directly into the resulting vector.
template<class AE >
BOOST_UBLAS_INLINE vectorminus_assign (const vector_expression< AE > &ae)
 Assign the difference of the vector and a vector_expression to the vector Assign the difference of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. No temporary is created. Computations are done and stored directly into the resulting vector.
template<class AT >
BOOST_UBLAS_INLINE vectoroperator*= (const AT &at)
 Assign the product of the vector and a scalar to the vector Assign the product of the vector and a scalar to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. No temporary is created. Computations are done and stored directly into the resulting vector.
template<class AT >
BOOST_UBLAS_INLINE vectoroperator/= (const AT &at)
 Assign the division of the vector by a scalar to the vector Assign the division of the vector by a scalar to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. No temporary is created. Computations are done and stored directly into the resulting vector.
BOOST_UBLAS_INLINE void swap (vector &v)
 Swap the content of the vector with another vector.
BOOST_UBLAS_INLINE const_iterator find (size_type i) const
 Return a const iterator to the element i.
BOOST_UBLAS_INLINE iterator find (size_type i)
 Return an iterator to the element i.
BOOST_UBLAS_INLINE const_iterator begin () const
 return an iterator on the first element of the vector
BOOST_UBLAS_INLINE const_iterator end () const
 return an iterator after the last element of the vector
BOOST_UBLAS_INLINE iterator begin ()
 Return an iterator on the first element of the vector.
BOOST_UBLAS_INLINE iterator end ()
 Return an iterator at the end of the vector.
BOOST_UBLAS_INLINE
const_reverse_iterator 
rbegin () const
 Return a const reverse iterator before the first element of the reversed vector (i.e. end() of normal vector).
BOOST_UBLAS_INLINE
const_reverse_iterator 
rend () const
 Return a const reverse iterator on the end of the reverse vector (i.e. first element of the normal vector).
BOOST_UBLAS_INLINE reverse_iterator rbegin ()
 Return a const reverse iterator before the first element of the reversed vector (i.e. end() of normal vector).
BOOST_UBLAS_INLINE reverse_iterator rend ()
 Return a const reverse iterator on the end of the reverse vector (i.e. first element of the normal vector).
template<class Archive >
void serialize (Archive &ar, const unsigned int)

Friends

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

Detailed Description

template<class T, class A>
class boost::numeric::ublas::vector< T, A >

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:
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

Constructor & Destructor Documentation

template<class T, class A>
BOOST_UBLAS_INLINE boost::numeric::ublas::vector< T, A >::vector ( size_type  size  )  [explicit]
Parameters:
size initial size of the vector
template<class T, class A>
BOOST_UBLAS_INLINE boost::numeric::ublas::vector< T, A >::vector ( size_type  size,
const array_type &  data 
)
Parameters:
size initial size of the vector
data container of type A
template<class T, class A>
BOOST_UBLAS_INLINE boost::numeric::ublas::vector< T, A >::vector ( const array_type &  data  ) 
Parameters:
data container of type A
template<class T, class A>
BOOST_UBLAS_INLINE boost::numeric::ublas::vector< T, A >::vector ( size_type  size,
const value_type &  init 
)
Parameters:
size of the vector
init value to assign to each element of the vector
template<class T, class A>
BOOST_UBLAS_INLINE boost::numeric::ublas::vector< T, A >::vector ( const vector< T, A > &  v  ) 
Parameters:
v is the vector to be duplicated
template<class T, class A>
template<class AE >
BOOST_UBLAS_INLINE boost::numeric::ublas::vector< T, A >::vector ( const vector_expression< AE > &  ae  ) 
Parameters:
ae the vector_expression which values will be duplicated into the vector

Member Function Documentation

template<class T, class A>
template<class AE >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::assign ( const vector_expression< AE > &  ae  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
Returns:
a reference to the resulting vector
template<class T, class A>
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::assign_temporary ( vector< T, A > &  v  ) 
Parameters:
v is the source vector
Returns:
a reference to a vector (i.e. the destination vector)
template<class T, class A>
BOOST_UBLAS_INLINE bool boost::numeric::ublas::vector< T, A >::empty (  )  const
Returns:
true if empty, false otherwise
template<class T, class A>
BOOST_UBLAS_INLINE void boost::numeric::ublas::vector< T, A >::erase_element ( size_type  i  ) 
Parameters:
i index of the element
template<class T, class A>
BOOST_UBLAS_INLINE iterator boost::numeric::ublas::vector< T, A >::find ( size_type  i  ) 
Parameters:
i index of the element
template<class T, class A>
BOOST_UBLAS_INLINE const_iterator boost::numeric::ublas::vector< T, A >::find ( size_type  i  )  const
Parameters:
i index of the element
template<class T, class A>
BOOST_UBLAS_INLINE const_pointer boost::numeric::ublas::vector< T, A >::find_element ( size_type  i  )  const
Parameters:
i index of the element
template<class T, class A>
BOOST_UBLAS_INLINE pointer boost::numeric::ublas::vector< T, A >::find_element ( size_type  i  ) 
Parameters:
i index of the element
template<class T, class A>
BOOST_UBLAS_INLINE reference boost::numeric::ublas::vector< T, A >::insert_element ( size_type  i,
const_reference  t 
)
Parameters:
i index of the element
t reference to the value to be set
template<class T, class A>
template<class AE >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::minus_assign ( const vector_expression< AE > &  ae  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
Returns:
a reference to the resulting vector
template<class T, class A>
BOOST_UBLAS_INLINE reference boost::numeric::ublas::vector< T, A >::operator() ( size_type  i  ) 
Parameters:
i index of the element
template<class T, class A>
BOOST_UBLAS_INLINE const_reference boost::numeric::ublas::vector< T, A >::operator() ( size_type  i  )  const
Parameters:
i index of the element
template<class T, class A>
template<class AT >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator*= ( const AT &  at  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
at is a const reference to the scalar
Returns:
a reference to the resulting vector
template<class T, class A>
template<class C >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator+= ( const vector_container< C > &  v  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
Returns:
a reference to the resulting vector
template<class T, class A>
template<class AE >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator+= ( const vector_expression< AE > &  ae  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
Returns:
a reference to the resulting vector
template<class T, class A>
template<class C >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator-= ( const vector_container< C > &  v  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
Returns:
a reference to the resulting vector
template<class T, class A>
template<class AE >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator-= ( const vector_expression< AE > &  ae  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
template<class T, class A>
template<class AT >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator/= ( const AT &  at  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
at is a const reference to the scalar
Returns:
a reference to the resulting vector
template<class T, class A>
template<class AE >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator= ( const vector_expression< AE > &  ae  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
Returns:
a reference to the resulting vector

Reimplemented in boost::numeric::ublas::bounded_vector< T, N >.

template<class T, class A>
template<class C >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator= ( const vector_container< C > &  v  ) 
Parameters:
v is the source vector container
Returns:
a reference to a vector (i.e. the destination vector)

Reimplemented in boost::numeric::ublas::bounded_vector< T, N >.

template<class T, class A>
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::operator= ( const vector< T, A > &  v  ) 
Parameters:
v is the source vector
Returns:
a reference to a vector (i.e. the destination vector)

Reimplemented in boost::numeric::ublas::permutation_matrix< T, A >.

template<class T, class A>
BOOST_UBLAS_INLINE reference boost::numeric::ublas::vector< T, A >::operator[] ( size_type  i  ) 
Parameters:
i index of the element
template<class T, class A>
BOOST_UBLAS_INLINE const_reference boost::numeric::ublas::vector< T, A >::operator[] ( size_type  i  )  const
Parameters:
i index of the element
template<class T, class A>
template<class AE >
BOOST_UBLAS_INLINE vector& boost::numeric::ublas::vector< T, A >::plus_assign ( const vector_expression< AE > &  ae  ) 
Template Parameters:
AE is the type of the vector_expression
Parameters:
ae is a const reference to the vector_expression
Returns:
a reference to the resulting vector
template<class T, class A>
BOOST_UBLAS_INLINE void boost::numeric::ublas::vector< T, A >::resize ( size_type  size,
bool  preserve = true 
)
Parameters:
size new size of the vector
preserve if true, keep values
template<class T, class A>
template<class Archive >
void boost::numeric::ublas::vector< T, A >::serialize ( Archive &  ar,
const unsigned  int 
)

Serialize a vector into and archive as defined in Boost

Parameters:
ar Archive object. Can be a flat file, an XML file or any other stream
file_version Optional file version (not yet used)
template<class T, class A>
BOOST_UBLAS_INLINE void boost::numeric::ublas::vector< T, A >::swap ( vector< T, A > &  v  ) 
Parameters:
v is the vector to be swapped with

Friends And Related Function Documentation

template<class T, class A>
BOOST_UBLAS_INLINE friend void swap ( vector< T, A > &  v1,
vector< T, A > &  v2 
) [friend]
Parameters:
v1 is the first vector. It takes values from v2
v2 is the second vector It takes values from v1

Generated on Sun Jul 4 20:31:07 2010 for ublas by  doxygen 1.6.1