Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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.

37  : m(0), rows(0), cols(0)
38 {
39 }
G4GDMLMatrix::G4GDMLMatrix ( size_t  rows0,
size_t  cols0 
)

Definition at line 41 of file G4GDMLReadDefine.cc.

References FatalException, and G4Exception().

42 {
43  if ((rows0==0) || (cols0==0))
44  {
45  G4Exception("G4GDMLMatrix::G4GDMLMatrix(r,c)", "InvalidSetup",
46  FatalException, "Zero indeces as arguments!?");
47  }
48  rows = rows0;
49  cols = cols0;
50  m = new G4double[rows*cols];
51 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
G4GDMLMatrix::G4GDMLMatrix ( const G4GDMLMatrix rhs)

Definition at line 53 of file G4GDMLReadDefine.cc.

54  : m(0), rows(0), cols(0)
55 {
56  if (rhs.m)
57  {
58  rows = rhs.rows;
59  cols = rhs.cols;
60  m = new G4double[rows*cols];
61  for (size_t i=0; i<rows*cols; i++) { m[i] = rhs.m[i]; }
62  }
63 }
double G4double
Definition: G4Types.hh:76
G4GDMLMatrix::~G4GDMLMatrix ( )

Definition at line 88 of file G4GDMLReadDefine.cc.

89 {
90  delete [] m;
91 }

Member Function Documentation

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

Definition at line 103 of file G4GDMLReadDefine.cc.

References test::c, FatalException, and G4Exception().

Referenced by G4GDMLReadMaterials::PropertyRead().

104 {
105  if (r>=rows || c>=cols)
106  {
107  G4Exception("G4GDMLMatrix::get()", "InvalidSetup",
108  FatalException, "Index out of range!");
109  }
110  return m[cols*r+c];
111 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
size_t G4GDMLMatrix::GetCols ( ) const

Definition at line 118 of file G4GDMLReadDefine.cc.

Referenced by G4GDMLReadMaterials::PropertyRead().

119 {
120  return cols;
121 }
size_t G4GDMLMatrix::GetRows ( ) const

Definition at line 113 of file G4GDMLReadDefine.cc.

Referenced by G4GDMLReadMaterials::PropertyRead().

114 {
115  return rows;
116 }
G4GDMLMatrix & G4GDMLMatrix::operator= ( const G4GDMLMatrix rhs)

Definition at line 65 of file G4GDMLReadDefine.cc.

66 {
67  // Check assignment to self
68  //
69  if (this == &rhs) { return *this; }
70 
71  // Copy data
72  //
73  rows = rhs.rows;
74  cols = rhs.cols;
75  if (rhs.m)
76  {
77  m = new G4double[rows*cols];
78  for (size_t i=0; i<rows*cols; i++) { m[i] = rhs.m[i]; }
79  }
80  else
81  {
82  m = 0;
83  }
84 
85  return *this;
86 }
double G4double
Definition: G4Types.hh:76
void G4GDMLMatrix::Set ( size_t  r,
size_t  c,
G4double  a 
)

Definition at line 93 of file G4GDMLReadDefine.cc.

References test::a, test::c, FatalException, and G4Exception().

Referenced by G4GDMLReadDefine::MatrixRead().

94 {
95  if (r>=rows || c>=cols)
96  {
97  G4Exception("G4GDMLMatrix::set()", "InvalidSetup",
98  FatalException, "Index out of range!");
99  }
100  m[cols*r+c] = a;
101 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

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