Geant4-11
Public Member Functions | Private Attributes
G4GDMLMatrix Class Reference

#include <G4GDMLReadDefine.hh>

Public Member Functions

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

Private Attributes

std::size_t cols = 0
 
G4doublem = nullptr
 
std::size_t rows = 0
 

Detailed Description

Definition at line 45 of file G4GDMLReadDefine.hh.

Constructor & Destructor Documentation

◆ G4GDMLMatrix() [1/3]

G4GDMLMatrix::G4GDMLMatrix ( )

Definition at line 37 of file G4GDMLReadDefine.cc.

38{
39}

◆ G4GDMLMatrix() [2/3]

G4GDMLMatrix::G4GDMLMatrix ( std::size_t  rows0,
std::size_t  cols0 
)

Definition at line 42 of file G4GDMLReadDefine.cc.

43{
44 if((rows0 == 0) || (cols0 == 0))
45 {
46 G4Exception("G4GDMLMatrix::G4GDMLMatrix(r,c)", "InvalidSetup",
47 FatalException, "Zero indices as arguments!?");
48 }
49 rows = rows0;
50 cols = cols0;
51 m = new G4double[rows * cols];
52}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83
std::size_t rows
std::size_t cols

References cols, FatalException, G4Exception(), m, and rows.

◆ G4GDMLMatrix() [3/3]

G4GDMLMatrix::G4GDMLMatrix ( const G4GDMLMatrix rhs)

Definition at line 55 of file G4GDMLReadDefine.cc.

56{
57 if(rhs.m)
58 {
59 rows = rhs.rows;
60 cols = rhs.cols;
61 m = new G4double[rows * cols];
62 for(std::size_t i = 0; i < rows * cols; ++i)
63 {
64 m[i] = rhs.m[i];
65 }
66 }
67}

References cols, m, and rows.

◆ ~G4GDMLMatrix()

G4GDMLMatrix::~G4GDMLMatrix ( )

Definition at line 100 of file G4GDMLReadDefine.cc.

101{
102 delete[] m;
103}

References m.

Member Function Documentation

◆ Get()

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

Definition at line 117 of file G4GDMLReadDefine.cc.

118{
119 if(r >= rows || c >= cols)
120 {
121 G4Exception("G4GDMLMatrix::get()", "InvalidSetup", FatalException,
122 "Index out of range!");
123 }
124 return m[cols * r + c];
125}

References cols, FatalException, G4Exception(), m, and rows.

Referenced by G4GDMLReadMaterials::PropertyRead(), and G4GDMLReadSolids::PropertyRead().

◆ GetCols()

std::size_t G4GDMLMatrix::GetCols ( ) const

Definition at line 134 of file G4GDMLReadDefine.cc.

135{
136 return cols;
137}

References cols.

Referenced by G4GDMLReadMaterials::PropertyRead(), and G4GDMLReadSolids::PropertyRead().

◆ GetRows()

std::size_t G4GDMLMatrix::GetRows ( ) const

Definition at line 128 of file G4GDMLReadDefine.cc.

129{
130 return rows;
131}

References rows.

Referenced by G4GDMLReadMaterials::PropertyRead(), and G4GDMLReadSolids::PropertyRead().

◆ operator=()

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

Definition at line 70 of file G4GDMLReadDefine.cc.

71{
72 // Check assignment to self
73 //
74 if(this == &rhs)
75 {
76 return *this;
77 }
78
79 // Copy data
80 //
81 rows = rhs.rows;
82 cols = rhs.cols;
83 if(rhs.m)
84 {
85 m = new G4double[rows * cols];
86 for(std::size_t i = 0; i < rows * cols; ++i)
87 {
88 m[i] = rhs.m[i];
89 }
90 }
91 else
92 {
93 m = nullptr;
94 }
95
96 return *this;
97}

References cols, m, and rows.

◆ Set()

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

Definition at line 106 of file G4GDMLReadDefine.cc.

107{
108 if(r >= rows || c >= cols)
109 {
110 G4Exception("G4GDMLMatrix::set()", "InvalidSetup", FatalException,
111 "Index out of range!");
112 }
113 m[cols * r + c] = a;
114}

References cols, FatalException, G4Exception(), m, and rows.

Referenced by G4GDMLReadDefine::MatrixRead().

Field Documentation

◆ cols

std::size_t G4GDMLMatrix::cols = 0
private

Definition at line 63 of file G4GDMLReadDefine.hh.

Referenced by G4GDMLMatrix(), Get(), GetCols(), operator=(), and Set().

◆ m

G4double* G4GDMLMatrix::m = nullptr
private

Definition at line 62 of file G4GDMLReadDefine.hh.

Referenced by G4GDMLMatrix(), Get(), operator=(), Set(), and ~G4GDMLMatrix().

◆ rows

std::size_t G4GDMLMatrix::rows = 0
private

Definition at line 63 of file G4GDMLReadDefine.hh.

Referenced by G4GDMLMatrix(), Get(), GetRows(), operator=(), and Set().


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