namespace alps { template <class CONTAINER> struct VectorTraits { typedef ... value_type; typedef ... norm_type; typedef ... iterator; typedef ... const_iterator; typedef ... size_type; static const bool is_complex; }; namespace vectorops { template <class C> inline typename VectorTraits<C>::size_type size(const C& c); template <class C> inline typename VectorTraits<C>::value_type* data(C& c); template <class C> inline const typename VectorTraits<C>::value_type* data(const C& c); template <class C> inline typename VectorTraits<C>::norm_type infinity_norm(const C & c); template <class C> inline typename VectorTraits<C>::norm_type one_norm(const C& c); template <class C> inline typename VectorTraits<C>::norm_type two_norm2(const C& c); template <class C> inline typename VectorTraits<C>::norm_type two_norm(const C& c); template <class C> inline typename VectorTraits<C>::norm_type normalize(C& c); template <class C, class X> inline void scale(C& c, X val); template <class C> inline void add(C& c1, const C& c2); template <class C> inline void subtract(C& c1, const C& c2); template <class C, class X> inline void add_scaled(C& c1, const C& c2, X val); template <class C, class X> inline void subtract_scaled(C& c1, const C& c2, X val); template <class C> inline void resize(C& c, std::size_t n); template <class C> inline void assign(C& c, typename VectorTraits<C>::value_type x); template <class C> inline void assign(C& c1, const C& c2); template <class C> inline void swap(C& c1, C& c2); template <class C> inline typename VectorTraits<C>::value_type scalar_product(const C& c1, const C& c2); template <class C> inline void deallocate(C& c); // specializations for std::valarray. . . } }
Member | Default value | Description |
value_type | C::value_type | the value type |
norm_type | TypeTraits<value_type>::norm_t | a type to store the norm of the vector |
iterator | C::value_type | the iterator type |
const_iterator | C::value_type | the const iterator type |
size_type | C::value_type | the size type |
is_complex | TypeTraits<value_type>::is_complex | a flag indicating whether the vector is complex |
returns the size of the vector.template <class C> inline typename VectorTraits<C>::size_type size(const C& c);
returns a pointer to the begin of the storage for the vector. Note that this might not be a sensible operations for all types of vectors.template <class C> inline typename VectorTraits<C>::value_type* data(C& c); template <class C> inline const typename VectorTraits<C>::value_type* data(const C& c);
returns the infinity norm (maximum absolute element value) of the vector.template <class C> inline typename VectorTraits<C>::norm_type infinity_norm(const C & c);
returns the one-norm (suym of absolute values) of the vector.template <class C> inline typename VectorTraits<C>::norm_type one_norm(const C& c);
returns the square of the 2-norm (sum of squares of absolute values) of the vector.template <class C> inline typename VectorTraits<C>::norm_type two_norm2(const C& c);
returns the 2-norm (square root of the sum of squares of absolute values) of the vector.template <class C> inline typename VectorTraits<C>::norm_type two_norm(const C& c);
scales the vector by the scalar. Acts like c*=val.template <class C, class X> inline void scale(C& c, X val);
normalizes the vector (divides by the 2-norm) and returns the 2-norm.template <class C> inline typename VectorTraits<C>::norm_type normalize(C& c);
adds a vector. Acts like c1+=c2.template <class C> inline void add(C& c1, const C& c2);
subtracts a vector. Acts like c1-=c2.template <class C> inline void subtract(C& c1, const C& c2);
adds a scaled vector. Acts like c1+=val*c2template <class C, class X> inline void add_scaled(C& c1, const C& c2, X val);
subtracts a scaled vector. Acts like c1-=val*c2template <class C, class X> inline void subtract_scaled(C& c1, const C& c2, X val);
resizes the vector.template <class C> inline void resize(C& c, std::size_t n);
assigns a value to all vector elementstemplate <class C> inline void assign(C& c, typename VectorTraits<C>::value_type x);
makes the vector a copy of another. Acts like c1=c2.template <class C> inline void assign(C& c1, const C& c2);
an optimized swap.template <class C> inline void swap(C& c1, C& c2);
returns the scalar products of the vectors.template <class C> inline typename VectorTraits<C>::value_type scalar_product(const C& c1, const C& c2);
deallocates the vector (releasing as much memory as possible).template <class C> inline void deallocate(C& c);
copyright (c) 1994-2010 by Matthias Troyer
Distributed under the Boost Software License, Version 1.0. å(See http://www.boost.org/LICENSE_1_0.txt)