CYCLUS
cyc_arithmetic.h
Go to the documentation of this file.
1 /*! \file cyc_arithmetic.h
2  \brief Declares the CycArithmetic class, which holds arithmetic algorithms
3  \author Kathryn D. Huff
4  */
5 #ifndef CYCLUS_SRC_CYC_ARITHMETIC_H_
6 #define CYCLUS_SRC_CYC_ARITHMETIC_H_
7 
8 #include <algorithm>
9 #include <iostream>
10 #include <map>
11 #include <vector>
12 
13 namespace cyclus {
14 /// @brief CycArithmetic is a toolkit for arithmetic
16  public:
17  /// sums the materials in the vector in an intelligent way,
18  /// to avoid floating point issues.
19  /// @param input is the list of values to add to each other
20  /// @return is the sum of all the values in the input vector
21  static double KahanSum(std::vector<double> input);
22 
23  /// orders the vector from smallest value to largest value.
24  /// This helps for addition algorithms.
25  /// @param to_sort is the vector of values to sort
26  /// @returns a set sorted from smallest to largest
27  static std::vector<double> sort_ascending(std::vector<double> to_sort);
28 
29  /// Identical to sort_ascending(std::vector<double>) except it modifies the
30  /// sorts the vector in-place modifying the passed in argument directly.
31  static void sort_inplace_ascending(std::vector<double>& to_sort);
32 
33  /// orders the values in a map from smallest value to largest value.
34  /// This helps for addition algorithms.
35  /// @param to_sort is a map of values to sort (according to the value of the double)
36  /// @returns a set sorted from smallest to largest
37  static std::vector<double> sort_ascending(std::map<int, double> to_sort);
38 };
39 
40 } // namespace cyclus
41 
42 #endif // CYCLUS_SRC_CYC_ARITHMETIC_H_
CycArithmetic is a toolkit for arithmetic.
static std::vector< double > sort_ascending(std::vector< double > to_sort)
orders the vector from smallest value to largest value.
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.
Definition: agent.cc:14
static void sort_inplace_ascending(std::vector< double > &to_sort)
Identical to sort_ascending(std::vector<double>) except it modifies the sorts the vector in-place mod...