4 #ifndef ROOT_Math_SVector_icc
5 #define ROOT_Math_SVector_icc
37 #ifndef ROOT_Math_StaticCheck
49 template <
class T,
unsigned int D>
51 for(
unsigned int i=0; i<D; ++i)
55 template <
class T,
unsigned int D>
61 template <
class T,
unsigned int D>
63 for(
unsigned int i=0; i<D; ++i)
74 template <
class T,
unsigned int D>
75 template <
class InputIterator>
78 std::copy(begin, end, fArray);
81 template <
class T,
unsigned int D>
82 template <
class InputIterator>
85 std::copy(begin, begin+size, fArray);
90 template <
class T,
unsigned int D>
97 for(
unsigned int i=0; i<D; ++i)
101 template <
class T,
unsigned int D>
103 assert(ibegin + D == iend);
104 std::copy(ibegin, iend, fArray);
111 template <
class T,
unsigned int D>
117 template <
class T,
unsigned int D>
120 fArray[0] = a1; fArray[1] = a2;
123 template <
class T,
unsigned int D>
126 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3;
129 template <
class T,
unsigned int D>
132 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
135 template <
class T,
unsigned int D>
139 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
143 template <
class T,
unsigned int D>
145 const T& a5,
const T& a6) {
147 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
148 fArray[4] = a5; fArray[5] = a6;
151 template <
class T,
unsigned int D>
153 const T& a5,
const T& a6,
const T& a7) {
155 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
156 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7;
159 template <
class T,
unsigned int D>
161 const T& a5,
const T& a6,
const T& a7,
const T& a8) {
163 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
164 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7; fArray[7] = a8;
167 template <
class T,
unsigned int D>
169 const T& a5,
const T& a6,
const T& a7,
const T& a8,
172 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
173 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7; fArray[7] = a8;
177 template <
class T,
unsigned int D>
179 const T& a5,
const T& a6,
const T& a7,
const T& a8,
180 const T& a9,
const T& a10) {
182 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
183 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7; fArray[7] = a8;
184 fArray[8] = a9; fArray[9] = a10;
190 template <
class T,
unsigned int D>
198 template <
class T,
unsigned int D>
202 for(
unsigned int i=0; i<D; ++i) {
203 fArray[i] = rhs.
apply(i);
209 for(
unsigned int i=0; i<D; ++i) {
210 tmp[i] = rhs.
apply(i);
212 for(
unsigned int i=0; i<D; ++i) {
222 template <
class T,
unsigned int D>
225 for(
unsigned int i=0; i<D; ++i) {
226 rc = rc && (fArray[i] == rhs);
231 template <
class T,
unsigned int D>
234 for(
unsigned int i=0; i<D; ++i) {
235 rc = rc && (fArray[i] == rhs.
apply(i));
240 template <
class T,
unsigned int D>
244 for(
unsigned int i=0; i<D; ++i) {
245 rc = rc && (fArray[i] == rhs.
apply(i));
253 template <
class T,
unsigned int D>
258 template <
class T,
unsigned int D>
263 template <
class T,
unsigned int D>
272 template <
class T,
unsigned int D>
275 for(
unsigned int i=0; i<D; ++i) {
276 rc = rc && (fArray[i] > rhs);
281 template <
class T,
unsigned int D>
284 for(
unsigned int i=0; i<D; ++i) {
285 rc = rc && (fArray[i] > rhs.
apply(i));
290 template <
class T,
unsigned int D>
294 for(
unsigned int i=0; i<D; ++i) {
295 rc = rc && (fArray[i] > rhs.
apply(i));
303 template <
class T,
unsigned int D>
306 for(
unsigned int i=0; i<D; ++i) {
307 rc = rc && (fArray[i] < rhs);
312 template <
class T,
unsigned int D>
315 for(
unsigned int i=0; i<D; ++i) {
316 rc = rc && (fArray[i] < rhs.
apply(i));
321 template <
class T,
unsigned int D>
325 for(
unsigned int i=0; i<D; ++i) {
326 rc = rc && (fArray[i] < rhs.
apply(i));
335 template <
class T,
unsigned int D>
341 template <
class T,
unsigned int D>
348 template <
class T,
unsigned int D>
355 template <
class T,
unsigned int D>
363 template <
class T,
unsigned int D>
365 for(
unsigned int i=0; i<D; ++i) {
371 template <
class T,
unsigned int D>
373 for(
unsigned int i=0; i<D; ++i) {
374 fArray[i] += rhs.
apply(i);
380 template <
class T,
unsigned int D>
383 for(
unsigned int i=0; i<D; ++i) {
384 fArray[i] += rhs.
apply(i);
392 template <
class T,
unsigned int D>
394 for(
unsigned int i=0; i<D; ++i) {
400 template <
class T,
unsigned int D>
402 for(
unsigned int i=0; i<D; ++i) {
403 fArray[i] -= rhs.
apply(i);
408 template <
class T,
unsigned int D>
411 for(
unsigned int i=0; i<D; ++i) {
412 fArray[i] -= rhs.
apply(i);
420 template <
class T,
unsigned int D>
422 for(
unsigned int i=0; i<D; ++i) {
428 template <
class T,
unsigned int D>
431 for(
unsigned int i=0; i<D; ++i) {
432 fArray[i] *= rhs.
apply(i);
440 template <
class T,
unsigned int D>
442 for(
unsigned int i=0; i<D; ++i) {
443 fArray[i] /= rhs.apply(i);
448 template <
class T,
unsigned int D>
451 for(
unsigned int i=0; i<D; ++i) {
452 fArray[i] /= rhs.apply(i);
457 template <
class T,
unsigned int D>
459 for(
unsigned int i=0; i<D; ++i) {
469 template <
class T,
unsigned int D>
471 const T len =
Mag(*
this);
472 for(
unsigned int i=0; i<D; ++i) {
481 template <
class T,
unsigned int D>
482 template <
unsigned int D2>
488 for(
unsigned int i=row, j=0; j<D2; ++i,++j)
489 fArray[i] = rhs.
apply(j);
498 template <
class T,
unsigned int D>
499 template <
class A,
unsigned int D2>
504 for(
unsigned int i=row, j=0; j<D2; ++i,++j)
505 fArray[i] = rhs.
apply(j);
513 template <
class T,
unsigned int D>
515 const std::ios_base::fmtflags prevFmt = os.setf(std::ios::right,std::ios::adjustfield);
518 for (
unsigned int i = 0; i < D; ++i ) {
520 if (i != D-1) os <<
", ";
522 if (prevFmt != os.flags() ) os.setf(prevFmt, std::ios::adjustfield);
529 template <
class T,
unsigned int D>
532 template <
class T,
unsigned int D>
535 template <
class T,
unsigned int D>
542 template <
class T,
unsigned int D>
545 template <
class T,
unsigned int D>
548 template <
class T,
unsigned int D>
551 template <
class T,
unsigned int D>
554 template <
class T,
unsigned int D>
555 template <
class InputIterator>
558 assert( ibegin + D == iend);
559 std::copy(ibegin, iend, fArray);
562 template <
class T,
unsigned int D>
563 template <
class InputIterator>
567 std::copy(ibegin, ibegin+size, fArray);
574 template <
class T,
unsigned int D>
577 template <
class T,
unsigned int D>
580 template <
class T,
unsigned int D>
583 template <
class T,
unsigned int D>
588 template <
class T,
unsigned int D>
594 template <
class T,
unsigned int D>
603 template <
class T,
unsigned int D>
604 template <
class SubVector>
614 tmp[i] = fArray[i+row];
620 template <
class T,
unsigned int D>
629 template <
class T,
unsigned int D>
630 inline std::ostream& operator<<(std::ostream& os, const SVector<T,D>& rhs) {
631 return rhs.Print(os);
bool operator==(const TKey &lhs, const TKey &rhs)
const T * Array() const
return read-only pointer to internal array
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 (Su...
std::ostream & Print(std::ostream &os) const
used by operator<<()
Namespace for new ROOT classes and functions.
bool operator!=(const T &rhs) const
element wise comparison
SVector< T, D > & operator-=(const T &rhs)
self subtraction with a scalar
T Mag(const SVector< T, D > &rhs)
Vector magnitude (Euclidian norm) Compute : .
#define STATIC_CHECK(expr, msg)
const T & At(unsigned int i) const
read-only access of vector elements with check on index. Index starts from 0.
T apply(unsigned int i) const
access the parse tree. Index starts from zero
SVector< T, D > & operator/=(const T &rhs)
self division with a scalar
bool operator<(const T &rhs) const
element wise comparison
iterator begin()
STL iterator interface.
SVector< T, D > & operator=(const T &a1)
assignment from a scalar (only for size 1 vector)
T apply(unsigned int i) const
const T * const_iterator
STL const_iterator interface.
void SetElements(InputIterator begin, InputIterator end)
set vector elements copying the values iterator size must match vector size
const T & operator[](unsigned int i) const
read-only access of vector elements. Index starts from 0.
bool IsInUse(const T *p) const
Function to check if a vector is sharing same memory location of the passed pointer This function is ...
bool IsInUse(const T *p) const
function to determine if any use operand is being used (has same memory adress)
SVector< T, D > & Place_at(const SVector< T, D2 > &rhs, unsigned int row)
place a sub-vector starting from the given position
Namespace for new Math classes and functions.
bool operator==(const T &rhs) const
element wise comparison
Binding & operator=(OUT(*fun)(void))
bool operator>(const T &rhs) const
element wise comparison
const T & operator()(unsigned int i) const
read-only access of vector elements. Index starts from 0.
Expression wrapper class for Vector objects.
SVector< T, D > & Unit()
transform vector into a vector of length 1
iterator end()
STL iterator interface.
SVector< T, D > & operator+=(const T &rhs)
self addition with a scalar
SVector< T, D > & operator*=(const T &rhs)
self multiplication with a scalar
SVector()
Default constructor: vector filled with zero values.
SVector: a generic fixed size Vector class.