CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
Matrix
CLHEP
Matrix
Matrix/CLHEP/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
&m2);
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
&m1,
const
HepVector
&m2);
147
friend
HepVector
operator*
(
const
HepDiagMatrix
&m1,
const
HepVector
&m2);
148
friend
HepMatrix
operator*
(
const
HepVector
&m1,
const
HepMatrix
&m2);
149
friend
HepVector
operator*
(
const
HepMatrix
&m1,
const
HepVector
&m2);
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
&m1,
const
HepVector
&m2);
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
&m1,
const
HepVector
&v2);
190
HepVector
operator+
(
const
HepVector
&v1,
const
HepMatrix
&m2);
191
HepVector
operator+
(
const
HepVector
&v1,
const
HepVector
&v2);
192
// Addition operators
193
194
HepVector
operator-
(
const
HepMatrix
&m1,
const
HepVector
&v2);
195
HepVector
operator-
(
const
HepVector
&v1,
const
HepMatrix
&m2);
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
Generated on Sun Jun 17 2012 08:08:28 for CLHEP by
1.8.1.1