@@ -105,8 +105,9 @@ module fitpack_curves
105105 procedure , private :: curve_derivative
106106 procedure , private :: curve_derivatives
107107 procedure , private :: curve_all_derivatives
108+ procedure , private :: curve_all_derivatives_pure
108109 generic :: dfdx = > curve_derivative,curve_derivatives
109- generic :: dfdx_all = > curve_all_derivatives
110+ generic :: dfdx_all = > curve_all_derivatives,curve_all_derivatives_pure
110111
111112 ! > Properties: MSE
112113 procedure , non_overridable :: mse = > curve_error
@@ -423,11 +424,11 @@ end function curve_error
423424 ! > Evaluate k-th derivative of the curve at points x
424425 ! > Use 1st derivative if order not present
425426 function curve_derivatives (this , x , order , ierr ) result(ddx)
426- class(fitpack_curve), intent (inout ) :: this
427- real (FP_REAL), intent (in ) :: x(:) ! Evaluation point (scalar)
428- integer , intent (in ) :: order ! Derivative order. Default 1
429- integer (FP_FLAG), optional , intent (out ) :: ierr ! Optional error flag
430- real (FP_REAL), dimension (size (x)) :: ddx
427+ class(fitpack_curve), intent (inout ) :: this
428+ real (FP_REAL), intent (in ) :: x(:) ! Evaluation point (scalar)
429+ integer , intent (in ) :: order ! Derivative order. Default 1
430+ integer (FP_FLAG), optional , intent (out ) :: ierr ! Optional error flag
431+ real (FP_REAL), dimension (size (x)) :: ddx
431432
432433 integer (FP_SIZE) :: ddx_order,m
433434 integer (FP_FLAG) :: ierr0
@@ -437,7 +438,6 @@ function curve_derivatives(this, x, order, ierr) result(ddx)
437438
438439 ierr0 = FITPACK_OK
439440
440-
441441 m = size (x); if (m<= 0 ) goto 1
442442
443443 ! subroutine splder evaluates in a number of points x(i),i=1,2,...,m the derivative of
@@ -458,14 +458,15 @@ function curve_derivatives(this, x, order, ierr) result(ddx)
458458
459459 end function curve_derivatives
460460
461+
461462 ! > Evaluate ALL derivatives of the curve at points x
462463 ! > (j-1)
463464 ! > d(j) = s (x) , j=1,2,...,k1
464465 ! > of a spline s(x) of order k1 (degree k=k1-1), given in its b-spline representation.
465466 function curve_all_derivatives (this , x , ierr ) result(ddx)
466- class(fitpack_curve), intent (inout ) :: this
467- real (FP_REAL), intent (in ) :: x ! Evaluation point (scalar)
468- integer (FP_FLAG), optional , intent (out ) :: ierr ! Optional error flag
467+ class(fitpack_curve), intent (inout ) :: this
468+ real (FP_REAL), intent (in ) :: x ! Evaluation point (scalar)
469+ integer (FP_FLAG), intent (out ) :: ierr ! Optional error flag
469470 real (FP_REAL), dimension (this% order+1 ) :: ddx
470471
471472 integer (FP_FLAG) :: ierr0
@@ -486,13 +487,40 @@ function curve_all_derivatives(this, x, ierr) result(ddx)
486487
487488 end function curve_all_derivatives
488489
490+ ! > Evaluate ALL derivatives of the curve at points x
491+ ! > (j-1)
492+ ! > d(j) = s (x) , j=1,2,...,k1
493+ ! > of a spline s(x) of order k1 (degree k=k1-1), given in its b-spline representation.
494+ function curve_all_derivatives_pure (this , x ) result(ddx)
495+ class(fitpack_curve), intent (in ) :: this
496+ real (FP_REAL), intent (in ) :: x ! Evaluation point (scalar)
497+ real (FP_REAL), dimension (this% order+1 ) :: ddx
498+
499+ integer (FP_FLAG) :: ierr0
500+
501+ ierr0 = FITPACK_OK
502+
503+ ! subroutine splder evaluates in a number of points x(i),i=1,2,...,m the derivative of
504+ ! order nu of a spline s(x) of degree k, given in its b-spline representation.
505+ call spalde(this% t, & ! Position of the knots
506+ this% knots, & ! Number of knots
507+ this% c, & ! spline coefficients
508+ this% order+1 , & ! spline order (=degree+1)
509+ x, & ! Point where this should be evaluated
510+ ddx, & ! Evaluated derivatives
511+ ierr0) ! Output flag
512+
513+ if (.not. FITPACK_SUCCESS(ierr0)) ddx = ieee_value(0.0_FP_REAL ,ieee_quiet_nan)
514+
515+ end function curve_all_derivatives_pure
516+
489517 ! > Evaluate k-th derivative of the curve at points x
490518 ! > Use 1st derivative if order not present
491519 real (FP_REAL) function curve_derivative(this, x, order, ierr) result(ddx)
492- class(fitpack_curve), intent (inout ) :: this
493- real (FP_REAL), intent (in ) :: x ! Evaluation point (scalar)
494- integer , intent (in ) :: order ! Derivative order. Default 1
495- integer (FP_FLAG), optional , intent (out ) :: ierr ! Optional error flag
520+ class(fitpack_curve), intent (inout ) :: this
521+ real (FP_REAL), intent (in ) :: x ! Evaluation point (scalar)
522+ integer , intent (in ) :: order ! Derivative order. Default 1
523+ integer (FP_FLAG), optional , intent (out ) :: ierr ! Optional error flag
496524
497525 real (FP_REAL) :: ddxa(1 )
498526
0 commit comments