Skip to contents

For a Splinets-object S and a vector of arguments t, the function returns the matrix of values for the splines in S. The evaluations are done through the Taylor expansions, so on the \(i\)th interval for \(t\in [\xi_i,\xi_{i+1}]\): $$S(t)=\sum_{j=0}^{k} s_{i j} \frac{(t-\xi_{i})^j}{j!}.$$ For the zero order splines which are discontinuous at the knots, the following convention is taken. At the LHS knots the value is taken as the RHS-limit, at the RHS knots as the LHS-limit. The value at the central knot for the zero order and an odd number of knots case is assumed to be zero.

Usage

evspline(object, sID = NULL, x = NULL, N = 250)

Arguments

object

Splinets object;

sID

vector of integers, the indicies specifying splines in the Splinets list to be evaluated; If sID=NULL, then all splines in the Splinet-object are evaluated. The default value is NULL.

x

vector, the arguments at which the splines are evaluated; If x is NULL, then the splines are evaluated over regular grids per each interval of the support. The default value is x=NULL.

N

integer, the number of points per an interval between two consequitive knots at which the splines are evaluated. The default value is N = 250;

Value

The length(x) x length(sID+1) matrix containing the argument values, in the first column, then, columnwise, values of the subsequent splines.

References

Liu, X., Nassar, H., Podg\(\mbox{\'o}\)rski, K. "Dyadic diagonalization of positive definite band matrices and efficient B-spline orthogonalization." Journal of Computational and Applied Mathematics (2022) <https://doi.org/10.1016/j.cam.2022.114444>.

Podg\(\mbox{\'o}\)rski, K. (2021) "Splinets – splines through the Taylor expansion, their support sets and orthogonal bases." <arXiv:2102.00733>.

Nassar, H., Podg\(\mbox{\'o}\)rski, K. (2023) "Splinets 1.5.0 – Periodic Splinets." <arXiv:2302.07552>

See also

is.splinets for diagnostic of Splinets-objects; plot,Splinets-method for plotting Splinets-objects;

Examples

#---------------------------------------------#
#-- Example piecewise polynomial vs. spline --#
#---------------------------------------------#
n=20; k=3; xi=sort(runif(n+2))
sp=new("Splinets",knots=xi) 

#Randomly assigning the derivatives -- a very 'wild' function.
S=matrix(rnorm((n+2)*(k+1)),ncol=(k+1))
sp@supp=list(t(c(1,n+2))); sp@smorder=k; sp@der[[1]]=S

y = evspline(sp)
plot(y,type = 'l',col='red')

#A correct spline object
nsp=is.splinets(sp)
#> 
#> 
#> DIAGNOSTIC CHECK of a SPLINETS object
#> 
#> THE KNOTS:  
#> The Taylor expansion coefficient matrix does not have the proper number of columns.
#> It is evaluated now and assigned to the output.
#> 
#> 
#> THE SUPPORT SETS:  
#> 
#> 
#> 
#> THE DERIVATIVES AT THE KNOTS:  
#> 
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices over the support component 1 of spline 1 in the output 'Splinets' object.
#> 
#> Spline 1 , support 1  - highest derivative is not symmetric at the center (equal values at the two central knots).
#> The two values have been made equal by averaging.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.512227 .
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> Correction of the LHS part of the matrix
#> There are less than 5 knots, the first 1 entries of the 5 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the RHS part of the matrix
#> There are less than 5 knots, the first 1 entries of the 5 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object Spline 1  support 1 has the derivative matrix corrected by the RRM method.
sp2=nsp$robject 
y = evspline(sp2)
lines(y,type='l')


#---------------------------------------------#
#-- Example piecewise polynomial vs. spline --#
#---------------------------------------------#
#Gathering three 'Splinets' objects using three different
#method to correct the derivative matrix
n=17; k=4; xi=sort(runif(n+2)); xi[1]=0; xi[n+2]=1

S=matrix(rnorm((n+2)*(k+1)),ncol=(k+1)) # generate a random matrix S

spl=construct(xi,k,S) #constructing the first correct spline
#> 
#> Using  method RRM to correct the derivative matrix entries.
#> 
#> 
#> DIAGNOSTIC CHECK of a SPLINETS object
#> 
#> THE KNOTS:  
#> 
#> 
#> THE SUPPORT SETS:  
#> 
#> The support sets for the splines are equal to the entire range of knots.
#> 
#> 
#> THE DERIVATIVES AT THE KNOTS:  
#> 
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices are made in the output 'Splinets' object.
#> 
#>  The spline 1 'ths highest derivative at the central knot is zero.
#> Now it is set to zero.
#> 
#> The derivative matrix for spline 1 does not satisfy the smoothness conditions (up to the accuracy SLOT 'epsilon').
#> The standard error per matrix entry is 1.562798 .
#> 
#> 
#> Correction of the LHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the RHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object has the derivative matrix corrected by the RRM method.
#> 
#> The matrix derivative is now corrected by method RRM .
spl=gather(spl,construct(xi,k,S,mthd='CRFC')) #the second and the first ones
#> 
#> Using  method CRFC to correct the derivative matrix entries.
#> 
#> 
#> DIAGNOSTIC CHECK of a SPLINETS object
#> 
#> THE KNOTS:  
#> 
#> 
#> THE SUPPORT SETS:  
#> 
#> The support sets for the splines are equal to the entire range of knots.
#> 
#> 
#> THE DERIVATIVES AT THE KNOTS:  
#> 
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices are made in the output 'Splinets' object.
#> 
#>  The spline 1 'ths highest derivative at the central knot is zero.
#> Now it is set to zero.
#> 
#> The derivative matrix for spline 1 does not satisfy the smoothness conditions (up to the accuracy SLOT 'epsilon').
#> The standard error per matrix entry is 1.562798 .
#> 
#> 
#> Correction of the LHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the RHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object has the derivative matrix corrected by the RRM method.
#> The zero boundary conditions are not satisfied.
#> The correction of the first and last rows of the derivative matrix has been made.
#> 
#> 
#> The highest order derivative at the central knot is not equal to zero.
#> It has been made equal to zero now.
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The matrix derivative is now corrected by method CRFC .
spl=gather(spl,construct(xi,k,S,mthd='CRLC')) #the third is added
#> 
#> Using  method CRLC to correct the derivative matrix entries.
#> 
#> 
#> DIAGNOSTIC CHECK of a SPLINETS object
#> 
#> THE KNOTS:  
#> 
#> 
#> THE SUPPORT SETS:  
#> 
#> The support sets for the splines are equal to the entire range of knots.
#> 
#> 
#> THE DERIVATIVES AT THE KNOTS:  
#> 
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices are made in the output 'Splinets' object.
#> 
#>  The spline 1 'ths highest derivative at the central knot is zero.
#> Now it is set to zero.
#> 
#> The derivative matrix for spline 1 does not satisfy the smoothness conditions (up to the accuracy SLOT 'epsilon').
#> The standard error per matrix entry is 1.562798 .
#> 
#> 
#> Correction of the LHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the RHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object has the derivative matrix corrected by the RRM method.
#> The zero boundary conditions are not satisfied.
#> The correction of the first and last rows of the derivative matrix has been made.
#> 
#> 
#> The highest order derivative at the central knot is not equal to zero.
#> It has been made equal to zero now.
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The matrix derivative is now corrected by method CRLC .
y = evspline(spl, sID= 1)
plot(y,type = 'l',col='red')


y = evspline(spl, sID = c(1,3))
plot(y[,1:2],type = 'l',col='red')
points(y[,c(1,3)],type = 'l',col='blue')


#sID = NULL
y = evspline(spl)
plot(y[,1:2],type = 'l',col='red',ylim=range(y[,2:4]))
points(y[,c(1,3)],type = 'l',col='blue')
points(y[,c(1,4)],type = 'l',col='green')


#---------------------------------------------#
#--- Example with different support ranges ---#
#---------------------------------------------#
n=25; k=3; xi=sort(runif(n+2)); xi[1]=0; xi[n+2]=1
#Defining support ranges for three splines
supp=matrix(c(2,12,4,20,6,25),byrow=TRUE,ncol=2)
#Initial random matrices of the derivative for each spline
SS1=matrix(rnorm((supp[1,2]-supp[1,1]+1)*(k+1)),ncol=(k+1)) 
SS2=matrix(rnorm((supp[2,2]-supp[2,1]+1)*(k+1)),ncol=(k+1)) 
SS3=matrix(rnorm((supp[3,2]-supp[3,1]+1)*(k+1)),ncol=(k+1)) 
spl=construct(xi,k,SS1,supp[1,]) #constructing the first correct spline
#> 
#> Using  method RRM to correct the derivative matrix entries.
#> 
#> 
#> DIAGNOSTIC CHECK of a SPLINETS object
#> 
#> THE KNOTS:  
#> 
#> 
#> THE SUPPORT SETS:  
#> 
#> 
#> 
#> THE DERIVATIVES AT THE KNOTS:  
#> 
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices over the support component 1 of spline 1 in the output 'Splinets' object.
#> 
#> Spline 1 support 1 's highest derivative at the central knot is not zero.
#> Now it is set to zero.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.396783 .
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object Spline 1  support 1 has the derivative matrix corrected by the RRM method.
#> The matrix derivative is now corrected by method RRM .
nspl=construct(xi,k,SS2,supp[2,],'CRFC')
#> 
#> Using  method CRFC to correct the derivative matrix entries.
#> 
#> 
#> DIAGNOSTIC CHECK of a SPLINETS object
#> 
#> THE KNOTS:  
#> 
#> 
#> THE SUPPORT SETS:  
#> 
#> 
#> 
#> THE DERIVATIVES AT THE KNOTS:  
#> 
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices over the support component 1 of spline 1 in the output 'Splinets' object.
#> 
#> Spline 1 support 1 's highest derivative at the central knot is not zero.
#> Now it is set to zero.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.945662 .
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object Spline 1  support 1 has the derivative matrix corrected by the RRM method.The zero boundary conditions are not satisfied.
#> The correction of the first and last rows of the derivative matrix has been made.
#> 
#> 
#> The highest order derivative at the central knot is not equal to zero.
#> It has been made equal to zero now.
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The matrix derivative is now corrected by method CRFC .
spl=gather(spl,nspl) #the second and the first ones
nspl=construct(xi,k,SS3,supp[3,],'CRLC')
#> 
#> Using  method CRLC to correct the derivative matrix entries.
#> 
#> 
#> DIAGNOSTIC CHECK of a SPLINETS object
#> 
#> THE KNOTS:  
#> 
#> 
#> THE SUPPORT SETS:  
#> 
#> 
#> 
#> THE DERIVATIVES AT THE KNOTS:  
#> 
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices over the support component 1 of spline 1 in the output 'Splinets' object.
#> 
#> Spline 1 , support 1  - highest derivative is not symmetric at the center (equal values at the two central knots).
#> The two values have been made equal by averaging.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.470755 .
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> Correction of the LHS part of the matrix
#> There are less than 5 knots, the first 2 entries of the 5 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the RHS part of the matrix
#> There are less than 5 knots, the first 2 entries of the 5 nd row counting from the end in the input will be changed in the output.
#> 
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object Spline 1  support 1 has the derivative matrix corrected by the RRM method.The zero boundary conditions are not satisfied.
#> The correction of the first and last rows of the derivative matrix has been made.
#> 
#> 
#> The highest order derivative is not symmetrically defined at the center.
#>           The values at the two central knots should be equal.
#> The highest order derivative values at the two central knots
#>           have been made equal by averaging the two central values.
#> 
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The matrix derivative is now corrected by method CRLC .
spl=gather(spl,nspl) #the third is added

y = evspline(spl, sID= 1)
plot(y,type = 'l',col='red')


y = evspline(spl, sID = c(1,3))
plot(y[,1:2],type = 'l',col='red')
points(y[,c(1,3)],type = 'l',col='blue')


#sID = NULL -- all splines evaluated
y = evspline(spl)
plot(y[,c(1,3)],type = 'l',col='red',ylim=c(-1,1))
points(y[,1:2],type = 'l',col='blue')
points(y[,c(1,4)],type = 'l',col='green')