TBCI Numerical high perf. C++ Library 2.8.0
Vector< T > Class Template Reference

#include <vector.h>

Inheritance diagram for Vector< T >:
Collaboration diagram for Vector< T >:

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.
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!
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.
TVector< Toperator- (const Vector< T > &) const HOT
 TV = V - V.
TVector< Toperator+ (TVector< T > tv) const HOT
 TV = V + TV transformed into TV += V.
TVector< Toperator- (TVector< T > tv) const HOT
 TV = V - TV transformed into -TV -= V.
TVector< Toperator+ (const TSVector< T > &) const HOT
 TV = V + TSV.
TVector< Toperator- (const TSVector< T > &) const HOT
 TV = V - TSV.
TVector< Toperator+ (const T &) const
 TV = V + T.
TVector< Toperator- (const T &) const
 TV = V - T.
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
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.
TVector< T > & operator-= (const T &)
 TV -= a.
TVector< T > & operator*= (const T &)
 TV *= a.
TVector< T > & operator/= (const T &)
 TV /= a.
TVector< T > & operator+= (const Vector< T > &) HOT
 TV += V.
TVector< T > & operator-= (const Vector< T > &) HOT
 TV -= V.
TVector< T > & operator+= (const TVector< T > &tv)
TVector< T > & operator-= (const TVector< T > &tv)
TVector< T > & operator+= (const TSVector< T > &tsv) HOT
 TV += TSV.
TVector< T > & operator-= (const TSVector< T > &tsv) HOT
 TV -= TSV.
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.
TVector< T > & operator- (const TSVector< T > &ts) HOT
 TV = TV - TSV Transformed to TV -= TSV.
const TVector< T > & operator+ (const TVector< T > &a) HOT
 TV = TV + TV Transformed to TV += TV.
const TVector< T > & operator- (const TVector< T > &a) HOT
 TV = TV - TV Transformed to TV -= TV.
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
 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).
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
BVector< T > & push_back (const T &value)
 performs poorly
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.
BVector< T > & alias (const BVector< T > &bv)
BVector< T > & copy (const BVector< T > &bv)
 copy does a resize, if necessary
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).
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 1526 of file vector.h.

Member Typedef Documentation

◆ element_type

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

Definition at line 1531 of file vector.h.

◆ TALIGN

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

Definition at line 1532 of file vector.h.

◆ value_type

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

Definition at line 1530 of file vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/9]

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

◆ Vector() [2/9]

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

Definition at line 1540 of file vector.h.

References T, and TVector< T >::TVector().

◆ Vector() [3/9]

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

Definition at line 1541 of file vector.h.

References BVector< T >::BVector, T, and TVector< T >::TVector().

◆ Vector() [4/9]

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

Definition at line 1542 of file vector.h.

References T, TVector< T >::TVector(), and Vector().

◆ Vector() [5/9]

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

Definition at line 1544 of file vector.h.

References ts.

◆ Vector() [6/9]

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

Definition at line 1546 of file vector.h.

References T, and TVector< T >::TVector().

◆ Vector() [7/9]

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

Definition at line 2340 of file matrix.h.

References BVector< T >::keep, LIKELY, NEW, T, and TBCICOPY.

◆ Vector() [8/9]

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

Definition at line 1687 of file vector.h.

References i, BVector< T >::keep, NEW, T, and UNLIKELY.

◆ ~Vector()

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

Definition at line 1559 of file vector.h.

References BVector< T >::destroy().

◆ Vector() [9/9]

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

Definition at line 1673 of file vector.h.

References BVector< T >::BVector, T, and TVector< T >::TVector().

Member Function Documentation

◆ abs()

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

Definition at line 1646 of file vector.h.

References fabssqr(), MATH__, sqrt(), and T.

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

◆ clear()

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

Definition at line 1578 of file vector.h.

References fill(), and Vector().

◆ contains()

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

Definition at line 1649 of file vector.h.

References BVector< T >::contains().

◆ fabs()

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

Definition at line 1645 of file vector.h.

References fabs(), fabssqr(), MATH__, and sqrt().

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

◆ fabssqr()

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

◆ fill()

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

Definition at line 1577 of file vector.h.

References BVector< T >::fill(), T, and Vector().

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

◆ incr()

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, T, TVector< T >::TVector(), and BVector< T >::vec.

◆ max() [1/2]

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

Definition at line 2058 of file vector.h.

References ALIGN, LIKELY, max(), MIN_ALIGN, REGISTER, T, and UNLIKELY.

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

◆ max() [2/2]

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

Definition at line 2070 of file vector.h.

References ALIGN, BCHK, LIKELY, max(), MIN_ALIGN, REGISTER, T, and UNLIKELY.

◆ min() [1/2]

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

Definition at line 2032 of file vector.h.

References ALIGN, LIKELY, min(), MIN_ALIGN, REGISTER, T, and UNLIKELY.

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

◆ min() [2/2]

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

Definition at line 2044 of file vector.h.

References ALIGN, BCHK, LIKELY, min(), MIN_ALIGN, REGISTER, T, and UNLIKELY.

◆ operator!=() [1/3]

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

Definition at line 1607 of file vector.h.

References ts.

◆ operator!=() [2/3]

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

Definition at line 1609 of file vector.h.

References TVector< T >::TVector().

◆ operator!=() [3/3]

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

Definition at line 1605 of file vector.h.

References Vector().

◆ operator()() [1/2]

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

Definition at line 1569 of file vector.h.

References i, BVector< T >::operator()(), and T.

◆ operator()() [2/2]

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.

References i, and BVector< T >::operator()().

Referenced by operator[](), and operator[]().

◆ operator*() [1/3]

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

Definition at line 2263 of file vector.h.

References a, and T.

Referenced by operator*().

◆ operator*() [2/3]

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

◆ operator*() [3/3]

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

Definition at line 1635 of file vector.h.

References operator*(), T, TVector< T >::TVector(), and Vector().

◆ operator+() [1/4]

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 a, STD_SMP_TEMPLATE3VC, T, TVector< T >::TVector(), and BVector< T >::vec.

◆ operator+() [2/4]

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

◆ operator+() [3/4]

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

◆ operator+() [4/4]

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, TVector< T >::size(), STD_SMP_TEMPLATE2V, TVector< T >::TVector(), and BVector< T >::vec.

◆ operator-() [1/5]

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

Definition at line 2326 of file vector.h.

References TVector< T >::TVector(), and BVector< T >::vec.

◆ operator-() [2/5]

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 a, STD_SMP_TEMPLATE3VC, T, TVector< T >::TVector(), and BVector< T >::vec.

◆ operator-() [3/5]

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

◆ operator-() [4/5]

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

◆ operator-() [5/5]

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, TVector< T >::size(), STD_SMP_TEMPLATE2V, TVector< T >::TVector(), and BVector< T >::vec.

◆ operator/() [1/2]

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

Definition at line 2269 of file vector.h.

References a, BCHK, and T.

◆ operator/() [2/2]

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

Definition at line 2024 of file vector.h.

References a, ALIGN, BCHK, MIN_ALIGN, norm(), T, and Vector().

◆ operator<()

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

Definition at line 1613 of file vector.h.

References Vector().

◆ operator<=()

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

Definition at line 1611 of file vector.h.

References BVector< T >::operator<=(), and Vector().

◆ operator=() [1/4]

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

Definition at line 1587 of file vector.h.

References a, TVector< T >::operator=(), T, and Vector().

◆ operator=() [2/4]

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

Definition at line 1592 of file vector.h.

References HOT, TVector< T >::operator=(), ts, and Vector().

◆ operator=() [3/4]

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

Definition at line 1594 of file vector.h.

References HOT, TVector< T >::operator=(), TVector< T >::TVector(), and Vector().

◆ operator=() [4/4]

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.

References HOT, TVector< T >::operator=(), and Vector().

◆ operator==() [1/3]

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

◆ operator==() [2/3]

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

Definition at line 1608 of file vector.h.

References TVector< T >::TVector().

◆ operator==() [3/3]

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

Definition at line 1603 of file vector.h.

References BVector< T >::BVector, BVector< T >::operator==(), and Vector().

◆ operator>()

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

Definition at line 1614 of file vector.h.

References Vector().

◆ operator>=()

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

Definition at line 1612 of file vector.h.

References BVector< T >::operator>=(), and Vector().

◆ operator[]() [1/2]

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

Definition at line 1571 of file vector.h.

References i, operator()(), and T.

◆ operator[]() [2/2]

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.

References i, and operator()().

◆ slice()

template<typename T>
TVector< T > Vector< T >::slice ( unsigned long i0,
unsigned long i1 ) const
inline

◆ sum()

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

◆ vec_info()

template<typename T>
const char * Vector< T >::vec_info ( )
inlinestatic

Definition at line 1655 of file vector.h.

◆ FGD

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

References dot(), HOT, T, and Vector().

◆ TSVector< T >

template<typename T>
friend class TSVector< T >
friend

Definition at line 1532 of file vector.h.


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