Skip to contents

The function calculates the definite integrals of the splines in an input Splinets-object.

Usage

dintegra(object, sID = NULL)

Arguments

object

Splinets-object;

sID

vector of integers, the indicies specifying for which splines in the Splinets-object the definite integral is to be evaluated; If sID=NULL, then the definite integral of all splines in the object are calculated. The default is NULL.

Value

A length(sID) x 2 matrix, with the first column holding the id of splines and the second column holding the corresponding definite integrals.

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

integra for generating the indefinite integral; deriva for generating derivative functions of splines;

Examples

#------------------------------------------#
#--- Example with common support ranges ---#
#------------------------------------------#
n=23; k=4
set.seed(5)
xi=sort(runif(n+2)); xi[1]=0; xi[n+2]=1
# generate a random matrix S
S=matrix(rnorm((n+2)*(k+1)),ncol=(k+1))
# construct the spline
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.441088 .
#> 
#> 
#> 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 6 knots, the first 3 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 3 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.441088 .
#> 
#> 
#> 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 6 knots, the first 3 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 3 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.441088 .
#> 
#> 
#> 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 6 knots, the first 3 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 3 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 .

plot(spl)

dintegra(spl, sID = c(1,3))
#>      Spline ID  dIntegral
#> [1,]         1 -0.2817531
#> [2,]         3  0.2713847
dintegra(spl)
#>      Spline ID     dIntegral
#> [1,]         1 -2.817531e-01
#> [2,]         2  4.126813e+08
#> [3,]         3  2.713847e-01
plot(spl,sID=c(1,3))


#---------------------------------------------#
#--- Examples with different support ranges---#
#---------------------------------------------#

n=25; k=2
xi=seq(0,1,by=1/(n+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
set.seed(5)
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 equal to zero.
#> Spline 1 support 1 's highest derivative value at the central knot has been made equal to zero.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.376113 .
#> 
#> 
#> 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,])
#> 
#> 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 equal to zero.
#> Spline 1 support 1 's highest derivative value at the central knot has been made equal to zero.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.307197 .
#> 
#> 
#> 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
#> 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 .
spl=gather(spl,nspl) #the second and the first ones
nspl=construct(xi,k,SS3,supp[3,])
#> 
#> 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 is not symmetrically defined at the center (the values at the two central knots should be equal).
#> Spline 1  highest, support 1 's derivative values at the two central knots have been made equal by averaging the two central values in SLOT 'der'.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.655723 .
#> 
#> 
#> 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
#> 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 .
spl=gather(spl,nspl) #the third is added

plot(spl)

dintegra(spl, sID = 1)
#> Error in dintegra(spl, sID = 1): object 'n' not found
dintegra(spl)
#> Error in dintegra(spl): object 'n' not found

#The third order case
n=40; xi=seq(0,1,by=1/(n+1)); k=3; 
support=list(matrix(c(2,12,15,27,30,40),ncol=2,byrow = TRUE))
sp=new("Splinets",knots=xi,smorder=k,supp=support) 
m=sum(sp@supp[[1]][,2]-sp@supp[[1]][,1]+1) #the number of knots in the support
sp@der=list(matrix(rnorm(m*(k+1)),ncol=(k+1))); sp1 = is.splinets(sp)[[2]] 
#> 
#> 
#> 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.
#> 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 2 of spline 1 in the output 'Splinets' object.
#> 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 3 of spline 1 in the output 'Splinets' object.
#> 
#> Spline 1 support 1 's highest derivative at the central knot is not equal to zero.
#> Spline 1 support 1 's highest derivative value at the central knot has been made equal to zero.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.302027 .
#> 
#> 
#> 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.
#> Spline 1 support 2 's highest derivative at the central knot is not equal to zero.
#> Spline 1 support 2 's highest derivative value at the central knot has been made equal to zero.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 2  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.663474 .
#> 
#> 
#> 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 2 has the derivative matrix corrected by the RRM method.
#> Spline 1 support 3 's highest derivative at the central knot is not equal to zero.
#> Spline 1 support 3 's highest derivative value at the central knot has been made equal to zero.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 3  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.192439 .
#> 
#> 
#> 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 3 has the derivative matrix corrected by the RRM method.

support=list(matrix(c(2,13,17,30),ncol=2,byrow = TRUE))
sp=new("Splinets",knots=xi,smorder=k,supp=support) 
m=sum(sp@supp[[1]][,2]-sp@supp[[1]][,1]+1) #the number of knots in the support
sp@der=list(matrix(rnorm(m*(k+1)),ncol=(k+1))); sp2 = is.splinets(sp)[[2]] 
#> 
#> 
#> 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.
#> 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 2 of spline 1 in the output 'Splinets' object.
#> 
#> Spline 1 , support 1 's highest derivative is not symmetrically defined at the center (the values at the two central knots should be equal).
#> Spline 1  highest, support 1 's derivative values at the two central knots have been made equal by averaging the two central values in SLOT 'der'.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 1  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.382402 .
#> 
#> 
#> 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.
#> Spline 1 , support 2 's highest derivative is not symmetrically defined at the center (the values at the two central knots should be equal).
#> Spline 1  highest, support 2 's derivative values at the two central knots have been made equal by averaging the two central values in SLOT 'der'.
#> 
#> The matrix of derivatives at the knots for spline 1 , support 2  does not satisfy the conditions that are required for a spline (up to the accuracy SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.489447 .
#> 
#> 
#> 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 2 has the derivative matrix corrected by the RRM method.

sp = gather(sp1,sp2)
dintegra(sp)
#> Error in dintegra(sp): object 'n' not found
plot(sp)


lcsp=lincomb(sp,matrix(c(-1,1),ncol=2))
dintegra(lcsp)                  #linearity of the integral
#> Error in dintegra(lcsp): object 'n' not found
dintegra(sp2)-dintegra(sp1)
#> Error in dintegra(sp2): object 'n' not found