G4GDMLMatrix Class Reference

#include <G4GDMLReadDefine.hh>


Public Member Functions

 G4GDMLMatrix ()
 G4GDMLMatrix (size_t rows0, size_t cols0)
 G4GDMLMatrix (const G4GDMLMatrix &rhs)
G4GDMLMatrixoperator= (const G4GDMLMatrix &rhs)
 ~G4GDMLMatrix ()
void Set (size_t r, size_t c, G4double a)
G4double Get (size_t r, size_t c) const
size_t GetRows () const
size_t GetCols () const


Detailed Description

Definition at line 47 of file G4GDMLReadDefine.hh.


Constructor & Destructor Documentation

G4GDMLMatrix::G4GDMLMatrix (  ) 

Definition at line 36 of file G4GDMLReadDefine.cc.

00037   : m(0), rows(0), cols(0)
00038 {
00039 }

G4GDMLMatrix::G4GDMLMatrix ( size_t  rows0,
size_t  cols0 
)

Definition at line 41 of file G4GDMLReadDefine.cc.

References FatalException, and G4Exception().

00042 {   
00043    if ((rows0==0) || (cols0==0))
00044    {
00045      G4Exception("G4GDMLMatrix::G4GDMLMatrix(r,c)", "InvalidSetup",
00046                  FatalException, "Zero indeces as arguments!?");
00047    }
00048    rows = rows0;
00049    cols = cols0;
00050    m = new G4double[rows*cols];
00051 }

G4GDMLMatrix::G4GDMLMatrix ( const G4GDMLMatrix rhs  ) 

Definition at line 53 of file G4GDMLReadDefine.cc.

References cols, m, and rows.

00054   : m(0), rows(0), cols(0)
00055 {
00056    if (rhs.m)
00057    {
00058      rows = rhs.rows;
00059      cols = rhs.cols;
00060      m = new G4double[rows*cols];
00061      for (size_t i=0; i<rows*cols; i++)  { m[i] = rhs.m[i]; }
00062    }
00063 }

G4GDMLMatrix::~G4GDMLMatrix (  ) 

Definition at line 88 of file G4GDMLReadDefine.cc.

00089 {
00090    delete [] m;
00091 }


Member Function Documentation

G4double G4GDMLMatrix::Get ( size_t  r,
size_t  c 
) const

Definition at line 103 of file G4GDMLReadDefine.cc.

References FatalException, and G4Exception().

Referenced by G4GDMLReadMaterials::PropertyRead().

00104 {   
00105    if (r>=rows || c>=cols)
00106    {
00107      G4Exception("G4GDMLMatrix::get()", "InvalidSetup",
00108                  FatalException, "Index out of range!");
00109    }
00110    return m[cols*r+c];
00111 }

size_t G4GDMLMatrix::GetCols (  )  const

Definition at line 118 of file G4GDMLReadDefine.cc.

Referenced by G4GDMLReadMaterials::PropertyRead().

00119 {
00120    return cols;
00121 }

size_t G4GDMLMatrix::GetRows (  )  const

Definition at line 113 of file G4GDMLReadDefine.cc.

Referenced by G4GDMLReadMaterials::PropertyRead().

00114 {
00115    return rows;
00116 }

G4GDMLMatrix & G4GDMLMatrix::operator= ( const G4GDMLMatrix rhs  ) 

Definition at line 65 of file G4GDMLReadDefine.cc.

References cols, m, and rows.

00066 {
00067    // Check assignment to self
00068    //
00069    if (this == &rhs)  { return *this; }
00070 
00071    // Copy data
00072    //
00073    rows = rhs.rows;
00074    cols = rhs.cols;
00075    if (rhs.m)
00076    {
00077      m = new G4double[rows*cols];
00078      for (size_t i=0; i<rows*cols; i++)  { m[i] = rhs.m[i]; }
00079    }
00080    else
00081    {
00082      m = 0;
00083    }
00084 
00085    return *this;
00086 }

void G4GDMLMatrix::Set ( size_t  r,
size_t  c,
G4double  a 
)

Definition at line 93 of file G4GDMLReadDefine.cc.

References FatalException, and G4Exception().

00094 {   
00095    if (r>=rows || c>=cols)
00096    {
00097      G4Exception("G4GDMLMatrix::set()", "InvalidSetup",
00098                  FatalException, "Index out of range!");
00099    }
00100    m[cols*r+c] = a;
00101 }


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