// SVector example of usage /** \page SVectorDoc SVector Class Properties The template ROOT::Math::SVector class has 2 template parameters which define, at compile time, its properties. These are:
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,N> v; // create a vector of size N, v[i]=0 SVector>double,3> v(1,2,3); // create a vector of size 3, v[0]=1,v[1]=2,v[2]=3 double a[9] = {1,2,3,4,5,6,7,8,9}; // input data SVector>double,9> v(a,9); // create a vector using the a[] data
v[0] = 1; // set the first element v(1) = 2; // set the second element *(v.begin()+3) = 3; // set the third element // set vector elements from a std::vectorIn 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.::iterator std::vectorw(3); v.SetElements(w.begin(),w.end()); double x = m(i); // return the i-th element x = m.apply(i); // return the i-th element x = *(m.begin()+i); // return the i-th element
SVector>double,N> v; SVector>double,M> w; // M <= N otherwise a compilation error is obtained later // place a vector of size M starting from element ioff, v[ioff + i] = w[i] v.Place_at(w,ioff); // return a sub-vector of size M starting from v[ioff]: w[i] = v[ioff + i] w = v.Sub < SVector>double,M> > (ioff);For additional Vector functionality see the \ref MatVecFunctions page */