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::G4ThreeMat (  ) 

Definition at line 38 of file G4ThreeMat.cc.

00039 {  
00040   //  default (null) constructor 
00041   for ( G4int i = 0; i < 3 ; i++ )
00042   {
00043     row[i]    = G4Vector3D( 0., 0., 0. );
00044     column[i] = G4Vector3D( 0., 0., 0. );
00045     
00046     for ( G4int j = 0; j < 3 ; j++ ) 
00047       element[i][j] = 0.;
00048   }
00049 }

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

Definition at line 52 of file G4ThreeMat.cc.

00053 {
00054   //  constructor to make matrix from array
00055   for ( G4int i = 0; i < 3 ; i++ )
00056   {
00057     row[i]    = G4Vector3D( a[i][0], a[i][1], a[i][2] );
00058     column[i] = G4Vector3D( a[0][i], a[1][i], a[2][i] );
00059     
00060     for ( G4int j = 0; j < 3 ; j++ ) 
00061       element[i][j] = a[i][j];
00062   }
00063 }

G4ThreeMat::~G4ThreeMat (  )  [virtual]

Definition at line 66 of file G4ThreeMat.cc.

00067 {
00068 }

G4ThreeMat::G4ThreeMat ( const G4ThreeMat m  ) 

Definition at line 71 of file G4ThreeMat.cc.

References column, element, and row.

00072 { 
00073   //  copy constructor
00074   for ( G4int i = 0; i < 3 ; i++ )
00075   {
00076     row[i]    = mat.row[i];
00077     column[i] = mat.column[i];
00078     
00079     for ( G4int j = 0; j < 3 ; j++ ) 
00080       element[i][j] = mat.element[i][j];
00081   }
00082 }


Member Function Documentation

G4double G4ThreeMat::Determinant (  )  const

Definition at line 151 of file G4ThreeMat.cc.

00152 { 
00153   //  Determinant of a three by three matrix
00154   return element[0][0] * ( element[1][1] * element[2][2]
00155                                     -  element[2][1] * element[1][2] )
00156     - element[0][1] * ( element[1][0] * element[2][2]
00157                         -  element[2][0] * element[1][2] )
00158     + element[0][2] * ( element[1][0] * element[2][1]
00159                         -  element[2][0] * element[1][1] );
00160 }

const char * G4ThreeMat::NameOf (  )  const [virtual]

Definition at line 85 of file G4ThreeMat.cc.

00086 {
00087   return "G4ThreeMat";
00088 }

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

Definition at line 136 of file G4ThreeMat.cc.

References column, element, and row.

00137 { 
00138   if (&mat == this) return *this;
00139   for ( G4int i = 0; i < 3 ; i++ )
00140   {
00141     row[i]    = mat.row[i];
00142     column[i] = mat.column[i];
00143 
00144     for ( G4int j = 0; j < 3 ; j++ ) 
00145       element[i][j] = mat.element[i][j];
00146   }
00147   return *this;
00148 }

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

Definition at line 121 of file G4ThreeMat.cc.

References element.

00122 {
00123   for ( G4int i = 0; i < 3 ; i++ ) 
00124   {
00125     for ( G4int j = 0; j < 3 ; j++ ) 
00126     {
00127       if ( element[i][j] != mat.element[i][j] )
00128         return 0;
00129     }
00130   }
00131 
00132   return 1;
00133 }

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

Definition at line 100 of file G4ThreeMat.cc.

Referenced by operator<<().

00101 {
00102   // printing function using C++ std::ostream class
00103   os << "[ " << element[0][0] << "\t" 
00104      << element[0][1] << "\t"
00105      << element[0][2] << "\n  "
00106      << element[1][0] << "\t"
00107      << element[1][1] << "\t"
00108      << element[1][2] << "\n  "
00109      << element[2][0] << "\t"
00110      << element[2][1] << "\t"
00111      << element[2][2] << " ]\n";
00112   /*
00113     for ( G4int i = 0; i < 3; i++ ) {
00114     os << "row   [" << i << "] " << row[i] << "\n"
00115     << "column[" << i << "] " << column[i] << "\n";
00116     }
00117     */
00118 }


Friends And Related Function Documentation

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

Definition at line 91 of file G4ThreeMat.cc.

00092 {
00093   // overwrite output operator << to Print out G4ThreeMat objects
00094   // using the PrintOn function defined below
00095   mat.PrintOn( os );
00096   return os;
00097 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:32 2013 for Geant4 by  doxygen 1.4.7