19 std::string error =
"Error: Matrix-Vector dimensions are not compatible: " + \
20 boost::lexical_cast<std::string>(x_o.
NumRows()) + \
21 " rows vs " + boost::lexical_cast<std::string>(n) +
" nuclides.";
26 double alpha = MaxAbsDiag(A);
37 x_t = GetSolutionVector(B, x_o, alpha, t, tol);
43double UniformTaylor::MaxAbsDiag(
const Matrix& A) {
45 double a_ii = A(1, 1);
50 double max_a_ii = a_ii;
53 for (
int i = 2; i <= n; ++i) {
57 if (a_ii > max_a_ii) {
67 double alpha,
double t,
double tol) {
69 long double alpha_t =
alpha * t;
70 long double expat = exp(-alpha_t);
74 "Error: exp(-alpha * t) exceeds the range of a long double.";
75 error +=
"\nThe Uniform Taylor method cannot solve the matrix exponential.";
76 throw ValueError(error);
85 Vector C_next = expat * x_o;
90 int maxTerms = MaxNumTerms(alpha_t, tol);
94 for (
int k = 1; k < maxTerms; ++k) {
111int UniformTaylor::MaxNumTerms(
long double alpha_t,
double epsilon) {
112 long double nextTerm;
115 long double prevTerm = 1;
116 long double sumTerms = 1;
119 long double lowerBound = exp(alpha_t);
122 if (lowerBound == HUGE_VAL) {
124 "Error: exp(alpha * t) exceeds the range of a long double";
125 error +=
"\nThe Uniform Taylor method cannot solve the matrix exponential.";
126 throw ValueError(error);
129 lowerBound = lowerBound * (1 - epsilon);
133 bool stopSum =
false;
135 while (stopSum !=
true) {
137 if (sumTerms >= lowerBound) {
141 nextTerm = (alpha_t / p) * prevTerm;
145 sumTerms += nextTerm;
For values that are too big, too small, etc.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
struct pyne::alpha alpha
a struct matching the '/decay/alphas' table in nuc_data.h5.