ROOT  6.06/09
Reference Guide
List of all members
ROOT::Math::SVector< T, D > Class Template Reference

template<class T, unsigned int D>
class ROOT::Math::SVector< T, D >

SVector: a generic fixed size Vector class.

The class is template on the scalar type and on the vector size D. See SVector Class Properties

Original author is Thorsten Glebe HERA-B Collaboration, MPI Heidelberg (Germany)

Authors
T. Glebe, L. Moneta and J. Palacios

Definition at line 31 of file BinaryOperators.h.

Public Types

--- Typedefs ---
typedef T value_type
 contained scalar type More...
 
typedef T * iterator
 STL iterator interface. More...
 
typedef const T * const_iterator
 STL const_iterator interface. More...
 

Public Member Functions

--- Constructors ---
 SVector ()
 Default constructor: vector filled with zero values. More...
 
template<class A >
 SVector (const VecExpr< A, T, D > &rhs)
 contruct from a vector expression More...
 
 SVector (const SVector< T, D > &rhs)
 copy contructor More...
 
 SVector (const T *a, unsigned int len)
 fill from array with len must be equal to D! More...
 
 SVector (const_iterator begin, const_iterator end)
 fill from a SVector iterator of type T* (for ambiguities iterator cannot be generic ) More...
 
 SVector (const T &a1)
 construct a vector of size 1 from a single scalar value More...
 
 SVector (const T &a1, const T &a2)
 construct a vector of size 2 from 2 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3)
 construct a vector of size 3 from 3 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4)
 construct a vector of size 4 from 4 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4, const T &a5)
 construct a vector of size 5 from 5 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6)
 construct a vector of size 6 from 6 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7)
 construct a vector of size 7 from 7 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8)
 construct a vector of size 8 from 8 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9)
 construct a vector of size 9 from 9 scalar values More...
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10)
 construct a vector of size 10 from 10 scalar values More...
 
SVector< T, D > & operator= (const T &a1)
 assignment from a scalar (only for size 1 vector) More...
 
template<class A >
SVector< T, D > & operator= (const VecExpr< A, T, D > &rhs)
 assignment from Vector Expression More...
 
--- STL-like interface ---
iterator begin ()
 STL iterator interface. More...
 
iterator end ()
 STL iterator interface. More...
 
const_iterator begin () const
 STL const_iterator interface. More...
 
const_iterator end () const
 STL const_iterator interface. More...
 
template<class InputIterator >
void SetElements (InputIterator begin, InputIterator end)
 set vector elements copying the values iterator size must match vector size More...
 
template<class InputIterator >
void SetElements (InputIterator begin, unsigned int size)
 set vector elements copying the values size must be <= vector size More...
 
--- Operators ---
bool operator== (const T &rhs) const
 element wise comparison More...
 
bool operator!= (const T &rhs) const
 element wise comparison More...
 
bool operator== (const SVector< T, D > &rhs) const
 element wise comparison More...
 
bool operator!= (const SVector< T, D > &rhs) const
 element wise comparison More...
 
template<class A >
bool operator== (const VecExpr< A, T, D > &rhs) const
 element wise comparison More...
 
template<class A >
bool operator!= (const VecExpr< A, T, D > &rhs) const
 element wise comparison More...
 
bool operator> (const T &rhs) const
 element wise comparison More...
 
bool operator< (const T &rhs) const
 element wise comparison More...
 
bool operator> (const SVector< T, D > &rhs) const
 element wise comparison More...
 
bool operator< (const SVector< T, D > &rhs) const
 element wise comparison More...
 
template<class A >
bool operator> (const VecExpr< A, T, D > &rhs) const
 element wise comparison More...
 
template<class A >
bool operator< (const VecExpr< A, T, D > &rhs) const
 element wise comparison More...
 
const T & operator[] (unsigned int i) const
 read-only access of vector elements. Index starts from 0. More...
 
const T & operator() (unsigned int i) const
 read-only access of vector elements. Index starts from 0. More...
 
const T & At (unsigned int i) const
 read-only access of vector elements with check on index. Index starts from 0. More...
 
T & operator[] (unsigned int i)
 read/write access of vector elements. Index starts from 0. More...
 
T & operator() (unsigned int i)
 read/write access of vector elements. Index starts from 0. More...
 
T & At (unsigned int i)
 read/write access of vector elements with check on index. Index starts from 0. More...
 
SVector< T, D > & operator+= (const T &rhs)
 self addition with a scalar More...
 
SVector< T, D > & operator-= (const T &rhs)
 self subtraction with a scalar More...
 
SVector< T, D > & operator*= (const T &rhs)
 self multiplication with a scalar More...
 
SVector< T, D > & operator/= (const T &rhs)
 self division with a scalar More...
 
SVector< T, D > & operator+= (const SVector< T, D > &rhs)
 self addition with another vector More...
 
SVector< T, D > & operator-= (const SVector< T, D > &rhs)
 self subtraction with another vector More...
 
template<class A >
SVector< T, D > & operator+= (const VecExpr< A, T, D > &rhs)
 self addition with a vector expression More...
 
template<class A >
SVector< T, D > & operator-= (const VecExpr< A, T, D > &rhs)
 self subtraction with a vector expression More...
 
--- Expert functions ---
SVector< T, D > & Unit ()
 transform vector into a vector of length 1 More...
 
template<unsigned int D2>
SVector< T, D > & Place_at (const SVector< T, D2 > &rhs, unsigned int row)
 place a sub-vector starting from the given position More...
 
template<class A , unsigned int D2>
SVector< T, D > & Place_at (const VecExpr< A, T, D2 > &rhs, unsigned int row)
 place a sub-vector expression starting from the given position More...
 
template<class SubVector >
SubVector Sub (unsigned int row) const
 return a subvector of size N starting at the value row where N is the size of the returned vector (SubVector::kSize) Condition row+N <= D More...
 
bool IsInUse (const T *p) const
 Function to check if a vector is sharing same memory location of the passed pointer This function is used by the expression templates to avoid the alias problem during expression evaluation. More...
 
std::ostream & Print (std::ostream &os) const
 used by operator<<() More...
 

Private Attributes

--- Data member ---
fArray [D]
 SVector data. More...
 

--- Access functions ---

enum  { kSize = D }
 Enumeration defining the Vector size. More...
 
apply (unsigned int i) const
 access the parse tree. Index starts from zero More...
 
const T * Array () const
 return read-only pointer to internal array More...
 
T * Array ()
 return non-const pointer to internal array More...
 
static unsigned int Dim ()
 return dimension $D$ More...
 

#include <Math/BinaryOperators.h>

+ Collaboration diagram for ROOT::Math::SVector< T, D >:

Member Typedef Documentation

template<class T, unsigned int D>
typedef const T* ROOT::Math::SVector< T, D >::const_iterator

STL const_iterator interface.

Definition at line 89 of file SVector.h.

template<class T, unsigned int D>
typedef T* ROOT::Math::SVector< T, D >::iterator

STL iterator interface.

Definition at line 86 of file SVector.h.

template<class T, unsigned int D>
typedef T ROOT::Math::SVector< T, D >::value_type

contained scalar type

Definition at line 83 of file SVector.h.

Constructor & Destructor Documentation

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( )

Default constructor: vector filled with zero values.

Definition at line 50 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
ROOT::Math::SVector< T, D >::SVector ( const VecExpr< A, T, D > &  rhs)

contruct from a vector expression

Definition at line 57 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const SVector< T, D > &  rhs)

copy contructor

Definition at line 62 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T *  a,
unsigned int  len 
)

fill from array with len must be equal to D!

Definition at line 94 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const_iterator  begin,
const_iterator  end 
)

fill from a SVector iterator of type T* (for ambiguities iterator cannot be generic )

Definition at line 102 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1)
explicit

construct a vector of size 1 from a single scalar value

Definition at line 112 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2 
)

construct a vector of size 2 from 2 scalar values

Definition at line 118 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3 
)

construct a vector of size 3 from 3 scalar values

Definition at line 124 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4 
)

construct a vector of size 4 from 4 scalar values

Definition at line 130 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5 
)

construct a vector of size 5 from 5 scalar values

Definition at line 136 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5,
const T &  a6 
)

construct a vector of size 6 from 6 scalar values

Definition at line 144 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5,
const T &  a6,
const T &  a7 
)

construct a vector of size 7 from 7 scalar values

Definition at line 152 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5,
const T &  a6,
const T &  a7,
const T &  a8 
)

construct a vector of size 8 from 8 scalar values

Definition at line 160 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5,
const T &  a6,
const T &  a7,
const T &  a8,
const T &  a9 
)

construct a vector of size 9 from 9 scalar values

Definition at line 168 of file SVector.icc.

template<class T , unsigned int D>
ROOT::Math::SVector< T, D >::SVector ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5,
const T &  a6,
const T &  a7,
const T &  a8,
const T &  a9,
const T &  a10 
)

construct a vector of size 10 from 10 scalar values

Definition at line 178 of file SVector.icc.

Member Function Documentation

template<class T , unsigned int D>
const T & ROOT::Math::SVector< T, D >::At ( unsigned int  i) const
inline

read-only access of vector elements with check on index. Index starts from 0.

Definition at line 589 of file SVector.icc.

template<class T , unsigned int D>
T & ROOT::Math::SVector< T, D >::At ( unsigned int  i)
inline

read/write access of vector elements with check on index. Index starts from 0.

Definition at line 595 of file SVector.icc.

template<class T , unsigned int D>
T * ROOT::Math::SVector< T, D >::begin ( )
inline

STL iterator interface.

Definition at line 543 of file SVector.icc.

Referenced by ROOT::Math::Inverter< idim, n >::InvertBunchKaufman().

template<class T , unsigned int D>
const T * ROOT::Math::SVector< T, D >::begin ( ) const
inline

STL const_iterator interface.

Definition at line 546 of file SVector.icc.

template<class T , unsigned int D>
T * ROOT::Math::SVector< T, D >::end ( )
inline

STL iterator interface.

Definition at line 549 of file SVector.icc.

template<class T , unsigned int D>
const T * ROOT::Math::SVector< T, D >::end ( ) const
inline

STL const_iterator interface.

Definition at line 552 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::IsInUse ( const T *  p) const

Function to check if a vector is sharing same memory location of the passed pointer This function is used by the expression templates to avoid the alias problem during expression evaluation.

When the vector is in use, for example in operations like V = M * V, where M is a mtrix, a temporary object storing the intermediate result is automatically created when evaluating the expression.

Definition at line 621 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator!= ( const T &  rhs) const
inline

element wise comparison

Definition at line 254 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator!= ( const SVector< T, D > &  rhs) const
inline

element wise comparison

Definition at line 259 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
bool ROOT::Math::SVector< T, D >::operator!= ( const VecExpr< A, T, D > &  rhs) const
inline

element wise comparison

Definition at line 265 of file SVector.icc.

template<class T , unsigned int D>
const T & ROOT::Math::SVector< T, D >::operator() ( unsigned int  i) const
inline

read-only access of vector elements. Index starts from 0.

Definition at line 578 of file SVector.icc.

template<class T , unsigned int D>
T & ROOT::Math::SVector< T, D >::operator() ( unsigned int  i)
inline

read/write access of vector elements. Index starts from 0.

Definition at line 584 of file SVector.icc.

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::operator*= ( const T &  rhs)

self multiplication with a scalar

Definition at line 421 of file SVector.icc.

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::operator+= ( const T &  rhs)

self addition with a scalar

Definition at line 364 of file SVector.icc.

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::operator+= ( const SVector< T, D > &  rhs)

self addition with another vector

Definition at line 372 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
SVector< T, D > & ROOT::Math::SVector< T, D >::operator+= ( const VecExpr< A, T, D > &  rhs)

self addition with a vector expression

Definition at line 382 of file SVector.icc.

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::operator-= ( const T &  rhs)

self subtraction with a scalar

Definition at line 393 of file SVector.icc.

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::operator-= ( const SVector< T, D > &  rhs)

self subtraction with another vector

Definition at line 401 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
SVector< T, D > & ROOT::Math::SVector< T, D >::operator-= ( const VecExpr< A, T, D > &  rhs)

self subtraction with a vector expression

Definition at line 410 of file SVector.icc.

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::operator/= ( const T &  rhs)

self division with a scalar

Definition at line 458 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator< ( const T &  rhs) const

element wise comparison

Definition at line 304 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator< ( const SVector< T, D > &  rhs) const

element wise comparison

Definition at line 313 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
bool ROOT::Math::SVector< T, D >::operator< ( const VecExpr< A, T, D > &  rhs) const

element wise comparison

Definition at line 323 of file SVector.icc.

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::operator= ( const T &  a1)

assignment from a scalar (only for size 1 vector)

Definition at line 191 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
SVector< T, D > & ROOT::Math::SVector< T, D >::operator= ( const VecExpr< A, T, D > &  rhs)

assignment from Vector Expression

Definition at line 200 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator== ( const T &  rhs) const

element wise comparison

Definition at line 223 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator== ( const SVector< T, D > &  rhs) const

element wise comparison

Definition at line 232 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
bool ROOT::Math::SVector< T, D >::operator== ( const VecExpr< A, T, D > &  rhs) const

element wise comparison

Definition at line 242 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator> ( const T &  rhs) const

element wise comparison

Definition at line 273 of file SVector.icc.

template<class T , unsigned int D>
bool ROOT::Math::SVector< T, D >::operator> ( const SVector< T, D > &  rhs) const

element wise comparison

Definition at line 282 of file SVector.icc.

template<class T , unsigned int D>
template<class A >
bool ROOT::Math::SVector< T, D >::operator> ( const VecExpr< A, T, D > &  rhs) const

element wise comparison

Definition at line 292 of file SVector.icc.

template<class T , unsigned int D>
const T & ROOT::Math::SVector< T, D >::operator[] ( unsigned int  i) const
inline

read-only access of vector elements. Index starts from 0.

Definition at line 575 of file SVector.icc.

template<class T , unsigned int D>
T & ROOT::Math::SVector< T, D >::operator[] ( unsigned int  i)
inline

read/write access of vector elements. Index starts from 0.

Definition at line 581 of file SVector.icc.

template<class T , unsigned int D>
template<unsigned int D2>
SVector< T, D > & ROOT::Math::SVector< T, D >::Place_at ( const SVector< T, D2 > &  rhs,
unsigned int  row 
)

place a sub-vector starting from the given position

Definition at line 483 of file SVector.icc.

Referenced by test1(), and test8().

template<class T , unsigned int D>
template<class A, unsigned int D2>
SVector< T, D > & ROOT::Math::SVector< T, D >::Place_at ( const VecExpr< A, T, D2 > &  rhs,
unsigned int  row 
)

place a sub-vector expression starting from the given position

Definition at line 500 of file SVector.icc.

template<class T , unsigned int D>
std::ostream & ROOT::Math::SVector< T, D >::Print ( std::ostream &  os) const

used by operator<<()

Definition at line 514 of file SVector.icc.

template<class T , unsigned int D>
template<class InputIterator >
void ROOT::Math::SVector< T, D >::SetElements ( InputIterator  begin,
InputIterator  end 
)

set vector elements copying the values iterator size must match vector size

Definition at line 556 of file SVector.icc.

Referenced by test15().

template<class T , unsigned int D>
template<class InputIterator >
void ROOT::Math::SVector< T, D >::SetElements ( InputIterator  begin,
unsigned int  size 
)

set vector elements copying the values size must be <= vector size

Definition at line 564 of file SVector.icc.

template<class T , unsigned int D>
template<class SubVector >
SubVector ROOT::Math::SVector< T, D >::Sub ( unsigned int  row) const

return a subvector of size N starting at the value row where N is the size of the returned vector (SubVector::kSize) Condition row+N <= D

Definition at line 605 of file SVector.icc.

Referenced by test10().

template<class T , unsigned int D>
SVector< T, D > & ROOT::Math::SVector< T, D >::Unit ( )

transform vector into a vector of length 1

Definition at line 470 of file SVector.icc.

Member Data Documentation

template<class T, unsigned int D>
T ROOT::Math::SVector< T, D >::fArray[D]
private

SVector data.

Definition at line 337 of file SVector.h.

Referenced by ROOT::Math::SVector< T, D >::SVector().


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