FEDRA emulsion software from the OPERA Collaboration
VtVector.hh
Go to the documentation of this file.
1 #ifndef __VTVECTOR_HH
2 #define __VTVECTOR_HH
3 // *****************************************************************************
4 //
5 // source:
6 //
7 // type: source code
8 //
9 // created: 21. Aug 2000
10 //
11 // author: Thorsten Glebe
12 // HERA-B Collaboration
13 // Max-Planck-Institut fuer Kernphysik
14 // Saupfercheckweg 1
15 // 69117 Heidelberg
16 // Germany
17 // E-mail: T.Glebe@mpi-hd.mpg.de
18 //
19 // Description: vector class
20 //
21 // changes:
22 // 21 Aug 2000 (TG) creation
23 // 05 Sep 2000 (TG) mag(), mag2() added
24 // 11 Sep 2000 (TG) added documentation
25 // 14 Sep 2000 (TG) place_at() added
26 // 11 Okt 2000 (TG) added clear() member function
27 // 09 Mar 2001 (TG) unit(), operator*(double) added
28 // 08 Jan 2002 (TG) moved inline functions to VtVector.icc file
29 //
30 // *****************************************************************************
31 
32 #include <cmath>
33 #include <iosfwd>
34 #ifdef WIN32
35 # include "Rtypes.h"
36 #endif
37 
38 namespace MATRIX {
39  class VtVector; // to fake DOC++
40 
42  //============================================================================
43  // Class VtVector
44  //============================================================================
45  class VtVector {
46  public:
49  VtVector(const unsigned int size);
51  VtVector(double v1, double v2);
53  VtVector(double v1, double v2, double v3);
55  VtVector(double v1, double v2, double v3, double v4);
57  VtVector(double v1, double v2, double v3, double v4, double v5);
59  VtVector(double v1, double v2, double v3, double v4, double v5,
60  double v6);
62  VtVector(const VtVector& rhs);
64  ~VtVector();
65 
68  double operator[](unsigned int row) const;
70  double& operator[](const unsigned int row);
72  double operator()(unsigned int row) const;
74  double& operator()(const unsigned int row);
75 
77  const VtVector& operator= (const VtVector& rhs);
79  const VtVector& operator+=(const double rhs);
81  const VtVector& operator-=(const double rhs);
83  const VtVector& operator*=(const double rhs);
85  const VtVector& operator/=(const double rhs);
87  const VtVector& operator+=(const VtVector& rhs);
89  const VtVector& operator-=(const VtVector& rhs);
91  const VtVector operator+ (const VtVector& rhs) const;
93  const VtVector operator- (const VtVector& rhs) const;
95  const double operator* (const VtVector& rhs) const;
97  VtVector operator*(const double rhs) const;
98 
101  unsigned int size() const;
103  unsigned int nrow() const;
105  double mag2() const;
107  double mag() const;
109  VtVector unit() const;
110 
113  void print(std::ostream& os) const;
115  void place_at(const VtVector& rhs, const unsigned int row);
117  void copy(const VtVector& rhs, const unsigned int offset);
119  void clear(void);
120 
121  private:
122  unsigned int v_size; // no of rows
123  double* v; // data array
124 
125 #ifdef WIN32
126  ClassDef(VtVector,0)
127 #endif
128  };
129 
130  //==============================================================================
131  // operator <<
132  //==============================================================================
133  std::ostream& operator<< ( std::ostream& os, const VtVector& t );
134 
135 #include "VtVector.icc"
136 } // namespace MATRIX
137 #endif
TTree * t
Definition: check_shower.C:4
Definition: VtVector.hh:45
void print(std::ostream &os) const
called by cout
Definition: VtVector.C:264
unsigned int size() const
vector dimension
double mag() const
$\sqrt{\sum_i v_i^2}$ vector length
unsigned int nrow() const
vector dimension
double operator()(unsigned int row) const
const double operator*(const VtVector &rhs) const
$\vec{v} * \vec{w} = \sum_\mu v_\mu \cdot w_\mu$
Definition: VtVector.C:225
VtVector(const unsigned int size)
Definition: VtVector.C:39
const VtVector & operator*=(const double rhs)
$\vec{v} = (v_\mu \cdot \alpha)$
Definition: VtVector.C:171
const VtVector & operator+=(const double rhs)
$\vec{v} = (v_\mu + \alpha)$
Definition: VtVector.C:129
void copy(const VtVector &rhs, const unsigned int offset)
to be used if vector dimensions differ
Definition: VtVector.C:290
const VtVector operator+(const VtVector &rhs) const
$\vec{v} + \vec{w}$
Definition: VtVector.C:187
unsigned int v_size
Definition: VtVector.hh:122
void place_at(const VtVector &rhs, const unsigned int row)
copy a smaller vector at a certain place
Definition: VtVector.C:248
VtVector unit() const
return a unit vector
Definition: VtVector.C:307
void clear(void)
set vector elements to 0
Definition: VtVector.C:282
double * v
Definition: VtVector.hh:123
double & operator()(const unsigned int row)
double & operator[](const unsigned int row)
const VtVector & operator=(const VtVector &rhs)
$\vec{v} = \vec{w}$
Definition: VtVector.C:112
const VtVector operator-(const VtVector &rhs) const
$\vec{v} - \vec{w}$
Definition: VtVector.C:206
const VtVector & operator/=(const double rhs)
$\vec{v} = (v_\mu / \alpha)$
Definition: VtVector.C:179
double operator[](unsigned int row) const
const VtVector & operator-=(const double rhs)
$\vec{v} = (v_\mu - \alpha)$
Definition: VtVector.C:150
~VtVector()
Definition: VtVector.C:92
double mag2() const
$\sum_i v_i^2$
Definition: VtVector.C:102
Definition: CMatrix.C:43
std::ostream & operator<<(std::ostream &os, const VtMatrix &t)
Definition: VtMatrix.hh:189