Logo ROOT   6.18/05
Reference Guide
List of all members | 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 SVectorDoc

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

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

Definition at line 75 of file SVector.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...
 
SVector< T, D > & operator= (const SVector< T, D > &rhs)
 assignment from another 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/SVector.h>

Member Typedef Documentation

◆ const_iterator

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

STL const_iterator interface.

Definition at line 85 of file SVector.h.

◆ iterator

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

STL iterator interface.

Definition at line 82 of file SVector.h.

◆ value_type

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

contained scalar type

Definition at line 79 of file SVector.h.

Member Enumeration Documentation

◆ anonymous enum

template<class T , unsigned int D>
anonymous enum

Enumeration defining the Vector size.

Enumerator
kSize 

return vector size

Definition at line 172 of file SVector.h.

Constructor & Destructor Documentation

◆ SVector() [1/15]

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

Default constructor: vector filled with zero values.

Definition at line 53 of file SVector.icc.

◆ SVector() [2/15]

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 60 of file SVector.icc.

◆ SVector() [3/15]

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

copy contructor

Definition at line 65 of file SVector.icc.

◆ SVector() [4/15]

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 97 of file SVector.icc.

◆ SVector() [5/15]

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 105 of file SVector.icc.

◆ SVector() [6/15]

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 115 of file SVector.icc.

◆ SVector() [7/15]

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 121 of file SVector.icc.

◆ SVector() [8/15]

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 127 of file SVector.icc.

◆ SVector() [9/15]

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 133 of file SVector.icc.

◆ SVector() [10/15]

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 139 of file SVector.icc.

◆ SVector() [11/15]

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 147 of file SVector.icc.

◆ SVector() [12/15]

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 155 of file SVector.icc.

◆ SVector() [13/15]

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 163 of file SVector.icc.

◆ SVector() [14/15]

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 171 of file SVector.icc.

◆ SVector() [15/15]

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 181 of file SVector.icc.

Member Function Documentation

◆ apply()

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

access the parse tree. Index starts from zero

Definition at line 540 of file SVector.icc.

◆ Array() [1/2]

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

return non-const pointer to internal array

Definition at line 546 of file SVector.icc.

◆ Array() [2/2]

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

return read-only pointer to internal array

Definition at line 543 of file SVector.icc.

◆ At() [1/2]

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 605 of file SVector.icc.

◆ At() [2/2]

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 599 of file SVector.icc.

◆ begin() [1/2]

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

STL iterator interface.

Definition at line 553 of file SVector.icc.

◆ begin() [2/2]

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

STL const_iterator interface.

Definition at line 556 of file SVector.icc.

◆ Dim()

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

return dimension $D$

Definition at line 179 of file SVector.h.

◆ end() [1/2]

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

STL iterator interface.

Definition at line 559 of file SVector.icc.

◆ end() [2/2]

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

STL const_iterator interface.

Definition at line 562 of file SVector.icc.

◆ IsInUse()

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 631 of file SVector.icc.

◆ operator!=() [1/3]

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 269 of file SVector.icc.

◆ operator!=() [2/3]

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

element wise comparison

Definition at line 264 of file SVector.icc.

◆ operator!=() [3/3]

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 275 of file SVector.icc.

◆ operator()() [1/2]

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 594 of file SVector.icc.

◆ operator()() [2/2]

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 588 of file SVector.icc.

◆ operator*=()

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 431 of file SVector.icc.

◆ operator+=() [1/3]

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 382 of file SVector.icc.

◆ operator+=() [2/3]

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 374 of file SVector.icc.

◆ operator+=() [3/3]

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 392 of file SVector.icc.

◆ operator-=() [1/3]

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 411 of file SVector.icc.

◆ operator-=() [2/3]

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 403 of file SVector.icc.

◆ operator-=() [3/3]

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 420 of file SVector.icc.

◆ operator/=()

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 468 of file SVector.icc.

◆ operator<() [1/3]

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 323 of file SVector.icc.

◆ operator<() [2/3]

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

element wise comparison

Definition at line 314 of file SVector.icc.

◆ operator<() [3/3]

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 333 of file SVector.icc.

◆ operator=() [1/3]

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

assignment from another vector

Definition at line 202 of file SVector.icc.

◆ operator=() [2/3]

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 194 of file SVector.icc.

◆ operator=() [3/3]

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 210 of file SVector.icc.

◆ operator==() [1/3]

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 242 of file SVector.icc.

◆ operator==() [2/3]

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

element wise comparison

Definition at line 233 of file SVector.icc.

◆ operator==() [3/3]

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 252 of file SVector.icc.

◆ operator>() [1/3]

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 292 of file SVector.icc.

◆ operator>() [2/3]

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

element wise comparison

Definition at line 283 of file SVector.icc.

◆ operator>() [3/3]

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 302 of file SVector.icc.

◆ operator[]() [1/2]

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 591 of file SVector.icc.

◆ operator[]() [2/2]

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 585 of file SVector.icc.

◆ Place_at() [1/2]

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 493 of file SVector.icc.

◆ Place_at() [2/2]

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 510 of file SVector.icc.

◆ Print()

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

used by operator<<()

Definition at line 524 of file SVector.icc.

◆ SetElements() [1/2]

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 566 of file SVector.icc.

◆ SetElements() [2/2]

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 574 of file SVector.icc.

◆ Sub()

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 615 of file SVector.icc.

◆ Unit()

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 480 of file SVector.icc.

Member Data Documentation

◆ fArray

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

SVector data.

Definition at line 335 of file SVector.h.


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