// NumericalDeriv computes a particular derivative dN[i]dt @ t using numerical differentiation // Note: it uses RecursiveBasis and therefore is highly non-efficient func (o *Bspline) NumericalDeriv(t float64, i int) float64 { // check if t < o.tmin || t > o.tmax { chk.Panic("t must be within [%g, %g]. t=%g is incorrect", t, o.tmin, o.tmax) } // derivatives f := func(x float64, args ...interface{}) float64 { return o.RecursiveBasis(x, i) } return num.DerivRange(f, t, o.tmin, o.tmax) }
// NumericalDeriv computes a particular derivative dN[i]dt @ t using numerical differentiation // Note: it uses RecursiveBasis and therefore is highly non-efficient func (o *Bspline) NumericalDeriv(t float64, i int) float64 { // check if t < o.tmin || t > o.tmax { chk.Panic(_bspline_err02, "NumericalDeriv", t, o.tmin, o.tmax) } // derivatives f := func(x float64, args ...interface{}) float64 { return o.RecursiveBasis(x, i) } return num.DerivRange(f, t, o.tmin, o.tmax) }
// NumericalDeriv computes a particular derivative dR[i][j][k]du @ t using numerical differentiation // Note: it uses RecursiveBasis and therefore is highly non-efficient func (o *Nurbs) NumericalDeriv(dRdu []float64, u []float64, l int) { var tmp float64 for d := 0; d < o.gnd; d++ { f := func(x float64, args ...interface{}) (val float64) { if x < o.b[d].tmin || x > o.b[d].tmax { chk.Panic("problem with numerical derivative: x=%v is invalid. xrange=[%v,%v]", x, o.b[d].tmin, o.b[d].tmax) } tmp = u[d] u[d] = x val = o.RecursiveBasis(u, l) u[d] = tmp return } dRdu[d] = num.DerivRange(f, u[d], o.b[d].tmin, o.b[d].tmax) } return }
// NumericalDeriv computes a particular derivative dR[i][j][k]du @ t using numerical differentiation // Note: it uses RecursiveBasis and therefore is highly non-efficient func (o *Nurbs) NumericalDeriv(dRdu []float64, u []float64, l int) { var tmp float64 for d := 0; d < o.gnd; d++ { f := func(x float64, args ...interface{}) (val float64) { if x < o.b[d].tmin || x > o.b[d].tmax { chk.Panic(_nurbs_err6, x, o.b[d].tmin, o.b[d].tmax) } tmp = u[d] u[d] = x val = o.RecursiveBasis(u, l) u[d] = tmp return } dRdu[d] = num.DerivRange(f, u[d], o.b[d].tmin, o.b[d].tmax) } return }