The template ROOT::Math::SVector class has 2 template parameters which define, at compile time, its properties. These are:
- type of the contained elements, for example float or double.
- size of the vector.
Creating a Vector
The following constructors are available to create a vector:
- Default constructor for a zero vector (all elements equal to zero)
- Constructor (and assignment) from a vector expression, like v = p*q + w. Due to the expression template technique, no temporary objects are created in this operation.
- Construct a vector passing directly the elements. This is possible only for vector up to size 10.
- Constructor from an iterator copying the data referred by the iterator. It is possible to specify the begin and end of the iterator or the begin and the size. Note that for the Vector the iterator is not generic and must be of type T*, where T is the type of the contained elements.
Here are some examples on how to create a vector. In the following we assume that we are using the namespace ROOT::Math.
SVector<double,3>
v(1,2,3);
double a[9] = {1,2,3,4,5,6,7,8,9};
SVector<double,9>
v(
a,9);
Accessing and Setting Methods
The single vector elements can be set or retrieved using the operator[i] , operator(i) or the iterator interface. Notice that the index starts from zero and not from one as in FORTRAN. Also no check is performed on the passed index. Furthermore, all the matrix elements can be set also by using the ROOT::SVector::SetElements function passing a generic iterator. The elements can be accessed also by using the ROOT::Math::SVector::apply(i) function.
std::vector <double>
w(3);
v.SetElements(
w.begin(),
w.end());
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
In addition there are methods to place a sub-vector in a vector. If the size of the the sub-vector is larger than the vector size a static assert ( a compilation error) is produced.
For additional Vector functionality see the Matrix and Vector Operators and Functions page