4 #ifndef ROOT_Math_SVector_icc 5 #define ROOT_Math_SVector_icc 34 #ifndef ROOT_Math_SVector 35 #error "Do not use SVector.icc directly. #include \"Math/SVector.h\" instead." 36 #endif // ROOT_Math_SVector 52 template <
class T,
unsigned int D>
54 for(
unsigned int i=0; i<D; ++i)
58 template <
class T,
unsigned int D>
64 template <
class T,
unsigned int D>
66 for(
unsigned int i=0; i<D; ++i)
77 template <
class T,
unsigned int D>
78 template <
class InputIterator>
80 assert(begin + D == end);
81 std::copy(begin, end, fArray);
84 template <
class T,
unsigned int D>
85 template <
class InputIterator>
88 std::copy(begin, begin+size, fArray);
93 template <
class T,
unsigned int D>
100 for(
unsigned int i=0; i<D; ++i)
104 template <
class T,
unsigned int D>
106 assert(ibegin + D == iend);
107 std::copy(ibegin, iend, fArray);
114 template <
class T,
unsigned int D>
120 template <
class T,
unsigned int D>
123 fArray[0] = a1; fArray[1] = a2;
126 template <
class T,
unsigned int D>
129 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3;
132 template <
class T,
unsigned int D>
135 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
138 template <
class T,
unsigned int D>
142 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
146 template <
class T,
unsigned int D>
148 const T& a5,
const T& a6) {
150 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
151 fArray[4] = a5; fArray[5] = a6;
154 template <
class T,
unsigned int D>
156 const T& a5,
const T& a6,
const T& a7) {
158 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
159 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7;
162 template <
class T,
unsigned int D>
164 const T& a5,
const T& a6,
const T& a7,
const T& a8) {
166 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
167 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7; fArray[7] = a8;
170 template <
class T,
unsigned int D>
172 const T& a5,
const T& a6,
const T& a7,
const T& a8,
175 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
176 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7; fArray[7] = a8;
180 template <
class T,
unsigned int D>
182 const T& a5,
const T& a6,
const T& a7,
const T& a8,
183 const T& a9,
const T& a10) {
185 fArray[0] = a1; fArray[1] = a2; fArray[2] = a3; fArray[3] = a4;
186 fArray[4] = a5; fArray[5] = a6; fArray[6] = a7; fArray[7] = a8;
187 fArray[8] = a9; fArray[9] = a10;
193 template <
class T,
unsigned int D>
201 template <
class T,
unsigned int D>
205 for(
unsigned int i=0; i<D; ++i) {
206 fArray[i] = rhs.
apply(i);
212 for(
unsigned int i=0; i<D; ++i) {
213 tmp[i] = rhs.
apply(i);
215 for(
unsigned int i=0; i<D; ++i) {
225 template <
class T,
unsigned int D>
228 for(
unsigned int i=0; i<D; ++i) {
229 rc = rc && (fArray[i] == rhs);
234 template <
class T,
unsigned int D>
237 for(
unsigned int i=0; i<D; ++i) {
238 rc = rc && (fArray[i] == rhs.
apply(i));
243 template <
class T,
unsigned int D>
247 for(
unsigned int i=0; i<D; ++i) {
248 rc = rc && (fArray[i] == rhs.
apply(i));
256 template <
class T,
unsigned int D>
261 template <
class T,
unsigned int D>
266 template <
class T,
unsigned int D>
275 template <
class T,
unsigned int D>
278 for(
unsigned int i=0; i<D; ++i) {
279 rc = rc && (fArray[i] > rhs);
284 template <
class T,
unsigned int D>
287 for(
unsigned int i=0; i<D; ++i) {
288 rc = rc && (fArray[i] > rhs.
apply(i));
293 template <
class T,
unsigned int D>
297 for(
unsigned int i=0; i<D; ++i) {
298 rc = rc && (fArray[i] > rhs.
apply(i));
306 template <
class T,
unsigned int D>
309 for(
unsigned int i=0; i<D; ++i) {
310 rc = rc && (fArray[i] < rhs);
315 template <
class T,
unsigned int D>
318 for(
unsigned int i=0; i<D; ++i) {
319 rc = rc && (fArray[i] < rhs.
apply(i));
324 template <
class T,
unsigned int D>
328 for(
unsigned int i=0; i<D; ++i) {
329 rc = rc && (fArray[i] < rhs.
apply(i));
338 template <
class T,
unsigned int D>
344 template <
class T,
unsigned int D>
351 template <
class T,
unsigned int D>
358 template <
class T,
unsigned int D>
366 template <
class T,
unsigned int D>
368 for(
unsigned int i=0; i<D; ++i) {
374 template <
class T,
unsigned int D>
376 for(
unsigned int i=0; i<D; ++i) {
377 fArray[i] += rhs.
apply(i);
383 template <
class T,
unsigned int D>
386 for(
unsigned int i=0; i<D; ++i) {
387 fArray[i] += rhs.
apply(i);
395 template <
class T,
unsigned int D>
397 for(
unsigned int i=0; i<D; ++i) {
403 template <
class T,
unsigned int D>
405 for(
unsigned int i=0; i<D; ++i) {
406 fArray[i] -= rhs.
apply(i);
411 template <
class T,
unsigned int D>
414 for(
unsigned int i=0; i<D; ++i) {
415 fArray[i] -= rhs.
apply(i);
423 template <
class T,
unsigned int D>
425 for(
unsigned int i=0; i<D; ++i) {
431 template <
class T,
unsigned int D>
434 for(
unsigned int i=0; i<D; ++i) {
435 fArray[i] *= rhs.
apply(i);
443 template <
class T,
unsigned int D>
445 for(
unsigned int i=0; i<D; ++i) {
446 fArray[i] /= rhs.
apply(i);
451 template <
class T,
unsigned int D>
454 for(
unsigned int i=0; i<D; ++i) {
455 fArray[i] /= rhs.
apply(i);
460 template <
class T,
unsigned int D>
462 for(
unsigned int i=0; i<D; ++i) {
472 template <
class T,
unsigned int D>
474 const T len =
Mag(*
this);
475 for(
unsigned int i=0; i<D; ++i) {
484 template <
class T,
unsigned int D>
485 template <
unsigned int D2>
491 for(
unsigned int i=row, j=0; j<D2; ++i,++j)
492 fArray[i] = rhs.
apply(j);
501 template <
class T,
unsigned int D>
502 template <
class A,
unsigned int D2>
507 for(
unsigned int i=row, j=0; j<D2; ++i,++j)
508 fArray[i] = rhs.
apply(j);
516 template <
class T,
unsigned int D>
518 const std::ios_base::fmtflags prevFmt = os.setf(std::ios::right,std::ios::adjustfield);
521 for (
unsigned int i = 0; i < D; ++i ) {
523 if (i != D-1) os <<
", ";
525 if (prevFmt != os.flags() ) os.setf(prevFmt, std::ios::adjustfield);
532 template <
class T,
unsigned int D>
535 template <
class T,
unsigned int D>
538 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>
557 template <
class T,
unsigned int D>
558 template <
class InputIterator>
561 assert( ibegin + D == iend);
562 std::copy(ibegin, iend, fArray);
565 template <
class T,
unsigned int D>
566 template <
class InputIterator>
570 std::copy(ibegin, ibegin+size, fArray);
577 template <
class T,
unsigned int D>
580 template <
class T,
unsigned int D>
583 template <
class T,
unsigned int D>
586 template <
class T,
unsigned int D>
591 template <
class T,
unsigned int D>
597 template <
class T,
unsigned int D>
606 template <
class T,
unsigned int D>
607 template <
class SubVector>
617 tmp[i] = fArray[i+row];
623 template <
class T,
unsigned int D>
632 template <
class T,
unsigned int D>
633 inline std::ostream& operator<<(std::ostream& os, const SVector<T,D>& rhs) {
634 return rhs.Print(os);
const T & operator[](unsigned int i) const
read-only access of vector elements. Index starts from 0.
Namespace for new ROOT classes and functions.
const T * Array() const
return read-only pointer to internal array
SVector< T, D > & operator-=(const T &rhs)
self subtraction with a scalar
std::ostream & Print(std::ostream &os) const
used by operator<<()
T Mag(const SVector< T, D > &rhs)
Vector magnitude (Euclidian norm) Compute : .
const T & At(unsigned int i) const
read-only access of vector elements with check on index. Index starts from 0.
#define STATIC_CHECK(expr, msg)
SVector< T, D > & operator/=(const T &rhs)
self division with a scalar
iterator begin()
STL iterator interface.
SVector< T, D > & operator=(const T &a1)
assignment from a scalar (only for size 1 vector)
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
bool IsInUse(const T *p) const
function to determine if any use operand is being used (has same memory adress)
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...
T apply(unsigned int i) const
access the parse tree. Index starts from zero
bool operator>(const T &rhs) const
element wise comparison
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.
Binding & operator=(OUT(*fun)(void))
Expression wrapper class for Vector objects.
Bool_t operator==(const TDatime &d1, const TDatime &d2)
bool operator==(const T &rhs) const
element wise comparison
bool operator<(const T &rhs) const
element wise comparison
SVector< T, D > & Unit()
transform vector into a vector of length 1
bool operator!=(const T &rhs) const
element wise comparison
iterator end()
STL iterator interface.
SVector< T, D > & operator+=(const T &rhs)
self addition with a scalar
bool IsInUse(const T *p) const
Function to check if a vector is sharing same memory location of the passed pointer This function is ...
const T & operator()(unsigned int i) const
read-only access of vector elements. Index starts from 0.
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.
T apply(unsigned int i) const