A technical but useful transformation of the matrix of derivatives form the one-sided
to symmetric representations, or a reverse one. It allows for switching between the standard representation of the matrix
of the derivatives for Splinets which is symmetric around the central knot(s) to the one-sided that yields
the RHS limits at the knots, which is more convenient for computations.
Arguments
- S
(m+2) x (k+1)numeric matrix, the derivatives in one of the two representations;- supp
(Nsupp x 2)orNULLmatrix, row-wise the endpoint indices of the support intervals; If it is equal toNULL(which is also the default), then the full support is assumed.- inv
logical; If
FALSE(default), then the function assumes that the input is in the symmetric format and transforms it to the left-to-right format. IfTRUE, then the inverse transformation is applied.
Details
The transformation essentially changes only the last column in S, i.e. the highest (discontinuous) derivatives so that
the one-sided representation yields the right-hand-side limit.
It is expected that the number of rows in S is the same as the total size of the support
as indicated by supp, i.e. if supp!=NULL, then sum(supp[,2]-supp[,1]+1)=m+2.
If the latter is true, than all derivative submatrices of the components in S will be reversed.
However, this condition formally is not checked in the code, which may lead to switch of
the representations only for parts of the matrix S.
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
Splinets-class for the description of the Splinets-class;
is.splinets for diagnostic of Splinets-objects;
Examples
#-----------------------------------------------------#
#-------Representations of derivatives at knots-------#
#-----------------------------------------------------#
n=10; k=3; xi=seq(0,1,by=1/(n+1)) #the even number of equally spaced knots
set.seed(5)
S=matrix(rnorm((n+2)*(k+1)),ncol=(k+1))
spl=construct(xi,k,S) #construction of a 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.
#>
#> Spline 1 's highest derivative is not symmetrically defined at the center (the values at the two central knots should be equal).
#> Spline 1 's highest 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 does not satisfy the conditions
#>
#> required for a spline (up to the accuracy SLOT 'epsilon').
#>
#> One of the reasons can be that SLOT 'taylor' is not correctly given.
#> The computed standard error per matrix entry is 1.383861 .
#>
#>
#> 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 has the derivative matrix corrected by the RRM method
#> given that SLOT 'taylor' is properly given.
#> The matrix derivative is now corrected by method RRM .
a=spl@der[[1]]
b=sym2one(a)
aa=sym2one(b,inv=TRUE) # matrix 'aa' is the same as 'a'
n=11; xi2=seq(0,1,by=1/(n+1)) #the odd number of knots case
S2=matrix(rnorm((n+2)*(k+1)),ncol=(k+1))
spl2=construct(xi2,k,S2) #construction of a 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.
#>
#> Spline 1 's highest derivative at the central knot is not equal to zero.
#> Spline 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 does not satisfy the conditions
#>
#> required for a spline (up to the accuracy SLOT 'epsilon').
#>
#> One of the reasons can be that SLOT 'taylor' is not correctly given.
#> The computed standard error per matrix entry is 1.157913 .
#>
#>
#> 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 has the derivative matrix corrected by the RRM method
#> given that SLOT 'taylor' is properly given.
#> The matrix derivative is now corrected by method RRM .
a2=spl2@der[[1]]
b2=sym2one(a2)
aa2=sym2one(b2, inv=TRUE) # matrix 'aa2' is the same as 'a2'
#-----------------------------------------------------#
#--------------More complex support sets--------------#
#-----------------------------------------------------#
#Zero order splines, non-equidistant case, support with three components
n=43; xi=seq(0,1,by=1/(n+1)); k=3; xi=sort(runif(n+2)); xi[1]=0; xi[n+2]=1;
support=list(matrix(c(2,14,17,30,32,43),ncol=2,byrow = TRUE))
#Third order splines
ssp=new("Splinets",knots=xi,supp=support,smorder=k) #with partial support
m=sum(ssp@supp[[1]][,2]-ssp@supp[[1]][,1]+1) #the total number of knots in the support
ssp@der=list(matrix(rnorm(m*(k+1)),ncol=(k+1))) #the derivative matrix at random
IS=is.splinets(ssp)
#>
#>
#> 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 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.492997 .
#>
#>
#> 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.
#> Spline 1 , support 2 - 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 2 does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.148768 .
#>
#>
#> 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 2 has the derivative matrix corrected by the RRM method.
#> Spline 1 , support 3 - 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 3 does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.601748 .
#>
#>
#> 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 3 has the derivative matrix corrected by the RRM method.
IS$robject@der
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.000000000 0.00000000 0.000000e+00 2.602891e+07
#> [2,] 0.020169442 36.25368071 4.344293e+04 -1.133425e+07
#> [3,] 0.452070889 116.91998071 -7.661883e+03 2.487946e+05
#> [4,] 1.630578457 -1.05775009 -1.857767e-01 -8.839958e-02
#> [5,] 1.605482003 -1.06217347 -1.878697e-01 -2.694659e+02
#> [6,] 1.600437999 -1.06609441 -1.465747e+00 9.770884e-02
#> [7,] 1.594683523 -1.07397554 -1.465221e+00 0.000000e+00
#> [8,] 1.577314990 -1.09727433 -1.447437e+00 1.111619e+00
#> [9,] 1.555766871 -1.10351300 8.081351e-01 1.155689e+02
#> [10,] 1.528859115 -1.08310035 8.507972e-01 1.733572e+00
#> [11,] 1.517330148 -17.18082778 -1.800946e+04 -1.007411e+07
#> [12,] 0.348403322 -73.44339875 1.032124e+04 1.935679e+06
#> [13,] 0.000000000 0.00000000 0.000000e+00 -7.252391e+05
#> [14,] 0.000000000 0.00000000 0.000000e+00 -8.107931e+03
#> [15,] -0.023141799 -2.69342936 -2.089887e+02 5.145988e+03
#> [16,] -0.379094229 -5.91164232 1.027351e+02 -1.182501e+03
#> [17,] -0.633041558 -1.44923541 9.547868e-01 -1.245056e+00
#> [18,] -0.648147346 -1.43931725 9.417646e-01 2.184919e+03
#> [19,] -0.676410037 -0.84951596 5.077620e+01 -1.488525e+03
#> [20,] -0.685692768 0.01651311 -1.038042e-01 -1.500139e+00
#> [21,] -0.685466074 0.01485930 -1.254480e-01 -1.500139e+00
#> [22,] -0.673722335 1.39097073 1.109865e+02 4.475646e+03
#> [23,] -0.666343314 1.64910142 -1.544657e+00 -2.385537e+04
#> [24,] -0.610172067 1.59545238 -1.554262e+00 -2.773949e-01
#> [25,] -0.549315902 3.58114751 1.484087e+02 5.545347e+03
#> [26,] -0.019535704 2.26930738 -1.757383e+02 -3.376473e+03
#> [27,] 0.000000000 0.00000000 0.000000e+00 6.804706e+03
#> [28,] 0.000000000 0.00000000 0.000000e+00 4.724698e+03
#> [29,] 0.030551709 2.70740062 1.599478e+02 -3.216931e+04
#> [30,] 0.063906965 2.43697547 -2.073212e+02 1.884581e+04
#> [31,] 0.082396860 1.29662506 6.436154e-01 -4.384008e-01
#> [32,] 0.084463485 1.29764993 6.429170e-01 2.080547e+02
#> [33,] 0.087591557 1.29980214 1.144070e+00 7.453307e-01
#> [34,] 0.113611057 1.32265181 1.158860e+00 7.453307e-01
#> [35,] 0.164496395 1.37723487 1.733344e+00 1.522015e+01
#> [36,] 0.174588409 1.38990312 1.740164e+00 9.349643e-01
#> [37,] 0.176698633 -2.49013668 -3.787662e+02 -1.848703e+04
#> [38,] 0.009774724 -2.37641018 3.851652e+02 2.149187e+04
#> [39,] 0.000000000 0.00000000 0.000000e+00 -3.121351e+04
#>
IS$robject@supp
#> [[1]]
#> [,1] [,2]
#> [1,] 2 14
#> [2,] 17 30
#> [3,] 32 43
#>
b=sym2one(IS$robject@der[[1]],IS$robject@supp[[1]]) #the RHS limits at the knots
a=sym2one(b,IS$robject@supp[[1]],inv=TRUE) #is the same as the SLOT supp in IS@robject