CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Matrix/Matrix/Vector.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // CLASSDOC OFF
3 // ---------------------------------------------------------------------------
4 // CLASSDOC ON
5 //
6 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
7 //
8 // Although Vector and Matrix class are very much related, I like the typing
9 // information I get by making them different types. It is usually an error
10 // to use a Matrix where a Vector is expected, except in the case that the
11 // Matrix is a single column. But this case can be taken care of by using
12 // constructors as conversions. For this same reason, I don't want to make
13 // a Vector a derived class of Matrix.
14 //
15 
16 #ifndef _Vector_H_
17 #define _Vector_H_
18 
19 #ifdef GNUPRAGMA
20 #pragma interface
21 #endif
22 
23 #include "CLHEP/Matrix/defs.h"
24 #include "CLHEP/Matrix/GenMatrix.h"
25 
26 namespace CLHEP {
27 
28 class HepRandom;
29 
30 class HepMatrix;
31 class HepSymMatrix;
32 class HepDiagMatrix;
33 class Hep3Vector;
34 
39 class HepVector : public HepGenMatrix {
40 public:
41  inline HepVector();
42  // Default constructor. Gives vector of length 0.
43  // Another Vector can be assigned to it.
44 
45  explicit HepVector(int p);
46  HepVector(int p, int);
47  // Constructor. Gives vector of length p.
48 
49  HepVector(int p, HepRandom &r);
50 
51  HepVector(const HepVector &v);
52  HepVector(const HepMatrix &m);
53  // Copy constructors.
54  // Note that there is an assignment operator for v = Hep3Vector.
55 
56  virtual ~HepVector();
57  // Destructor.
58 
59  inline const double & operator()(int row) const;
60  inline double & operator()(int row);
61  // Read or write a matrix element.
62  // ** Note that the indexing starts from (1). **
63 
64  inline const double & operator[](int row) const;
65  inline double & operator[](int row);
66  // Read and write an element of a Vector.
67  // ** Note that the indexing starts from [0]. **
68 
69  virtual const double & operator()(int row, int col) const;
70  virtual double & operator()(int row, int col);
71  // Read or write a matrix element.
72  // ** Note that the indexing starts from (1,1). **
73  // Allows accessing Vector using GenMatrix
74 
75  HepVector & operator*=(double t);
76  // Multiply a Vector by a floating number.
77 
78  HepVector & operator/=(double t);
79  // Divide a Vector by a floating number.
80 
81  HepVector & operator+=( const HepMatrix &v2);
82  HepVector & operator+=( const HepVector &v2);
83  HepVector & operator-=( const HepMatrix &v2);
84  HepVector & operator-=( const HepVector &v2);
85  // Add or subtract a Vector.
86 
87  HepVector & operator=( const HepVector &hm2);
88  // Assignment operators.
89 
90  HepVector& operator=(const HepMatrix &);
91  HepVector& operator=(const Hep3Vector &);
92  // assignment operators from other classes.
93 
94  HepVector operator- () const;
95  // unary minus, ie. flip the sign of each element.
96 
97  HepVector apply(double (*f)(double, int)) const;
98  // Apply a function to all elements.
99 
100  HepVector sub(int min_row, int max_row) const;
101  // Returns a sub vector.
102  HepVector sub(int min_row, int max_row);
103  // SGI CC bug. I have to have both with/without const. I should not need
104  // one without const.
105 
106  void sub(int row, const HepVector &v1);
107  // Replaces a sub vector of a Vector with v1.
108 
109  inline double normsq() const;
110  // Returns norm squared.
111 
112  inline double norm() const;
113  // Returns norm.
114 
115  virtual int num_row() const;
116  // Returns number of rows.
117 
118  virtual int num_col() const;
119  // Number of columns. Always returns 1. Provided for compatibility with
120  // GenMatrix.
121 
122  HepMatrix T() const;
123  // Returns the transpose of a Vector. Note that the returning type is
124  // Matrix.
125 
126  friend inline void swap(HepVector &v1, HepVector &v2);
127  // Swaps two vectors.
128 
129 protected:
130  virtual int num_size() const;
131 
132 private:
133  virtual void invert(int&);
134  // produces an error. Demanded by GenMatrix
135 
136  friend class HepDiagMatrix;
137  friend class HepSymMatrix;
138  friend class HepMatrix;
139  // friend classes
140 
141  friend double dot(const HepVector &v1, const HepVector &v2);
142  // f = v1 * v2;
143 
144  friend HepVector operator+(const HepVector &v1, const HepVector &v2);
145  friend HepVector operator-(const HepVector &v1, const HepVector &v2);
146  friend HepVector operator*(const HepSymMatrix &hm1, const HepVector &hm2);
147  friend HepVector operator*(const HepDiagMatrix &hm1, const HepVector &hm2);
148  friend HepMatrix operator*(const HepVector &hm1, const HepMatrix &hm2);
149  friend HepVector operator*(const HepMatrix &hm1, const HepVector &hm2);
150 
151  friend HepVector solve(const HepMatrix &a, const HepVector &v);
152  friend void tridiagonal(HepSymMatrix *a,HepMatrix *hsm);
153  friend void row_house(HepMatrix *,const HepMatrix &, double, int, int,
154  int, int);
155  friend void row_house(HepMatrix *,const HepVector &, double, int, int);
156  friend void back_solve(const HepMatrix &R, HepVector *b);
157  friend void col_house(HepMatrix *,const HepMatrix &,double, int, int,
158  int, int);
159  friend HepVector house(const HepSymMatrix &a,int row,int col);
160  friend HepVector house(const HepMatrix &a,int row,int col);
161  friend void house_with_update(HepMatrix *a,int row,int col);
162  friend HepSymMatrix vT_times_v(const HepVector &v);
163  friend HepVector qr_solve(HepMatrix *, const HepVector &);
164 
165 #ifdef DISABLE_ALLOC
166  std::vector<double > m;
167 #else
168  std::vector<double,Alloc<double,25> > m;
169 #endif
170  int nrow;
171 };
172 
173 //
174 // Operations other than member functions
175 //
176 
177 std::ostream& operator<<(std::ostream &s, const HepVector &v);
178 // Write out Matrix, SymMatrix, DiagMatrix and Vector into ostream.
179 
180 HepVector operator*(const HepMatrix &hm1, const HepVector &hm2);
181 HepVector operator*(double t, const HepVector &v1);
182 HepVector operator*(const HepVector &v1, double t);
183 // Multiplication operators.
184 // Note that m *= x is always faster than m = m * x.
185 
186 HepVector operator/(const HepVector &v1, double t);
187 // Divide by a real number.
188 
189 HepVector operator+(const HepMatrix &hm1, const HepVector &v2);
190 HepVector operator+(const HepVector &v1, const HepMatrix &hm2);
191 HepVector operator+(const HepVector &v1, const HepVector &v2);
192 // Addition operators
193 
194 HepVector operator-(const HepMatrix &hm1, const HepVector &v2);
195 HepVector operator-(const HepVector &v1, const HepMatrix &hm2);
196 HepVector operator-(const HepVector &v1, const HepVector &v2);
197 // subtraction operators
198 
199 HepVector dsum(const HepVector &s1, const HepVector &s2);
200 // Direct sum of two vectors;
201 
202 } // namespace CLHEP
203 
204 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
205 // backwards compatibility will be enabled ONLY in CLHEP 1.9
206 using namespace CLHEP;
207 #endif
208 
209 #include "CLHEP/Matrix/Vector.icc"
210 
211 #endif
CLHEP::HepVector::house_with_update
friend void house_with_update(HepMatrix *a, int row, int col)
Definition: MatrixLinear.cc:393
a
@ a
Definition: testCategories.cc:125
CLHEP::HepVector::operator[]
const double & operator[](int row) const
b
@ b
Definition: testCategories.cc:125
CLHEP::HepVector::swap
friend void swap(HepVector &v1, HepVector &v2)
CLHEP::HepVector::house
friend HepVector house(const HepSymMatrix &a, int row, int col)
Definition: MatrixLinear.cc:350
CLHEP::HepVector::HepVector
HepVector()
CLHEP::HepVector::operator-
HepVector operator-() const
Definition: Vector.cc:213
CLHEP::HepVector::operator-=
HepVector & operator-=(const HepMatrix &v2)
Definition: Vector.cc:430
CLHEP::HepVector::operator=
HepVector & operator=(const HepVector &hm2)
Definition: Vector.cc:469
CLHEP::HepVector::HepSymMatrix
friend class HepSymMatrix
Definition: Matrix/CLHEP/Matrix/Vector.h:137
CLHEP::operator/
HepLorentzVector operator/(const HepLorentzVector &, double a)
Definition: LorentzVector.cc:162
CLHEP::HepVector::norm
double norm() const
CLHEP::HepVector::num_row
virtual int num_row() const
Definition: Vector.cc:117
CLHEP::HepVector::row_house
friend void row_house(HepMatrix *, const HepMatrix &, double, int, int, int, int)
Definition: MatrixLinear.cc:649
CLHEP::HepVector::dot
friend double dot(const HepVector &v1, const HepVector &v2)
Definition: Vector.cc:543
f
void f(void g())
Definition: excDblThrow.cc:38
CLHEP::HepVector::back_solve
friend void back_solve(const HepMatrix &R, HepVector *b)
Definition: MatrixLinear.cc:60
CLHEP
Definition: ClhepVersion.h:13
CLHEP::operator-
Hep3Vector operator-(const Hep3Vector &, const Hep3Vector &)
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition: keyMergeIssues.doc:324
Hep3Vector
Issues Concerning the PhysicsVectors CLHEP Vector Merge The merge of ZOOM PhysicsVdectors and the CLHEP Vector package is completed The purpose of this document is to list the major issues that affected the merge of these and where relevant describe the resolutions More detailed documents describe more minor issues General Approach As agreed at the June CLHEP the approach is to combine the features of each ZOOM class with the corresponding CLHEP class expanding the interface to create a single lingua franca of what a Hep3Vector(for example) means. We are not forming SpaceVector as an class derived from Hep3Vector and enhancing it in that way. Another rule imposed by the agreement is to avoid using the Exceptions package(even though that will later go into CLHEP for other uses). A desirable goal is to avoid cluttering the interface and enlarging the code linked in when ordinary CLHEP Vector functionallity is used. To this end
CLHEP::HepVector::operator()
const double & operator()(int row) const
CLHEP::HepVector::solve
friend HepVector solve(const HepMatrix &a, const HepVector &v)
Definition: Vector.cc:576
CLHEP::HepVector::operator+
friend HepVector operator+(const HepVector &v1, const HepVector &v2)
Definition: Vector.cc:256
CLHEP::HepVector::num_col
virtual int num_col() const
Definition: Vector.cc:119
CLHEP::HepVector::T
HepMatrix T() const
Definition: Vector.cc:531
CLHEP::HepVector::HepMatrix
friend class HepMatrix
Definition: Matrix/CLHEP/Matrix/Vector.h:138
CLHEP::HepVector::sub
HepVector sub(int min_row, int max_row) const
Definition: Vector.cc:151
CLHEP::HepVector::operator*
friend HepVector operator*(const HepSymMatrix &hm1, const HepVector &hm2)
Definition: SymMatrix.cc:510
CLHEP::HepVector::~HepVector
virtual ~HepVector()
Definition: Vector.cc:92
CLHEP::HepVector::num_size
virtual int num_size() const
Definition: Vector.cc:118
CLHEP::HepVector::operator+=
HepVector & operator+=(const HepMatrix &v2)
Definition: Vector.cc:409
CLHEP::operator+
Hep3Vector operator+(const Hep3Vector &, const Hep3Vector &)
CLHEP::HepVector::qr_solve
friend HepVector qr_solve(HepMatrix *, const HepVector &)
Definition: MatrixLinear.cc:707
CLHEP::HepVector::operator*=
HepVector & operator*=(double t)
Definition: Vector.cc:450
CLHEP::HepVector::tridiagonal
friend void tridiagonal(HepSymMatrix *a, HepMatrix *hsm)
Definition: MatrixLinear.cc:774
R
Application of Rotations and LorentzTransformations to containers of and as in Rotation R
Definition: keyMergeIssues.doc:333
CLHEP::HepVector::normsq
double normsq() const
CLHEP::operator<<
std::ostream & operator<<(std::ostream &os, const HepAxisAngle &aa)
Definition: AxisAngle.cc:86
CLHEP::HepVector::apply
HepVector apply(double(*f)(double, int)) const
Definition: Vector.cc:556
CLHEP::HepVector::HepDiagMatrix
friend class HepDiagMatrix
Definition: Matrix/CLHEP/Matrix/Vector.h:136
CLHEP::operator*
HepLorentzRotation operator*(const HepRotation &r, const HepLorentzRotation &lt)
Definition: LorentzRotation.cc:262
n_constructors::m
int m
Definition: testSharedPtr.cc:370
CLHEP::dsum
HepDiagMatrix dsum(const HepDiagMatrix &s1, const HepDiagMatrix &s2)
Definition: DiagMatrix.cc:164
CLHEP::HepVector::operator/=
HepVector & operator/=(double t)
Definition: Vector.cc:444
CLHEP::HepVector::vT_times_v
friend HepSymMatrix vT_times_v(const HepVector &v)
Definition: SymMatrix.cc:542
CLHEP::HepVector::col_house
friend void col_house(HepMatrix *, const HepMatrix &, double, int, int, int, int)
Definition: MatrixLinear.cc:151