9 vec_basic generate_fdiff_weights_vector(
const vec_basic &grid,
10 const unsigned max_deriv,
11 const RCP<const Basic> around)
29 const unsigned len_g = numeric_cast<unsigned>(grid.size());
30 const unsigned len_w = len_g * (max_deriv + 1);
31 RCP<const Basic> c1, c4, c5;
33 c4 =
sub(grid[0], around);
34 vec_basic weights(len_w);
36 for (
unsigned idx = 1; idx < len_w; ++idx)
38 for (
unsigned i = 1; i < len_g; ++i) {
39 const int mn = (i < max_deriv) ? i : max_deriv;
40 RCP<const Basic> c2 = one;
42 c4 =
sub(grid[i], around);
43 for (
unsigned j = 0; j < i; ++j) {
44 const RCP<const Basic> c3 =
sub(grid[i], grid[j]);
47 for (
int k = mn; k >= 1; --k) {
48 weights[i + k * len_g]
50 weights[i - 1 + (k - 1) * len_g]),
51 mul(c5, weights[i - 1 + k * len_g]))),
55 =
mul(minus_one,
div(
mul(c1,
mul(c5, weights[i - 1])), c2));
57 for (
int k = mn; k >= 1; --k) {
58 weights[j + k * len_g]
59 =
div(
sub(
mul(c4, weights[j + k * len_g]),
60 mul(
integer(k), weights[j + (k - 1) * len_g])),
63 weights[j] =
div(
mul(c4, weights[j]), c3);
Classes and functions relating to the binary operation of addition.
Main namespace for SymEngine package.
RCP< const Basic > div(const RCP< const Basic > &a, const RCP< const Basic > &b)
Division.
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.