Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma omp declare simd uniform(node, order)
- inline double lagrange(const int order, const int node, const double x)
- {
- /* Distance between nodes */
- const double offset = 2.0/(double)order;
- /*
- At the specified node, l(x) = 1, and at all others l(x) = 0
- Use the simple form:
- \prod_{m, m \neq j} (x - x_m)/(x_j - x_m)
- */
- double y = 1.0;
- const double xj = -1.0 + ((double)node * offset);
- for (int i = 0; i < order+1; i++)
- {
- const double xm = -1.0 + ((double)i * offset);
- if (i != node)
- {
- y *= (x - xm) / (xj - xm);
- }
- }
- return y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement