Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ArrayOps Namespace Reference

Functions

template<class T >
void Set (G4int Elements, T *To, T Value)
 
template<class T >
void Copy (G4int Elements, T *To, T *From)
 
template<class T >
void Add (G4int Elements, T *To, T *A1, T *A2=nullptr)
 
template<class T >
void Add (G4int Elements, T *To, T A1, T *A2=NULL)
 
template<class T >
void Subtract (G4int Elements, T *To, T *Minuend, T *Subtrahend=NULL)
 
template<class T >
void Multiply (G4int Elements, T *To, T *M1, T *M2=nullptr)
 
template<class T >
void Multiply (G4int Elements, T *To, T M1, T *M2=NULL)
 
template<class T >
void Divide (G4int Elements, T *To, T *Numerator, T *Denominator=NULL)
 
template<class T >
void Divide (G4int Elements, T *To, T Numerator, T *Denominator=NULL)
 
template<class T >
void DeleteVectorOfPointers (std::vector< T > &Vector)
 

Detailed Description

G4ArrayOps is a namespace that provides template functions for performing basic arithmatic operations on any data type that is accessed with the [] operator.

Function Documentation

◆ Add() [1/2]

template<class T >
void G4ArrayOps::Add ( G4int Elements,
T * To,
T * A1,
T * A2 = nullptr )

Add two arrays together. If the second array is NULL then the 'To' array is used as if the function were the += operator.

Definition at line 71 of file G4ArrayOps.hh.

72{
73 if (A2 == nullptr) {
74 A2 = To;
75 }
76
77 for (G4int position = 0; position < Elements; position++) {
78 To[position] = A2[position] + A1[position];
79 }
80}
int G4int
Definition G4Types.hh:85

Referenced by G4FissionProductYieldDist::Renormalize(), and G4FissionProductYieldDist::SortProbability().

◆ Add() [2/2]

template<class T >
void G4ArrayOps::Add ( G4int Elements,
T * To,
T A1,
T * A2 = NULL )

Add a constant to an array. If the second array is NULL then the 'To' array is used as if the function were the += operator.

Definition at line 86 of file G4ArrayOps.hh.

87{
88 if (A2 == NULL) {
89 A2 = To;
90 }
91
92 for (G4int position = 0; position < Elements; position++) {
93 To[position] = A1 + A2[position];
94 }
95}

◆ Copy()

template<class T >
void G4ArrayOps::Copy ( G4int Elements,
T * To,
T * From )

◆ DeleteVectorOfPointers()

template<class T >
void G4ArrayOps::DeleteVectorOfPointers ( std::vector< T > & Vector)

Definition at line 175 of file G4ArrayOps.hh.

176{
177 for (unsigned int i = 0; i < Vector.size(); i++) {
178 delete Vector[i];
179 }
180
181 delete &Vector;
182}

Referenced by G4FissionProductYieldDist::G4GetFission().

◆ Divide() [1/2]

template<class T >
void G4ArrayOps::Divide ( G4int Elements,
T * To,
T * Numerator,
T * Denominator = NULL )

Divide an array by another. If the second array is NULL then the 'To' array is used as if the function were the /= operator.

Definition at line 147 of file G4ArrayOps.hh.

148{
149 if (Denominator == NULL) {
150 Denominator = Numerator;
151 Numerator = To;
152 }
153
154 for (G4int position = 0; position < Elements; position++) {
155 To[position] = Numerator[position] / Denominator[position];
156 }
157}

Referenced by G4FissionProductYieldDist::ReadProbabilities().

◆ Divide() [2/2]

template<class T >
void G4ArrayOps::Divide ( G4int Elements,
T * To,
T Numerator,
T * Denominator = NULL )

Divide a constant by an array. If the second array is NULL then the 'To' array is used as if the function were the /= operator.

Definition at line 163 of file G4ArrayOps.hh.

164{
165 if (Denominator == nullptr) {
166 Denominator = To;
167 }
168
169 for (G4int position = 0; position < Elements; position++) {
170 To[position] = Numerator / Denominator[position];
171 }
172}

◆ Multiply() [1/2]

template<class T >
void G4ArrayOps::Multiply ( G4int Elements,
T * To,
T * M1,
T * M2 = nullptr )

Multiply two arrays together. If the second array is NULL then the 'To' array is used as if the function were the *= operator.

Definition at line 117 of file G4ArrayOps.hh.

118{
119 if (M2 == nullptr) {
120 M2 = To;
121 }
122
123 for (G4int position = 0; position < Elements; position++) {
124 To[position] = M2[position] * M1[position];
125 }
126}

Referenced by G4FissionProductYieldDist::Renormalize().

◆ Multiply() [2/2]

template<class T >
void G4ArrayOps::Multiply ( G4int Elements,
T * To,
T M1,
T * M2 = NULL )

Multiply an array by a constant. If the second array is NULL then the 'To' array is used as if the function were the *= operator.

Definition at line 132 of file G4ArrayOps.hh.

133{
134 if (M2 == NULL) {
135 M2 = To;
136 }
137
138 for (G4int position = 0; position < Elements; position++) {
139 To[position] = M2[position] * M1;
140 }
141}

◆ Set()

template<class T >
void G4ArrayOps::Set ( G4int Elements,
T * To,
T Value )

Set's all the values in an array to a constant

Definition at line 51 of file G4ArrayOps.hh.

52{
53 for (G4int position = 0; position < Elements; position++) {
54 To[position] = Value;
55 }
56}

Referenced by G4FissionProductYieldDist::ReadProbabilities().

◆ Subtract()

template<class T >
void G4ArrayOps::Subtract ( G4int Elements,
T * To,
T * Minuend,
T * Subtrahend = NULL )

Subtract an array from another. If the second array is NULL then the 'To' array is used as if the function were the -= operator.

Definition at line 101 of file G4ArrayOps.hh.

102{
103 if (Subtrahend == NULL) {
104 Subtrahend = Minuend;
105 Minuend = To;
106 }
107
108 for (G4int position = 0; position < Elements; position++) {
109 To[position] = Minuend[position] - Subtrahend[position];
110 }
111}