83 const dvar_vector& _y,
double yp1,
double ypn) :
x(_x) , y(_y)
108 for (
int i=mmin;i<=mmax;i++)
124 for (
int i=mmin;i<=mmax;i++)
151 if(
value(yp1) > 0.99e30 )
161 if(
value(ypn) > 0.99e30 )
245 if(
value(yp1) > 0.99e30 )
364 for ( i = 0; i < n-1; i++ )
376 h = t[ival+1] - t[ival];
379 + dt * ( ( y[ival+1] - y[ival] ) / h
380 - ( ypp[ival+1] / 6.0 + ypp[ival] / 3.0 ) * h
381 + dt * ( 0.5 * ypp[ival]
382 + dt * ( ( ypp[ival+1] - ypp[ival] ) / ( 6.0 * h ) ) ) );
489 for ( i = 0; i < n-1; i++ )
501 h = t[ival+1] - t[ival];
504 + dt * ( ( y[ival+1] - y[ival] ) / h
505 - ( ypp[ival+1] / 6.0 + ypp[ival] / 3.0 ) * h
506 + dt * ( 0.5 * ypp[ival]
507 + dt * ( ( ypp[ival+1] - ypp[ival] ) / ( 6.0 * h ) ) ) );
593 for ( i = 0; i < n; i++ )
595 if ( a[1+i*3] == 0.0 )
602 for ( i = 0; i < n; i++ )
607 for ( i = 1; i < n; i++ )
609 xmult = a[2+(i-1)*3] / a[1+(i-1)*3];
610 a[1+i*3] = a[1+i*3] - xmult * a[0+i*3];
611 x[i] = x[i] - xmult * x[i-1];
614 x[n-1] = x[n-1] / a[1+(n-1)*3];
615 for ( i = n-2; 0 <= i; i-- )
617 x[i] = ( x[i] - a[0+(i+1)*3] * x[i+1] ) / a[1+i*3];
772 cout <<
"SPLINE_CUBIC_SET - Fatal error!\n";
773 cout <<
" The number of data points N must be at least 2.\n";
774 cout <<
" The input value is " << n <<
".\n";
778 for ( i = 0; i < n - 1; i++ )
780 if ( t[i+1] <= t[i] )
783 cout <<
"SPLINE_CUBIC_SET - Fatal error!\n";
784 cout <<
" The knots must be strictly increasing, but\n";
785 cout <<
" T(" << i <<
") = " << t[i] <<
"\n";
786 cout <<
" T(" << i+1 <<
") = " << t[i+1] <<
"\n";
797 else if ( ibcbeg == 1 )
799 b[0] = ( y[1] - y[0] ) / ( t[1] - t[0] ) - ybcbeg;
800 a[1+0*3] = ( t[1] - t[0] ) / 3.0;
801 a[0+1*3] = ( t[1] - t[0] ) / 6.0;
803 else if ( ibcbeg == 2 )
812 cout <<
"SPLINE_CUBIC_SET - Fatal error!\n";
813 cout <<
" IBCBEG must be 0, 1 or 2.\n";
814 cout <<
" The input value is " << ibcbeg <<
".\n";
818 for ( i = 1; i < n-1; i++ )
820 b[i] = ( y[i+1] - y[i] ) / ( t[i+1] - t[i] )
821 - ( y[i] - y[i-1] ) / ( t[i] - t[i-1] );
822 a[2+(i-1)*3] = ( t[i] - t[i-1] ) / 6.0;
823 a[1+ i *3] = ( t[i+1] - t[i-1] ) / 3.0;
824 a[0+(i+1)*3] = ( t[i+1] - t[i] ) / 6.0;
834 else if ( ibcend == 1 )
836 b[n-1] = ybcend - ( y[n-1] - y[n-2] ) / ( t[n-1] - t[n-2] );
837 a[2+(n-2)*3] = ( t[n-1] - t[n-2] ) / 6.0;
838 a[1+(n-1)*3] = ( t[n-1] - t[n-2] ) / 3.0;
840 else if ( ibcend == 2 )
849 cout <<
"SPLINE_CUBIC_SET - Fatal error!\n";
850 cout <<
" IBCEND must be 0, 1 or 2.\n";
851 cout <<
" The input value is " << ibcend <<
".\n";
855 if ( n == 2 && ibcbeg == 0 && ibcend == 0 )
869 cout <<
"SPLINE_CUBIC_SET - Fatal error!\n";
870 cout <<
" The linear system could not be solved.\n";
dvariable operator()(double u)
Description not yet available.
Base class for dvariable.
dvar_vector & shift(int min)
Description not yet available.
dvariable spline_cubic_val2(int n, const dvector &t, const prevariable &tval, const dvar_vector &y, const dvar_vector &ypp)
Evaluates a piecewise cubic spline at a point.
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Vector of double precision numbers.
int indexmin() const
Get minimum valid index.
double splint(const dvector &xa, const dvector &ya, const dvector &y2a, double x)
dvar_vector spline_cubic_set(int n, const dvector &t, const dvar_vector &y, int ibcbeg, dvariable ybcbeg, int ibcend, dvariable ybcend)
Computes the second derivatives of a piecewise cubic spline.
void RETURN_ARRAYS_INCREMENT()
int indexmax() const
Get maximum valid index.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
vcubic_spline_function(const dvector &_x, const dvar_vector &_y, double yp1=0.0, double ypn=0.0)
Description not yet available.
dvector spline(const dvector &x, const dvector &y, double yp1, double ypn)
static _THREAD gradient_structure * _instance
dvariable spline_cubic_val(int n, const dvector &t, double tval, const dvar_vector &y, const dvar_vector &ypp)
Evaluates a piecewise cubic spline at a point.
dvector & shift(int min)
Shift valid range of subscripts.
unsigned int size() const
Get number of elements in array.
void allocate(int, int)
Allocate dvar_vector with indexmin = ncl and indexmax = nch.
void RETURN_ARRAYS_DECREMENT()
dvar_vector d3_np_fs(int n, const dvar_vector &_a, const dvar_vector &_b)
factors and solves a D3 system.
dvector value(const df1_one_vector &v)
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
Fundamental data type for reverse mode automatic differentiation.