TBCI Numerical high perf. C++ Library  2.8.0
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
Vector< T > Class Template Reference

#include <bvector.h>

Inheritance diagram for Vector< T >:
Inheritance graph
[legend]
Collaboration diagram for Vector< T >:
Collaboration graph
[legend]

Public Types

typedef T value_type
 
typedef T element_type
 
typedef T aligned_value_type TALIGN (MIN_ALIGN2)
 
- Public Types inherited from TVector< T >
typedef T value_type
 
typedef T element_type
 
typedef T aligned_value_type TALIGN (MIN_ALIGN2)
 
- Public Types inherited from BVector< T >
typedef Titerator
 STL-like iterator support. More...
 
typedef const Tconst_iterator
 

Public Member Functions

 Vector (const unsigned long d=0)
 
 Vector (const T &val, const unsigned long d)
 
 Vector (const BVector< T > &bv)
 
 Vector (const Vector< T > &v)
 
 Vector (const TSVector< T > &ts)
 
 Vector (const TVector< T > &tv)
 
 Vector (const Mat_Brack< T > &)
 
 Vector (const vararg va,...)
 
 ~Vector ()
 
tbci_traits< T >::const_refval_type operator() (const unsigned long i) const
 
tbci_traits< T >::const_refval_type operator[] (const unsigned long i) const
 
Toperator() (const unsigned long i)
 
Toperator[] (const unsigned long i)
 
Vector< T > & fill (const T &v)
 
Vector< T > & clear ()
 
TVector< Tslice (unsigned long, unsigned long) const
 
TVector< Tincr (const unsigned long, const T=(T) 1) const
 
Vector< T > & operator= (const T &a)
 
Vector< T > & operator= (const Vector< T > &v) HOT
 assignment operator does NOT resize the Vector! More...
 
Vector< T > & operator= (const TSVector< T > &ts) HOT
 
Vector< T > & operator= (const TVector< T > &tv) HOT
 
bool operator== (const Vector< T > &v) const
 
bool operator!= (const Vector< T > &v) const
 
bool operator== (const TSVector< T > &) const
 
bool operator!= (const TSVector< T > &ts) const
 
bool operator== (const TVector< T > &tv) const
 
bool operator!= (const TVector< T > &tv) const
 
bool operator<= (const Vector< T > &v) const
 
bool operator>= (const Vector< T > &v) const
 
bool operator< (const Vector< T > &v) const
 
bool operator> (const Vector< T > &v) const
 
TVector< Toperator+ (const Vector< T > &) const HOT
 TV = V + V. More...
 
TVector< Toperator- (const Vector< T > &) const HOT
 TV = V - V. More...
 
TVector< Toperator+ (TVector< T > tv) const HOT
 TV = V + TV transformed into TV += V. More...
 
TVector< Toperator- (TVector< T > tv) const HOT
 TV = V - TV transformed into -TV -= V. More...
 
TVector< Toperator+ (const TSVector< T > &) const HOT
 TV = V + TSV. More...
 
TVector< Toperator- (const TSVector< T > &) const HOT
 TV = V - TSV. More...
 
TVector< Toperator+ (const T &) const
 TV = V + T. More...
 
TVector< Toperator- (const T &) const
 TV = V - T. More...
 
TSVector< Toperator* (const T &) const
 
TSVector< Toperator/ (const T &) const
 
TVector< Toperator- () const
 
T operator* (const Vector< T > &) const
 
T operator* (TVector< T > &tv) const
 
T operator/ (const Vector< T > &) const
 
T min () const
 
T max () const
 
T min (unsigned long &pos) const
 
T max (unsigned long &pos) const
 
T sum () const
 
double fabssqr () const HOT
 
double fabs () const
 
T abs () const
 
bool contains (const T &v) const
 
template<typename U >
 Vector (const BVector< U > &bv)
 
- Public Member Functions inherited from TVector< T >
 TVector (const unsigned long d=0)
 
 TVector (const T &val, const unsigned long d)
 
 TVector (const BVector< T > &bv)
 
 TVector (const Vector< T > &v)
 
 TVector (const TVector< T > &tv) HOT
 
 TVector (const TSVector< T > &ts)
 
 TVector (const Mat_Brack< T > &)
 
 ~TVector ()
 
unsigned long size () const
 
TVector< T > & operator= (const T &a)
 
TVector< T > & operator= (const Vector< T > &v)
 
TVector< T > & operator= (const TVector< T > &tv)
 alias More...
 
TVector< T > & operator= (const TSVector< T > &ts)
 
bool operator== (const TVector< T > &tv) const
 
bool operator!= (const TVector< T > &tv) const
 
bool operator== (const Vector< T > &v) const
 
bool operator!= (const Vector< T > &v) const
 
bool operator== (const BVector< T > &bv) const
 
bool operator!= (const BVector< T > &v) const
 
bool operator== (const TSVector< T > &tsv) const
 
bool operator!= (const TSVector< T > &tsv) const
 
TVector< T > & operator+= (const T &)
 TV += a. More...
 
TVector< T > & operator-= (const T &)
 TV -= a. More...
 
TVector< T > & operator*= (const T &)
 TV *= a. More...
 
TVector< T > & operator/= (const T &)
 TV /= a. More...
 
TVector< T > & operator+= (const Vector< T > &) HOT
 TV += V. More...
 
TVector< T > & operator-= (const Vector< T > &) HOT
 TV -= V. More...
 
TVector< T > & operator+= (const TVector< T > &tv)
 
TVector< T > & operator-= (const TVector< T > &tv)
 
TVector< T > & operator+= (const TSVector< T > &tsv) HOT
 TV += TSV. More...
 
TVector< T > & operator-= (const TSVector< T > &tsv) HOT
 TV -= TSV. More...
 
T min ()
 
T max ()
 
T sum ()
 
double fabssqr ()
 
double fabs ()
 
T abs ()
 
TVector< T > & operator+ (const Vector< T > &) HOT
 
TVector< T > & operator- (const Vector< T > &) HOT
 
TVector< T > & operator+ (const TSVector< T > &ts) HOT
 TV = TV + TSV Transformed to TV += TSV. More...
 
TVector< T > & operator- (const TSVector< T > &ts) HOT
 TV = TV - TSV Transformed to TV -= TSV. More...
 
const TVector< T > & operator+ (const TVector< T > &a) HOT
 TV = TV + TV Transformed to TV += TV. More...
 
const TVector< T > & operator- (const TVector< T > &a) HOT
 TV = TV - TV Transformed to TV -= TV. More...
 
T operator() (const unsigned long i)
 
T operator[] (const unsigned long i)
 
const Tgetcref (const unsigned long i) const
 
tbci_traits< T >::const_refval_type get (const unsigned long i) const
 
Tsetval (const unsigned long i) const
 
Tsetval (const T &val, const unsigned long i) const
 
Tset (const T &val, const unsigned long i) const
 
TVector< Tslice (const unsigned long, const unsigned long)
 
TVector< T > & incr (const unsigned long, const T=(T) 1)
 
TVector< T > & operator+ (const T &)
 
TVector< T > & operator- (const T &)
 
TSVector< Toperator* (const T &)
 
TSVector< Toperator/ (const T &)
 
TSVector< Toperator- ()
 
T operator* (const Vector< T > &v)
 
T operator* (TVector< T > &tv)
 
template<typename U >
 TVector (const BVector< U > &bv)
 
- Public Member Functions inherited from BVector< T >
 BVector (const unsigned long=0)
 
 BVector (const T &, const unsigned long)
 
 BVector (const BVector< T > &) HOT
 copy constructor More...
 
 BVector (const vararg va,...)
 
void destroy ()
 
 ~BVector ()
 
BVector< T > & init_0 ()
 
BVector< T > & fill (const T &) HOT
 
BVector< T > & resize (const BVector< T > &)
 Actually it's a resize and copy (some people would expect the assignment op to do this) More...
 
BVector< T > & resize (const unsigned long)
 
BVector< T > & resize (const T &, const unsigned long)
 
BVector< T > & cheapdownsize (const unsigned long)
 
BVector< T > & clear ()
 
BVector< T > & append (const T &)
 performs poorly More...
 
BVector< T > & push_back (const T &value)
 performs poorly More...
 
BVector< T > & append (const BVector< T > &)
 
BVector< T > & remove (const unsigned long)
 
BVector< T > & revert ()
 
BVector< T > & bubble_sort ()
 
BVector< T > & swap (BVector< T > &v)
 
Toperator() (const unsigned long) HOT
 
tbci_traits< T >::const_refval_type operator() (const unsigned long) const HOT
 
const Tgetcref (const unsigned long idx) const
 
tbci_traits< T >::const_refval_type get (const unsigned long idx) const HOT
 
Tset (const unsigned long idx) HOT
 
Tset (const T &val, unsigned long idx)
 
Toperator[] (const unsigned long i)
 
tbci_traits< T >::const_refval_type operator[] (const unsigned long i) const
 
unsigned long size () const HOT
 
T *const & vecptr () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
BVector< T > & setptr (T *pointer)
 
BVector< T > & setsize (const unsigned long size)
 
T *const & get_fortran_vector () const
 
void set_fortran_vector (T *pointer)
 
BVector< T > & operator= (const T &a)
 
BVector< T > & operator= (const BVector< T > &) HOT
 Note that the assignment op does NEVER resize the target BVector. More...
 
BVector< T > & alias (const BVector< T > &bv)
 
BVector< T > & copy (const BVector< T > &bv)
 copy does a resize, if necessary More...
 
bool operator== (const BVector< T > &) const HOT
 KG, 2001-06-29: Strange: If we don't inline this, we seems to get better performance in our solver benchmark (iPIII) More...
 
bool operator!= (const BVector< T > &bv) const
 
bool operator<= (const BVector< T > &bv) const
 
bool operator>= (const BVector< T > &bv) const
 
bool operator< (const BVector< T > &bv) const
 
bool operator> (const BVector< T > &bv) const
 
bool contains (const T &, unsigned long *=0) const
 
BVector< Tconcat (const BVector< T > &) const
 
template<typename U >
 BVector (const BVector< U > &bv)
 
- Public Member Functions inherited from BVector_Sig< T >
 BVector_Sig ()
 
 BVector_Sig (const unsigned long)
 
 ~BVector_Sig ()
 
Toperator() (const unsigned long)
 
tbci_traits< T >::const_refval_type operator() (const unsigned long) const
 
unsigned long size () const
 
BVector_Sig< T > & fill (const T &)
 
BVector_Sig< T > & clear ()
 
bool operator== (const BVector_Sig< T > &) const
 
bool operator!= (const BVector_Sig< T > &) const
 
- Public Member Functions inherited from Vector_Sig< T >
 Vector_Sig ()
 
 Vector_Sig (const unsigned)
 
 ~Vector_Sig ()
 
Vector_Sig< Toperator+ (const Vector_Sig< T > &) const
 
Vector_Sig< Toperator- (const Vector_Sig< T > &) const
 
Vector_Sig< Toperator* (const T &) const
 
Vector_Sig< Toperator/ (const T &) const
 
Vector_Sig< T > & operator+= (const Vector_Sig< T > &)
 
Vector_Sig< T > & operator-= (const Vector_Sig< T > &)
 
Vector_Sig< T > & operator*= (const T &)
 
Vector_Sig< T > & operator/= (const T &)
 
bool operator<= (const Vector_Sig< T > &) const
 
bool operator>= (const Vector_Sig< T > &) const
 
bool operator< (const Vector_Sig< T > &) const
 
bool operator> (const Vector_Sig< T > &) const
 

Static Public Member Functions

static const char * vec_info ()
 
- Static Public Member Functions inherited from TVector< T >
static const char * vec_info ()
 
- Static Public Member Functions inherited from BVector< T >
static const char * vec_info ()
 
- Static Public Member Functions inherited from BVector_Sig< T >
static const char * vec_info ()
 

Friends

class TSVector< T >
 
T dot FGD (const Vector< T > &, const Vector< T > &) HOT
 

Additional Inherited Members

- Protected Types inherited from BVector< T >
typedef T value_type
 
typedef T element_type
 
typedef T aligned_value_type TALIGN (MIN_ALIGN2)
 
- Protected Attributes inherited from BVector< T >
Tvec
 
unsigned long dim
 
bool keep
 

Detailed Description

template<typename T>
class Vector< T >

This is the real Vector class, to be used by users of this library. The existence of TVector and TSVector should in theory be non-visible to the user.

Read the introduction to TBCI to understand how the Temporary Base Class Idiom helps to avoid spurious copies of data; the compiler knows that temporary objects can be aliased rather than copied, thus we copy one pointer rather than a data array. This gives us C++ semantics (operators!) with the possibility of composing operator expressions and at the same time the speed of C/FORTRAN. To achieve this the temporary base class TVector is needed as cousin for Vector.

The TSVector class is a further optimization that helps to do the composed operation Scale a x Plus y (a scalar, x, y vectors) in just one loop.

A more generic way of optimizing C++ expressions are expression templates. These however put a heavy burden on the compilers and will only be implemented in a successor project.

Definition at line 54 of file bvector.h.

Member Typedef Documentation

template<typename T>
typedef T Vector< T >::element_type

Definition at line 1531 of file vector.h.

template<typename T>
typedef T aligned_value_type Vector< T >::TALIGN(MIN_ALIGN2)

Definition at line 1532 of file vector.h.

template<typename T>
typedef T Vector< T >::value_type

Definition at line 1530 of file vector.h.

Constructor & Destructor Documentation

template<typename T>
Vector< T >::Vector ( const unsigned long  d = 0)
inlineexplicit

Definition at line 1539 of file vector.h.

template<typename T>
Vector< T >::Vector ( const T val,
const unsigned long  d 
)
inline

Definition at line 1540 of file vector.h.

template<typename T>
Vector< T >::Vector ( const BVector< T > &  bv)
inline

Definition at line 1541 of file vector.h.

template<typename T>
Vector< T >::Vector ( const Vector< T > &  v)
inline

Definition at line 1542 of file vector.h.

template<typename T>
Vector< T >::Vector ( const TSVector< T > &  ts)
inline

Definition at line 1544 of file vector.h.

template<typename T>
Vector< T >::Vector ( const TVector< T > &  tv)
inline

Definition at line 1546 of file vector.h.

template<typename T>
Vector< T >::Vector ( const Mat_Brack< T > &  mb)
inline

Definition at line 2340 of file matrix.h.

References TMatrix< T >::dim, if(), LIKELY, NEW, T, TBCICOPY, and TMatrix< T >::vec.

template<typename T>
Vector< T >::Vector ( const vararg  va,
  ... 
)
inline

Definition at line 1687 of file vector.h.

References TSVector< T >::dim, i, NEW, T, UNLIKELY, and TSVector< T >::vec.

template<typename T>
Vector< T >::~Vector ( )
inline

Definition at line 1559 of file vector.h.

template<typename T>
template<typename U >
Vector< T >::Vector ( const BVector< U > &  bv)
inlineexplicit

Definition at line 1673 of file vector.h.

Member Function Documentation

template<typename T>
T Vector< T >::abs ( ) const
inline

Definition at line 1646 of file vector.h.

Referenced by TVector< T >::abs().

template<typename T>
Vector<T>& Vector< T >::clear ( )
inline

Definition at line 1578 of file vector.h.

template<typename T>
bool Vector< T >::contains ( const T v) const
inline

Definition at line 1649 of file vector.h.

template<typename T>
double Vector< T >::fabs ( ) const
inline

Definition at line 1645 of file vector.h.

Referenced by TVector< T >::fabs().

template<typename T >
double Vector< T >::fabssqr ( ) const
inline
template<typename T>
Vector<T>& Vector< T >::fill ( const T v)
inline

Definition at line 1577 of file vector.h.

Referenced by CTensor< T >::calc_indx(), and Vector< unsigned >::clear().

template<typename T>
TVector< T > Vector< T >::incr ( const unsigned long  wh,
const T  i = (T)1 
) const
inline

Definition at line 2348 of file vector.h.

References BCHK, i, and BVector< T >::vec.

template<typename T >
T Vector< T >::max ( ) const

Definition at line 2058 of file vector.h.

References ALIGN, TSVector< T >::dim, LIKELY, max(), MIN_ALIGN, REGISTER, T, UNLIKELY, and TSVector< T >::vec.

Referenced by TVector< T >::max(), and TSVector< T >::max().

template<typename T >
T Vector< T >::max ( unsigned long &  pos) const

Definition at line 2070 of file vector.h.

References ALIGN, BCHK, TSVector< T >::dim, LIKELY, max(), MIN_ALIGN, REGISTER, T, UNLIKELY, and TSVector< T >::vec.

template<typename T >
T Vector< T >::min ( ) const

Definition at line 2032 of file vector.h.

References ALIGN, TSVector< T >::dim, LIKELY, min, MIN_ALIGN, REGISTER, T, UNLIKELY, and TSVector< T >::vec.

Referenced by TVector< T >::min(), and TSVector< T >::min().

template<typename T >
T Vector< T >::min ( unsigned long &  pos) const

Definition at line 2044 of file vector.h.

References ALIGN, BCHK, TSVector< T >::dim, LIKELY, min, MIN_ALIGN, REGISTER, T, UNLIKELY, and TSVector< T >::vec.

template<typename T>
bool Vector< T >::operator!= ( const Vector< T > &  v) const
inline

Definition at line 1605 of file vector.h.

template<typename T>
bool Vector< T >::operator!= ( const TSVector< T > &  ts) const
inline

Definition at line 1607 of file vector.h.

template<typename T>
bool Vector< T >::operator!= ( const TVector< T > &  tv) const
inline

Definition at line 1609 of file vector.h.

template<typename T>
tbci_traits<T>::const_refval_type Vector< T >::operator() ( const unsigned long  i) const
inline

Definition at line 1563 of file vector.h.

Referenced by Vector< unsigned >::operator[]().

template<typename T>
T& Vector< T >::operator() ( const unsigned long  i)
inline

Definition at line 1569 of file vector.h.

template<typename T>
TSVector< T > Vector< T >::operator* ( const T a) const
inline

Definition at line 2263 of file vector.h.

References a.

Referenced by Vector< unsigned >::operator*().

template<typename T>
T Vector< T >::operator* ( const Vector< T > &  a) const
inline
template<typename T>
T Vector< T >::operator* ( TVector< T > &  tv) const
inline

Definition at line 1635 of file vector.h.

template<typename T>
TVector< T > Vector< T >::operator+ ( const Vector< T > &  v) const
inline

TV = V + V.

Definition at line 2169 of file vector.h.

References BCHK, BVector< T >::dim, TSVector< T >::size(), STD_SMP_TEMPLATE3VV, and BVector< T >::vec.

template<typename T>
TVector< T > Vector< T >::operator+ ( TVector< T tv) const
inline

TV = V + TV transformed into TV += V.

Definition at line 2191 of file vector.h.

References BCHK, BVector< T >::dim, TSVector< T >::size(), STD_SMP_TEMPLATE2V, and BVector< T >::vec.

template<typename T>
TVector< T > Vector< T >::operator+ ( const TSVector< T > &  ts) const
inline
template<typename T>
TVector< T > Vector< T >::operator+ ( const T a) const
inline

TV = V + T.

Definition at line 2244 of file vector.h.

References STD_SMP_TEMPLATE3VC, and BVector< T >::vec.

template<typename T>
TVector< T > Vector< T >::operator- ( const Vector< T > &  v) const
inline

TV = V - V.

Definition at line 2179 of file vector.h.

References BCHK, BVector< T >::dim, TSVector< T >::size(), STD_SMP_TEMPLATE3VV, and BVector< T >::vec.

template<typename T>
TVector< T > Vector< T >::operator- ( TVector< T tv) const
inline

TV = V - TV transformed into -TV -= V.

Definition at line 2201 of file vector.h.

References BCHK, BVector< T >::dim, TSVector< T >::size(), STD_SMP_TEMPLATE2V, and BVector< T >::vec.

template<typename T>
TVector< T > Vector< T >::operator- ( const TSVector< T > &  ts) const
inline
template<typename T>
TVector< T > Vector< T >::operator- ( const T a) const
inline

TV = V - T.

Definition at line 2253 of file vector.h.

References STD_SMP_TEMPLATE3VC, and BVector< T >::vec.

template<typename T>
TVector< T > Vector< T >::operator- ( ) const
inline

Definition at line 2326 of file vector.h.

References TSVector< T >::dim, BVector< T >::vec, and TSVector< T >::vec.

template<typename T>
TSVector< T > Vector< T >::operator/ ( const T a) const
inline

Definition at line 2269 of file vector.h.

References BCHK, and T.

template<typename T>
T Vector< T >::operator/ ( const Vector< T > &  a) const

Definition at line 2024 of file vector.h.

References a, ALIGN, BCHK, Vector< T >::fabssqr(), MIN_ALIGN, norm(), and T.

template<typename T>
bool Vector< T >::operator< ( const Vector< T > &  v) const
inline

Definition at line 1613 of file vector.h.

template<typename T>
bool Vector< T >::operator<= ( const Vector< T > &  v) const
inline

Definition at line 1611 of file vector.h.

template<typename T>
Vector<T>& Vector< T >::operator= ( const T a)
inline

Definition at line 1587 of file vector.h.

template<typename T>
Vector<T>& Vector< T >::operator= ( const Vector< T > &  v)
inline

assignment operator does NOT resize the Vector!

Definition at line 1590 of file vector.h.

template<typename T>
Vector<T>& Vector< T >::operator= ( const TSVector< T > &  ts)
inline

Definition at line 1592 of file vector.h.

template<typename T>
Vector<T>& Vector< T >::operator= ( const TVector< T > &  tv)
inline

Definition at line 1594 of file vector.h.

template<typename T>
bool Vector< T >::operator== ( const Vector< T > &  v) const
inline

Definition at line 1603 of file vector.h.

template<typename T>
bool Vector< T >::operator== ( const TSVector< T > &  tsv) const
template<typename T>
bool Vector< T >::operator== ( const TVector< T > &  tv) const
inline

Definition at line 1608 of file vector.h.

template<typename T>
bool Vector< T >::operator> ( const Vector< T > &  v) const
inline

Definition at line 1614 of file vector.h.

template<typename T>
bool Vector< T >::operator>= ( const Vector< T > &  v) const
inline

Definition at line 1612 of file vector.h.

template<typename T>
tbci_traits<T>::const_refval_type Vector< T >::operator[] ( const unsigned long  i) const
inline

Definition at line 1566 of file vector.h.

template<typename T>
T& Vector< T >::operator[] ( const unsigned long  i)
inline

Definition at line 1571 of file vector.h.

template<typename T >
TVector< T > Vector< T >::slice ( unsigned long  i0,
unsigned long  i1 
) const
inline
template<typename T >
T Vector< T >::sum ( ) const
template<typename T>
static const char* Vector< T >::vec_info ( )
inlinestatic

Definition at line 1655 of file vector.h.

Friends And Related Function Documentation

template<typename T>
T dot FGD ( const Vector< T > &  ,
const Vector< T > &   
)
friend
template<typename T>
friend class TSVector< T >
friend

Definition at line 1534 of file vector.h.


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