CLHEP  2.4.7.2
C++ Class Library for High Energy Physics
Vector.icc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // ---------------------------------------------------------------------------
3 //
4 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
5 //
6 
7 #include <cmath>
8 #include <stdlib.h>
9 
10 namespace CLHEP {
11 
12 // Swap two vectors without doing a full copy.
13 inline void swap(HepVector &v1,HepVector &v2) {
14  HepGenMatrix::swap(v1.m,v2.m);
15  HepGenMatrix::swap(v1.nrow,v2.nrow);
16 }
17 
18 inline HepVector::HepVector()
19  : m(0), nrow(0)
20 {}
21 
22 inline double HepVector::normsq() const {return dot((*this),(*this));}
23 inline double HepVector::norm() const {return sqrt(normsq());}
24 
25 inline double & HepVector::operator()(int row)
26 {
27 #ifdef MATRIX_BOUND_CHECK
28  if(row<1 || row>nrow)
29  error("Range error in HepVector::operator()");
30 #endif
31 
32  return *(m.begin()+row-1);
33 }
34 inline const double & HepVector::operator()(int row) const
35 {
36 #ifdef MATRIX_BOUND_CHECK
37  if(row<1 || row>nrow)
38  error("Range error in HepVector::operator()");
39 #endif
40 
41  return *(m.begin()+row-1);
42 }
43 inline double & HepVector::operator[](int row)
44 {
45 #ifdef MATRIX_BOUND_CHECK
46  if(row<0 || row>=nrow)
47  error("Range error in HepVector::operator[]");
48 #endif
49 
50  return *(m.begin()+row);
51 }
52 inline const double & HepVector::operator[](int row) const
53 {
54 #ifdef MATRIX_BOUND_CHECK
55  if(row<0 || row>=nrow)
56  error("Range error in HepVector::operator[]");
57 #endif
58 
59  return *(m.begin()+row);
60 }
61 
62 } // namespace CLHEP
63 
void swap(HepVector &v1, HepVector &v2)
Definition: Vector.icc:13
void swap(HepMatrix &hm1, HepMatrix &hm2)
Definition: Matrix.icc:69
std::complex< double > dot(const SphericalHarmonicCoefficientSet &a, const SphericalHarmonicCoefficientSet &b)