CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
testSubscripts.cc File Reference
#include <assert.h>
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/LorentzVector.h"
#include "CLHEP/Vector/LorentzRotation.h"

Go to the source code of this file.

Classes

class  Rot3
 
class  Rot4
 

Typedefs

typedef Hep3Vector Vec3
 
typedef HepLorentzVector Vec4
 

Functions

int main ()
 

Typedef Documentation

◆ Vec3

typedef Hep3Vector Vec3

Definition at line 19 of file testSubscripts.cc.

◆ Vec4

Definition at line 20 of file testSubscripts.cc.

Function Documentation

◆ main()

int main ( )

Definition at line 46 of file testSubscripts.cc.

46 {
47
48 // Test ThreeVector subscripting
49
50 Vec3 V3;
51 const Vec3 ConstV3(1.,2.,3.);
52
53 V3[0] = ConstV3[0];
54 V3[1] = ConstV3[1];
55 V3[2] = ConstV3[2];
56 assert(V3 == ConstV3);
57
58 V3(0) = ConstV3(2);
59 V3(1) = ConstV3(1);
60 V3(2) = ConstV3(0);
61 assert(V3 == Hep3Vector(3.,2.,1.));
62
63 // Test LorentzVector subscripting
64
65 Vec4 V4;
66 const Vec4 ConstV4(1.,2.,3.,4);
67
68 V4[0] = ConstV4[0];
69 V4[1] = ConstV4[1];
70 V4[2] = ConstV4[2];
71 V4[3] = ConstV4[3];
72 assert(V4 == ConstV4);
73
74 V4(0) = ConstV4(3);
75 V4(1) = ConstV4(2);
76 V4(2) = ConstV4(1);
77 V4(3) = ConstV4(0);
78 assert(V4 == HepLorentzVector(4.,3.,2.,1.));
79
80 // Test Rotation subscripting
81
82 int i, j, k;
83 Rot3 R3;
84
85 R3.setMatrix(1.,2.,3.,4.,5.,6.,7.,8.,9.);
86
87 k = 1;
88 for(i=0; i<3; i++) {
89 for(j=0; j<3; j++) {
90 assert(R3(i,j) == double(k));
91 assert(R3[i][j] == double(k));
92 k++;
93 }
94 }
95
96 // Test LorentzRotation subscripting
97
98 Rot4 R4;
99 R4.setMatrix(1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.);
100
101 k = 1;
102 for(i=0; i<4; i++) {
103 for(j=0; j<4; j++) {
104 assert(R4(i,j) == double(k));
105 assert(R4[i][j] == double(k));
106 k++;
107 }
108 }
109
110 return 0;
111}
void setMatrix(double xx1, double xy1, double xz1, double yx1, double yy1, double yz1, double zx1, double zy1, double zz1)
void setMatrix(double xx1, double xy1, double xz1, double xt1, double yx1, double yy1, double yz1, double yt1, double zx1, double zy1, double zz1, double zt1, double tx1, double ty1, double tz1, double tt1)