1 \page SVectorDoc SVector
Class Properties
3 The
template ROOT::Math::SVector class has 2
template parameters which define, at compile time, its properties. These are:
5 *
type of the contained elements,
for example _float_ or
double.
10 The following constructors are available to create
a vector:
12 * Default constructor
for a zero vector (all elements
equal to zero)
13 * 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.
14 *
Construct a vector passing directly the elements. This is possible only
for vector up to size 10\.
15 * Constructor from an iterator copying the
data refered 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.
17 Here are some examples on how to create
a vector. In the following we assume that we are
using the
namespace ROOT::Math.
20 SVector>double,
N>
v;
_
21 SVector>double,3>
v(1,2,3);
_
22 double a[9] = {1,2,3,4,5,6,7,8,9};
_
23 SVector>double,9>
v(
a,9);
_
27 ### Accessing and Setting Methods
29 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.
34 *(
v.**begin**()+3) = 3;
_
36 std::vector <double>w(3);
37 v.SetElements(w.begin(),w.end());
41 x = *(
m.**begin**()+i);
_
45 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.
49 SVector>double,M> w;
_
51 v.**Place_at**(w,ioff);
53 w = v.Sub < SVector>double,M> > (ioff);
57 For additional Vector functionality see the \ref MatVecFunctions page
bool equal(double d1, double d2, double stol=10000)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
TCppObject_t Construct(TCppType_t type)
decltype(auto) constexpr apply(F &&f, Tuple &&t)
SVector: a generic fixed size Vector class.