20 for (CompMap::const_iterator it = v2.begin(); it != v2.end(); ++it) {
22 out[nuc] += it->second;
29 for (CompMap::const_iterator it = v2.begin(); it != v2.end(); ++it) {
31 out[nuc] -= it->second;
37 std::vector<double> vec;
38 vec.reserve(v.size());
39 for (CompMap::const_iterator it = v.begin(); it != v.end(); ++it) {
40 vec.push_back(it->second);
48 ss <<
"The threshold cannot be negative. The value provided was '" 53 CompMap::iterator it = v->begin();
54 while (it != v->end()) {
55 if (std::abs(it->second) <= threshold) {
65 if (sum != val && sum != 0) {
66 double mult = val / sum;
67 for (CompMap::iterator it = v->begin(); it != v->end(); ++it) {
74 CompMap::const_iterator it;
75 for (it = v.begin(); it != v.end(); ++it) {
84 CompMap::const_iterator it;
85 for (it = v.begin(); it != v.end(); ++it) {
100 std::stringstream ss;
101 ss <<
"The threshold cannot be negative. The value provided was '" 102 << threshold <<
"'.";
106 if (v1.size() != v2.size()) {
108 }
else if (v1.empty() && v2.empty()) {
115 CompMap::iterator it;
116 for (it = n1.begin(); it != n1.end(); ++it) {
118 if (n2.count(nuc) == 0) {
121 double minuend = n2[nuc];
122 double subtrahend = n1[nuc];
123 double diff = minuend - subtrahend;
124 if (std::abs(minuend) == 0 || std::abs(subtrahend) == 0) {
125 if (std::abs(diff) > std::abs(diff)*threshold) {
128 }
else if (std::abs(diff) > std::abs(minuend)*threshold ||
129 std::abs(diff) > std::abs(subtrahend)*threshold) {
bool AllPositive(const CompMap &v)
Returns true if all nuclides in v have quantities greater than or equal to zero.
CompMap Sub(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result...
bool isnuclide(std::string nuc)
For values that are too big, too small, etc.
bool ValidNucs(const CompMap &v)
Returns true if all nuclide keys in v are valid.
bool AlmostEq(const CompMap &v1, const CompMap &v2, double threshold)
Returns true if all nuclides of v1 and v2 are the same within threshold.
double Sum(const CompMap &v)
Sums the quantities of all nuclides without normalization.
std::map< Nuc, double > CompMap
a raw definition of nuclides and corresponding (dimensionless quantities).
CompMap Add(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result...
static double KahanSum(std::vector< double > input)
sums the materials in the vector in an intelligent way, to avoid floating point issues.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Declares the CycArithmetic class, which holds arithmetic algorithms.
void Normalize(CompMap *v, double val)
The sum of quantities of all nuclides of v is normalized to val.
void ApplyThreshold(CompMap *v, double threshold)
All nuclides with quantities below threshold will have their quantity set to zero.