/usr/include/root/Math/SVector.h is in libroot-math-smatrix-dev 5.34.14-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | // @(#)root/smatrix:$Id$
// Author: T. Glebe, L. Moneta, J. Palacios 2005
#ifndef ROOT_Math_SVector
#define ROOT_Math_SVector
/********************************************************************
//
// source:
//
// type: source code
//
// created: 16. Mar 2001
//
// author: Thorsten Glebe
// HERA-B Collaboration
// Max-Planck-Institut fuer Kernphysik
// Saupfercheckweg 1
// 69117 Heidelberg
// Germany
// E-mail: T.Glebe@mpi-hd.mpg.de
//
// Description: A fixed size Vector class
//
// changes:
// 16 Mar 2001 (TG) creation
// 21 Mar 2001 (TG) SVector::value_type added
// 21 Mar 2001 (TG) added operators +=, -=, *=, /=
// 26 Mar 2001 (TG) added place_at()
// 03 Apr 2001 (TG) Array() added
// 06 Apr 2001 (TG) CTORS added
// 07 Apr 2001 (TG) CTORS added
// 22 Aug 2001 (TG) CTOR(T*,len) added
// 04 Sep 2001 (TG) moved inlined functions to .icc file
// 14 Jan 2002 (TG) added operator==(), operator!=(), operator>(), operator<()
//
********************************************************************/
#ifndef ROOT_Math_MnConfig
#include "Math/MConfig.h"
#endif
#include <iosfwd>
// expression engine
#ifndef ROOT_Math_Expression
#include "Math/Expression.h"
#endif
namespace ROOT {
namespace Math {
// template <class T, unsigned int D, unsigned int D2> class MatRepStd;
// template <class A, class T, unsigned int D, unsigned int D2 = 1, class R = MatRepStd<T,D,D2> > class Expr;
//____________________________________________________________________________________________________________
/**
SVector: a generic fixed size Vector class.
The class is template on the scalar type and on the vector size D.
See \ref SVectorDoc
Original author is Thorsten Glebe
HERA-B Collaboration, MPI Heidelberg (Germany)
@ingroup SMatrixSVector
@authors T. Glebe, L. Moneta and J. Palacios
*/
//==============================================================================
// SVector
//==============================================================================
template <class T, unsigned int D>
class SVector {
public:
/** @name --- Typedefs --- */
/// contained scalar type
typedef T value_type;
/** STL iterator interface. */
typedef T* iterator;
/** STL const_iterator interface. */
typedef const T* const_iterator;
/** @name --- Constructors --- */
/**
Default constructor: vector filled with zero values
*/
SVector();
/// contruct from a vector expression
template <class A>
SVector(const VecExpr<A,T,D>& rhs);
/// copy contructor
SVector(const SVector<T,D>& rhs);
// new constructs using STL iterator interface
// skip - need to solve the ambiguities
#ifdef LATER
/**
Constructor with STL iterator interface. The data will be copied into the vector
The iterator size must be equal to the vector size
*/
template<class InputIterator>
explicit SVector(InputIterator begin, InputIterator end);
/**
Constructor with STL iterator interface. The data will be copied into the vector
The size must be <= vector size
*/
template<class InputIterator>
explicit SVector(InputIterator begin, unsigned int size);
#else
// if you use iterator this is not necessary
/// fill from array with len must be equal to D!
SVector( const T * a, unsigned int len);
/** fill from a SVector iterator of type T*
(for ambiguities iterator cannot be generic )
*/
SVector(const_iterator begin, const_iterator end);
#endif
/// construct a vector of size 1 from a single scalar value
explicit SVector(const T& a1);
/// construct a vector of size 2 from 2 scalar values
SVector(const T& a1, const T& a2);
/// construct a vector of size 3 from 3 scalar values
SVector(const T& a1, const T& a2, const T& a3);
/// construct a vector of size 4 from 4 scalar values
SVector(const T& a1, const T& a2, const T& a3, const T& a4);
/// construct a vector of size 5 from 5 scalar values
SVector(const T& a1, const T& a2, const T& a3, const T& a4,
const T& a5);
/// construct a vector of size 6 from 6 scalar values
SVector(const T& a1, const T& a2, const T& a3, const T& a4,
const T& a5, const T& a6);
/// construct a vector of size 7 from 7 scalar values
SVector(const T& a1, const T& a2, const T& a3, const T& a4,
const T& a5, const T& a6, const T& a7);
/// construct a vector of size 8 from 8 scalar values
SVector(const T& a1, const T& a2, const T& a3, const T& a4,
const T& a5, const T& a6, const T& a7, const T& a8);
/// construct a vector of size 9 from 9 scalar values
SVector(const T& a1, const T& a2, const T& a3, const T& a4,
const T& a5, const T& a6, const T& a7, const T& a8,
const T& a9);
/// construct a vector of size 10 from 10 scalar values
SVector(const T& a1, const T& a2, const T& a3, const T& a4,
const T& a5, const T& a6, const T& a7, const T& a8,
const T& a9, const T& a10);
/// assignment from a scalar (only for size 1 vector)
SVector<T,D>& operator=(const T& a1);
/// assignment from Vector Expression
template <class A>
SVector<T,D>& operator=(const VecExpr<A,T,D>& rhs);
/** @name --- Access functions --- */
/**
Enumeration defining the Vector size
*/
enum {
/// return vector size
kSize = D
};
/// return dimension $D$
inline static unsigned int Dim() { return D; }
/// access the parse tree. Index starts from zero
T apply(unsigned int i) const;
/// return read-only pointer to internal array
const T* Array() const;
/// return non-const pointer to internal array
T* Array();
/** @name --- STL-like interface --- */
/** STL iterator interface. */
iterator begin();
/** STL iterator interface. */
iterator end();
/** STL const_iterator interface. */
const_iterator begin() const;
/** STL const_iterator interface. */
const_iterator end() const;
/// set vector elements copying the values
/// iterator size must match vector size
template<class InputIterator>
void SetElements(InputIterator begin, InputIterator end);
/// set vector elements copying the values
/// size must be <= vector size
template<class InputIterator>
void SetElements(InputIterator begin, unsigned int size);
/** @name --- Operators --- */
/// element wise comparison
bool operator==(const T& rhs) const;
/// element wise comparison
bool operator!=(const T& rhs) const;
/// element wise comparison
bool operator==(const SVector<T,D>& rhs) const;
/// element wise comparison
bool operator!=(const SVector<T,D>& rhs) const;
/// element wise comparison
template <class A>
bool operator==(const VecExpr<A,T,D>& rhs) const;
/// element wise comparison
template <class A>
bool operator!=(const VecExpr<A,T,D>& rhs) const;
/// element wise comparison
bool operator>(const T& rhs) const;
/// element wise comparison
bool operator<(const T& rhs) const;
/// element wise comparison
bool operator>(const SVector<T,D>& rhs) const;
/// element wise comparison
bool operator<(const SVector<T,D>& rhs) const;
/// element wise comparison
template <class A>
bool operator>(const VecExpr<A,T,D>& rhs) const;
/// element wise comparison
template <class A>
bool operator<(const VecExpr<A,T,D>& rhs) const;
/// read-only access of vector elements. Index starts from 0.
const T& operator[](unsigned int i) const;
/// read-only access of vector elements. Index starts from 0.
const T& operator()(unsigned int i) const;
/// read-only access of vector elements with check on index. Index starts from 0.
const T& At(unsigned int i) const;
/// read/write access of vector elements. Index starts from 0.
T& operator[](unsigned int i);
/// read/write access of vector elements. Index starts from 0.
T& operator()(unsigned int i);
/// read/write access of vector elements with check on index. Index starts from 0.
T& At(unsigned int i);
/// self addition with a scalar
SVector<T,D>& operator+=(const T& rhs);
/// self subtraction with a scalar
SVector<T,D>& operator-=(const T& rhs);
/// self multiplication with a scalar
SVector<T,D>& operator*=(const T& rhs);
/// self division with a scalar
SVector<T,D>& operator/=(const T& rhs);
/// self addition with another vector
SVector<T,D>& operator+=(const SVector<T,D>& rhs);
/// self subtraction with another vector
SVector<T,D>& operator-=(const SVector<T,D>& rhs);
/// self addition with a vector expression
template <class A>
SVector<T,D>& operator+=(const VecExpr<A,T,D>& rhs);
/// self subtraction with a vector expression
template <class A>
SVector<T,D>& operator-=(const VecExpr<A,T,D>& rhs);
#ifdef OLD_IMPL
#ifndef __CINT__
/// self element-wise multiplication with another vector
SVector<T,D>& operator*=(const SVector<T,D>& rhs);
/// self element-wise division with another vector
SVector<T,D>& operator/=(const SVector<T,D>& rhs);
/// self element-wise multiplication with a vector expression
template <class A>
SVector<T,D>& operator*=(const VecExpr<A,T,D>& rhs);
/// self element-wise division with a vector expression
template <class A>
SVector<T,D>& operator/=(const VecExpr<A,T,D>& rhs);
#endif
#endif
/** @name --- Expert functions --- */
/// transform vector into a vector of length 1
SVector<T,D>& Unit();
/// place a sub-vector starting from the given position
template <unsigned int D2>
SVector<T,D>& Place_at(const SVector<T,D2>& rhs, unsigned int row);
/// place a sub-vector expression starting from the given position
template <class A, unsigned int D2>
SVector<T,D>& Place_at(const VecExpr<A,T,D2>& rhs, unsigned int row);
/**
return a subvector of size N starting at the value row
where N is the size of the returned vector (SubVector::kSize)
Condition row+N <= D
*/
template <class SubVector >
SubVector Sub(unsigned int row) const;
/// used by operator<<()
std::ostream& Print(std::ostream& os) const;
private:
/** @name --- Data member --- */
/// SVector data
T fArray[D];
}; // end of class SVector
//==============================================================================
// operator<<
//==============================================================================
template <class T, unsigned int D>
std::ostream& operator<<(std::ostream& os, const ROOT::Math::SVector<T,D>& rhs);
} // namespace Math
} // namespace ROOT
#ifndef __CINT__
// include implementation file
#ifndef ROOT_Math_SVector_icc
#include "Math/SVector.icc"
#endif
// include operators and functions
#ifndef ROOT_Math_UnaryOperators
#include "Math/UnaryOperators.h"
#endif
#ifndef ROOT_Math_BinaryOperators
#include "Math/BinaryOperators.h"
#endif
#ifndef ROOT_Math_MatrixFunctions
#include "Math/Functions.h"
#endif
#endif // __CINT__
#endif /* ROOT_Math_SVector */
|