Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 75 of file SVector.h.

Public Types

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

Public Member Functions

— Constructors —
 SVector ()
 Default constructor: vector filled with zero values.
 
template<class A >
 SVector (const VecExpr< A, T, D > &rhs)
 construct from a vector expression
 
 SVector (const SVector< T, D > &rhs)
 copy constructor
 
 SVector (const T *a, unsigned int len)
 fill from array with len must be equal to D!
 
 SVector (const_iterator begin, const_iterator end)
 fill from a SVector iterator of type T* (for ambiguities iterator cannot be generic )
 
 SVector (const T &a1)
 construct a vector of size 1 from a single scalar value
 
 SVector (const T &a1, const T &a2)
 construct a vector of size 2 from 2 scalar values
 
 SVector (const T &a1, const T &a2, const T &a3)
 construct a vector of size 3 from 3 scalar values
 
 SVector (const T &a1, const T &a2, const T &a3, const T &a4)
 construct a vector of size 4 from 4 scalar values
 
 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
 
 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
 
 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
 
 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
 
 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
 
 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
 
SVector< T, D > & operator= (const T &a1)
 assignment from a scalar (only for size 1 vector)
 
SVector< T, D > & operator= (const SVector< T, D > &rhs)
 assignment from another vector
 
template<class A >
SVector< T, D > & operator= (const VecExpr< A, T, D > &rhs)
 assignment from Vector Expression
 
— STL-like interface —
iterator begin ()
 STL iterator interface.
 
iterator end ()
 STL iterator interface.
 
const_iterator begin () const
 STL const_iterator interface.
 
const_iterator end () const
 STL const_iterator interface.
 
template<class InputIterator >
void SetElements (InputIterator begin, InputIterator end)
 set vector elements copying the values iterator size must match vector size
 
template<class InputIterator >
void SetElements (InputIterator begin, unsigned int size)
 set vector elements copying the values size must be <= vector size
 
— Operators —
bool operator== (const T &rhs) const
 element wise comparison
 
bool operator!= (const T &rhs) const
 element wise comparison
 
bool operator== (const SVector< T, D > &rhs) const
 element wise comparison
 
bool operator!= (const SVector< T, D > &rhs) const
 element wise comparison
 
template<class A >
bool operator== (const VecExpr< A, T, D > &rhs) const
 element wise comparison
 
template<class A >
bool operator!= (const VecExpr< A, T, D > &rhs) const
 element wise comparison
 
bool operator> (const T &rhs) const
 element wise comparison
 
bool operator< (const T &rhs) const
 element wise comparison
 
bool operator> (const SVector< T, D > &rhs) const
 element wise comparison
 
bool operator< (const SVector< T, D > &rhs) const
 element wise comparison
 
template<class A >
bool operator> (const VecExpr< A, T, D > &rhs) const
 element wise comparison
 
template<class A >
bool operator< (const VecExpr< A, T, D > &rhs) const
 element wise comparison
 
const T & operator[] (unsigned int i) const
 read-only access of vector elements. Index starts from 0.
 
const T & operator() (unsigned int i) const
 read-only access of vector elements. Index starts from 0.
 
const T & At (unsigned int i) const
 read-only access of vector elements with check on index. Index starts from 0.
 
T & operator[] (unsigned int i)
 read/write access of vector elements. Index starts from 0.
 
T & operator() (unsigned int i)
 read/write access of vector elements. Index starts from 0.
 
T & At (unsigned int i)
 read/write access of vector elements with check on index. Index starts from 0.
 
SVector< T, D > & operator+= (const T &rhs)
 self addition with a scalar
 
SVector< T, D > & operator-= (const T &rhs)
 self subtraction with a scalar
 
SVector< T, D > & operator*= (const T &rhs)
 self multiplication with a scalar
 
SVector< T, D > & operator/= (const T &rhs)
 self division with a scalar
 
SVector< T, D > & operator+= (const SVector< T, D > &rhs)
 self addition with another vector
 
SVector< T, D > & operator-= (const SVector< T, D > &rhs)
 self subtraction with another vector
 
template<class A >
SVector< T, D > & operator+= (const VecExpr< A, T, D > &rhs)
 self addition with a vector expression
 
template<class A >
SVector< T, D > & operator-= (const VecExpr< A, T, D > &rhs)
 self subtraction with a vector expression
 
— Expert functions —
SVector< T, D > & Unit ()
 transform vector into a vector of length 1
 
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
 
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
 
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
 
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.
 
std::ostream & Print (std::ostream &os) const
 used by operator<<()
 

Private Attributes

— Data member —
fArray [D]
 SVector data.
 

— Access functions —

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

#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)

construct 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 constructor

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 94 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 102 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 112 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 118 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 124 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 130 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 136 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 144 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 152 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 160 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 168 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 178 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 537 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 543 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 540 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 602 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 596 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 550 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 553 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 556 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 559 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 628 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 266 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 261 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 272 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.

◆ 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 428 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 379 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 371 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 389 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 408 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 400 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 417 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 465 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 320 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 311 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 330 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 199 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 191 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 207 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 239 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 230 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 249 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 289 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 280 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 299 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 588 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 582 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 490 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 507 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 521 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 563 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 571 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 612 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 477 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 333 of file SVector.h.

  • math/smatrix/inc/Math/BinaryOperators.h
  • math/smatrix/inc/Math/SVector.h
  • math/smatrix/inc/Math/SVector.icc