11 std::stringstream ss(params);
12 double slope, intercept;
13 ss >> slope >> intercept;
16 "Linear function created in the form y = m*x + b, with";
25 std::stringstream ss(params);
26 double constant, exponent, intercept;
27 ss >> constant >> exponent >> intercept;
30 "Exponential function created in the form y = a*exp(b*x) + c, with";
46 if (!params.empty()) {
47 throw Error(
"Piecewise Functions cannot be created with a list of parameters");
50 LOG(
LEV_DEBUG2,
"Funct") <<
"A piecewise function has been created: " 51 << function_->Print();
57 double starting_coord,
59 if (!function_->functions_.empty()) {
60 const PiecewiseFunction::PiecewiseFunctionInfo& last =
61 function_->functions_.back();
62 if (starting_coord <= last.xoffset) {
63 throw Error(
"Cannot append a function before the last registered function");
69 yoffset = function_->value(starting_coord) -
function->value(0);
72 function_->functions_.push_back(PiecewiseFunction::PiecewiseFunctionInfo(
73 function, starting_coord, yoffset));
77 std::map<std::string, BasicFunctionFactory::FunctionType>
78 BasicFunctionFactory::enum_names_ =
79 std::map<std::string, BasicFunctionFactory::FunctionType>();
83 if (enum_names_.empty()) {
84 enum_names_[
"lin"] = LIN;
85 enum_names_[
"linear"] = LIN;
86 enum_names_[
"exp"] = EXP;
87 enum_names_[
"exponential"] = EXP;
94 if (enum_names_.count(type) == 0) {
95 std::stringstream err(
"");
96 err << type <<
" is not a registered function type" 97 <<
" of the basic function factory.";
98 throw Error(err.str());
101 switch (enum_names_.at(type)) {
113 throw Error(
"Function type " + type +
" not yet supported.");
A generic mechanism to manually manage exceptions.
double slope(double x2, double y2, double x1, double y1)
Finds the slope of a line from the points (x1, y1) and (x2, y2).
Code providing rudimentary logging capability for the Cyclus core.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
#define LOG(level, prefix)
allows easy logging via the streaming operator similar to std::cout; this is the primary way to use t...