1#ifndef HAVE_TBASISFUN_H
2#define HAVE_TBASISFUN_H
11 template<
typename FLT>
13 ratio (
const FLT num,
const FLT denom) {
14 if (denom != FLT(0.0)) {
16 }
else if (num != FLT(0.0)) {
17 throw (
"division by zero!");
31 template<
typename INT,
typename FLT,
typename ITERATOR>
33 onebasisfun (FLT
const u, INT
const p, ITERATOR
const Ubegin, ITERATOR
const Uend) {
35 const FLT Umin = *(std::min_element (Ubegin, Uend));
36 const FLT Umax = *(std::max_element (Ubegin, Uend));
38 if ((u <= Umin) || ( u > Umax)) {
45 if (u < *std::next(Ubegin, 1)) {
46 N =
ratio ((u - *Ubegin),
47 (*std::next(Ubegin, 1) - *Ubegin));
50 N =
ratio ((*std::next(Ubegin, 2) - u),
51 (*std::next(Ubegin, 2) - *std::next(Ubegin, 1)));
55 const FLT ln = u - *Ubegin;
56 const FLT dn = *std::next(Ubegin, 3) - u;
57 const FLT ld = *std::next(Ubegin, 2) - *Ubegin;
58 const FLT dd = *std::next(Ubegin, 3) - *std::next(Ubegin, 1);
59 if (u < *std::next(Ubegin, 1)) {
60 N =
ratio (ln*ln, (ld * (*std::next(Ubegin, 1) - *Ubegin)));
62 }
else if (u > *std::next(Ubegin, 2)) {
64 (dd * (*std::next(Ubegin, 3) - *std::next(Ubegin, 2))));
68 N +=
ratio (ln * (*std::next(Ubegin, 2) - u),
69 ((*std::next(Ubegin, 2) - *std::next(Ubegin, 1)) * ld));
72 N +=
ratio (dn * (u - *std::next(Ubegin, 1)),
73 ((*std::next(Ubegin, 2) - *std::next(Ubegin, 1)) * dd));
79 const FLT ln = u - *Ubegin;
80 const FLT ld = *std::next(Uend, - 2) - *Ubegin;
82 N += ln *
onebasisfun (u, p-1, Ubegin, std::next(Uend, - 1)) / ld;
85 const FLT dn = *std::next (Uend, - 1) - u;
86 const FLT dd = *std::next (Uend, - 1) - *std::next (Ubegin , 1);
88 N += dn *
onebasisfun (u, p-1, std::next (Ubegin, 1), Uend) / dd;
100 template<
typename INT,
typename FLT,
typename ITERATOR>
106 const FLT Umin = *(std::min_element (Ubegin, Uend));
107 const FLT Umax = *(std::max_element (Ubegin, Uend));
109 if ((u <= Umin) || ( u > Umax)) {
117 const FLT ld = *std::next (Uend, -2) - *Ubegin;
118 if (ld != FLT(0.0)) {
119 Nder += p *
onebasisfun (u, p-1, Ubegin, std::next (Uend, -1)) / ld;
122 const FLT dd = *std::next (Uend, -1) - *std::next (Ubegin, 1);
123 if (dd != FLT(0.0)) {
124 Nder -= p *
onebasisfun (u, p-1, std::next (Ubegin, 1), Uend) / dd;
132 template<
typename INT,
typename FLT,
typename ITERATOR>
135 ITERATOR
const Ubegin, ITERATOR
const Uend,
136 ITERATOR
const Vbegin, ITERATOR
const Vend) {
Definition: tbasisfun.h:9
FLT onebasisfun2d(FLT const u, FLT const v, INT const pu, INT const pv, ITERATOR const Ubegin, ITERATOR const Uend, ITERATOR const Vbegin, ITERATOR const Vend)
Definition: tbasisfun.h:134
FLT onebasisfunder(FLT u, INT p, ITERATOR Ubegin, ITERATOR Uend)
function to compute the derivative of a BSpline basis function.
Definition: tbasisfun.h:102
FLT onebasisfun(FLT const u, INT const p, ITERATOR const Ubegin, ITERATOR const Uend)
function to compute the value of a BSpline basis function at a given point.
Definition: tbasisfun.h:33
FLT ratio(const FLT num, const FLT denom)
Definition: tbasisfun.h:13