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

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

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 77 of file G4ArrayOps.hh.

References position.

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

81  {
82  if(A2 == NULL)
83  {
84  A2 = To;
85  }
86 
87  for(G4int position = 0; position < Elements; position++)
88  {
89  To[position] = A2[position] + A1[position];
90  }
91  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7
template<class T >
void G4ArrayOps::Add ( G4int  Elements,
T *  To,
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 97 of file G4ArrayOps.hh.

References position.

101  {
102  if(A2 == NULL)
103  {
104  A2 = To;
105  }
106 
107  for(G4int position = 0; position < Elements; position++)
108  {
109  To[position] = A1 + A2[position];
110  }
111  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7
template<class T >
void G4ArrayOps::Copy ( G4int  Elements,
T *  To,
T *  From 
)

Copy values from one array to another

Definition at line 63 of file G4ArrayOps.hh.

References position.

Referenced by G4FissionProductYieldDist::ReadProbabilities(), G4FissionProductYieldDist::Renormalize(), G4ENDFYieldDataContainer::SetYieldError(), G4ENDFYieldDataContainer::SetYieldProbability(), and G4FissionProductYieldDist::SortProbability().

66  {
67  for(G4int position = 0; position < Elements; position++)
68  {
69  To[position] = From[position];
70  }
71  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7
template<class T >
void G4ArrayOps::DeleteVectorOfPointers ( std::vector< T > &  Vector)

Definition at line 216 of file G4ArrayOps.hh.

Referenced by G4FissionProductYieldDist::G4GetFission().

217  {
218  for(unsigned int i = 0; i < Vector.size(); i++)
219  {
220  delete Vector[i];
221  }
222 
223  delete &Vector;
224  }
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 178 of file G4ArrayOps.hh.

References position.

Referenced by G4FissionProductYieldDist::ReadProbabilities().

182  {
183  if(Denominator == NULL)
184  {
185  Denominator = Numerator;
186  Numerator = To;
187  }
188 
189  for(G4int position = 0; position < Elements; position++)
190  {
191  To[position] = Numerator[position] / Denominator[position];
192  }
193  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7
template<class T >
void G4ArrayOps::Divide ( G4int  Elements,
T *  To,
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 199 of file G4ArrayOps.hh.

References position.

203  {
204  if(Denominator == NULL)
205  {
206  Denominator = To;
207  }
208 
209  for(G4int position = 0; position < Elements; position++)
210  {
211  To[position] = Numerator / Denominator[position];
212  }
213  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7
template<class T >
void G4ArrayOps::Multiply ( G4int  Elements,
T *  To,
T *  M1,
T *  M2 = NULL 
)

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 138 of file G4ArrayOps.hh.

References position.

Referenced by G4FissionProductYieldDist::Renormalize().

142  {
143  if(M2 == NULL)
144  {
145  M2 = To;
146  }
147 
148  for(G4int position = 0; position < Elements; position++)
149  {
150  To[position] = M2[position] * M1[position];
151  }
152  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7
template<class T >
void G4ArrayOps::Multiply ( G4int  Elements,
T *  To,
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 158 of file G4ArrayOps.hh.

References position.

162  {
163  if(M2 == NULL)
164  {
165  M2 = To;
166  }
167 
168  for(G4int position = 0; position < Elements; position++)
169  {
170  To[position] = M2[position] * M1;
171  }
172  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7
template<class T >
void G4ArrayOps::Set ( G4int  Elements,
T *  To,
Value 
)
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 117 of file G4ArrayOps.hh.

References position.

121  {
122  if(Subtrahend == NULL)
123  {
124  Subtrahend = Minuend;
125  Minuend = To;
126  }
127 
128  for(G4int position = 0; position < Elements; position++)
129  {
130  To[position] = Minuend[position] - Subtrahend[position];
131  }
132  }
int G4int
Definition: G4Types.hh:78
int position
Definition: filter.cc:7