CYCLUS
comp_math.h
Go to the documentation of this file.
1 #ifndef CYCLUS_SRC_COMP_MATH_H_
2 #define CYCLUS_SRC_COMP_MATH_H_
3 
4 #include "composition.h"
5 
6 namespace cyclus {
7 
8 /// Contains functions for performing fundamental operations on CompMap's
9 namespace compmath {
10 
11 /// Does component-wise subtraction of the nuclide quantities of v1 and v2 and
12 /// returns the result. No normalization is done. Example:
13 ///
14 /// @code
15 /// CompMap v1;
16 /// v1[922350000] = 2.3;
17 /// v1[922380000] = 1.3;
18 /// CompMap v2;
19 /// v2[922350000] = 1.1;
20 /// v2[922380000] = 1.2;
21 /// CompMap v3 = compmath::Add(v1, v2):
22 /// // v3[922350000] == 3.4, v3[922380000] == 2.5
23 /// @endcode
24 ///
25 CompMap Add(const CompMap& v1, const CompMap& v2);
26 
27 /// Does component-wise subtraction of the nuclide quantities of v1 and v2 and
28 /// returns the result. No normalization is done.
29 CompMap Sub(const CompMap& v1, const CompMap& v2);
30 
31 /// Sums the quantities of all nuclides without normalization
32 double Sum(const CompMap& v1);
33 
34 /// All nuclides with quantities below threshold will have their quantity set to
35 /// zero.
36 void ApplyThreshold(CompMap* v, double threshold);
37 
38 /// The sum of quantities of all nuclides of v is normalized to val.
39 void Normalize(CompMap* v, double val = 1.0);
40 
41 /// Returns true if all nuclide keys in v are valid.
42 bool ValidNucs(const CompMap& v);
43 
44 /// Returns true if all nuclides in v have quantities greater than or equal to
45 /// zero.
46 bool AllPositive(const CompMap& v);
47 
48 /// Returns true if all nuclides of v1 and v2 are the same within threshold. No
49 /// normalization is performed.
50 bool AlmostEq(const CompMap& v1, const CompMap& v2, double threshold);
51 
52 } // namespace compmath
53 } // namespace cyclus
54 
55 #endif // CYCLUS_SRC_COMP_MATH_H_
bool AllPositive(const CompMap &v)
Returns true if all nuclides in v have quantities greater than or equal to zero.
Definition: comp_math.cc:83
CompMap Sub(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result...
Definition: comp_math.cc:27
bool ValidNucs(const CompMap &v)
Returns true if all nuclide keys in v are valid.
Definition: comp_math.cc:73
bool AlmostEq(const CompMap &v1, const CompMap &v2, double threshold)
Returns true if all nuclides of v1 and v2 are the same within threshold.
Definition: comp_math.cc:93
double Sum(const CompMap &v)
Sums the quantities of all nuclides without normalization.
Definition: comp_math.cc:36
std::map< Nuc, double > CompMap
a raw definition of nuclides and corresponding (dimensionless quantities).
Definition: composition.h:17
CompMap Add(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result...
Definition: comp_math.cc:18
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
void Normalize(CompMap *v, double val)
The sum of quantities of all nuclides of v is normalized to val.
Definition: comp_math.cc:63
void ApplyThreshold(CompMap *v, double threshold)
All nuclides with quantities below threshold will have their quantity set to zero.
Definition: comp_math.cc:45