Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ThreeMat Class Reference

#include <G4ThreeMat.hh>

Public Member Functions

 G4ThreeMat ()
 
 G4ThreeMat (G4double a[3][3])
 
virtual ~G4ThreeMat ()
 
 G4ThreeMat (const G4ThreeMat &m)
 
G4ThreeMatoperator= (const G4ThreeMat &m)
 
G4int operator== (const G4ThreeMat &m) const
 
virtual const char * NameOf () const
 
virtual void PrintOn (std::ostream &os=G4cout) const
 
G4double Determinant () const
 

Friends

std::ostream & operator<< (std::ostream &os, const G4ThreeMat &m)
 

Detailed Description

Definition at line 45 of file G4ThreeMat.hh.

Constructor & Destructor Documentation

◆ G4ThreeMat() [1/3]

G4ThreeMat::G4ThreeMat ( )

Definition at line 38 of file G4ThreeMat.cc.

39{
40 // default (null) constructor
41 for ( G4int i = 0; i < 3 ; i++ )
42 {
43 row[i] = G4Vector3D( 0., 0., 0. );
44 column[i] = G4Vector3D( 0., 0., 0. );
45
46 for ( G4int j = 0; j < 3 ; j++ )
47 element[i][j] = 0.;
48 }
49}
int G4int
Definition: G4Types.hh:66
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35

◆ G4ThreeMat() [2/3]

G4ThreeMat::G4ThreeMat ( G4double  a[3][3])

Definition at line 52 of file G4ThreeMat.cc.

53{
54 // constructor to make matrix from array
55 for ( G4int i = 0; i < 3 ; i++ )
56 {
57 row[i] = G4Vector3D( a[i][0], a[i][1], a[i][2] );
58 column[i] = G4Vector3D( a[0][i], a[1][i], a[2][i] );
59
60 for ( G4int j = 0; j < 3 ; j++ )
61 element[i][j] = a[i][j];
62 }
63}

◆ ~G4ThreeMat()

G4ThreeMat::~G4ThreeMat ( )
virtual

Definition at line 66 of file G4ThreeMat.cc.

67{
68}

◆ G4ThreeMat() [3/3]

G4ThreeMat::G4ThreeMat ( const G4ThreeMat m)

Definition at line 71 of file G4ThreeMat.cc.

72{
73 // copy constructor
74 for ( G4int i = 0; i < 3 ; i++ )
75 {
76 row[i] = mat.row[i];
77 column[i] = mat.column[i];
78
79 for ( G4int j = 0; j < 3 ; j++ )
80 element[i][j] = mat.element[i][j];
81 }
82}

Member Function Documentation

◆ Determinant()

G4double G4ThreeMat::Determinant ( ) const

Definition at line 151 of file G4ThreeMat.cc.

152{
153 // Determinant of a three by three matrix
154 return element[0][0] * ( element[1][1] * element[2][2]
155 - element[2][1] * element[1][2] )
156 - element[0][1] * ( element[1][0] * element[2][2]
157 - element[2][0] * element[1][2] )
158 + element[0][2] * ( element[1][0] * element[2][1]
159 - element[2][0] * element[1][1] );
160}

◆ NameOf()

const char * G4ThreeMat::NameOf ( ) const
virtual

Definition at line 85 of file G4ThreeMat.cc.

86{
87 return "G4ThreeMat";
88}

◆ operator=()

G4ThreeMat & G4ThreeMat::operator= ( const G4ThreeMat m)

Definition at line 136 of file G4ThreeMat.cc.

137{
138 if (&mat == this) return *this;
139 for ( G4int i = 0; i < 3 ; i++ )
140 {
141 row[i] = mat.row[i];
142 column[i] = mat.column[i];
143
144 for ( G4int j = 0; j < 3 ; j++ )
145 element[i][j] = mat.element[i][j];
146 }
147 return *this;
148}

◆ operator==()

G4int G4ThreeMat::operator== ( const G4ThreeMat m) const

Definition at line 121 of file G4ThreeMat.cc.

122{
123 for ( G4int i = 0; i < 3 ; i++ )
124 {
125 for ( G4int j = 0; j < 3 ; j++ )
126 {
127 if ( element[i][j] != mat.element[i][j] )
128 return 0;
129 }
130 }
131
132 return 1;
133}

◆ PrintOn()

void G4ThreeMat::PrintOn ( std::ostream &  os = G4cout) const
virtual

Definition at line 100 of file G4ThreeMat.cc.

101{
102 // printing function using C++ std::ostream class
103 os << "[ " << element[0][0] << "\t"
104 << element[0][1] << "\t"
105 << element[0][2] << "\n "
106 << element[1][0] << "\t"
107 << element[1][1] << "\t"
108 << element[1][2] << "\n "
109 << element[2][0] << "\t"
110 << element[2][1] << "\t"
111 << element[2][2] << " ]\n";
112 /*
113 for ( G4int i = 0; i < 3; i++ ) {
114 os << "row [" << i << "] " << row[i] << "\n"
115 << "column[" << i << "] " << column[i] << "\n";
116 }
117 */
118}

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const G4ThreeMat m 
)
friend

Definition at line 91 of file G4ThreeMat.cc.

92{
93 // overwrite output operator << to Print out G4ThreeMat objects
94 // using the PrintOn function defined below
95 mat.PrintOn( os );
96 return os;
97}

The documentation for this class was generated from the following files: