refine | R Documentation |
Any spline of a given order remains a spline of the same order if one considers it on a bigger set of knots than the original one.
However, this embedding changes the Splinets
representation of the so-refined spline.
The function evaluates the corresponding Splinets
-object.
refine(object, mult = 2, newknots = NULL)
object |
|
mult |
positive integer, refining rate; The number of the knots to be put equally spaced between the existing knots. |
newknots |
|
The function merges new knots with the ones from the input object
. It utilizes deriva()
-function to evaluate the derivative at the refined knots.
It removes duplications of the refined knots, and account also for the not-fully supported case.
In the case when the range of the additional knots extends beyond the knots of the input Splinets
-object,
the support sets of the output Splinets
-object account for the smaller than the full support.
A Splinet
object with the new refined knots and the new matrix of derivatives is evaluated at the new knots combined with the original ones.
Liu, X., Nassar, H., Podgorski, 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>.
Podgorski, K. (2021)
"Splinets
– splines through the Taylor expansion, their support sets and orthogonal bases." <arXiv:2102.00733>.
Nassar, H., Podgorski, K. (2023) "Splinets 1.5.0 – Periodic Splinets." <arXiv:2302.07552>
deriva
for computing derivatives at selected points;
project
for an orthogonal projection into a space of splines;
#-------------------------------------------------# #----Refining splines - the full support case-----# #-------------------------------------------------# k=3 # order n = 16 # number of the internal knots (excluding the endpoints) xi = seq(0, 1, length.out = n+2) set.seed(5) S=matrix(rnorm((n+2)*(k+1)),ncol=(k+1)) spl=construct(xi,k,S) plot(spl) # plotting a spline rspl=refine(spl) # refining the equidistant by doubling its knots plot(rspl) rspl@equid # the outcome is equidistant #a non-equidistant case 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)) spl=construct(xi,k,S) plot(spl) mult=3 #adding two knots between each subsequent pair of the original knots rspl=refine(spl,mult) is.splinets(rspl) plot(rspl) #adding specific knots rspl=refine(spl,newknots=c(0.5,0.75)) rspl@knots is.splinets(rspl) plot(rspl) #----------------------------------------------------# #----Refining splines - the partial support case-----# #----------------------------------------------------# Bases=splinet(xi,k) plot(Bases$bs) Base=Bases$bs BS_Two=subsample(Bases$bs,c(1,length(Base@der))) plot(BS_Two) A=matrix(c(1,-1),ncol=2) spl=lincomb(BS_Two,A) rspl=refine(spl) #doubling the number of knots plot(rspl) is.splinets(rspl) rspl@supp #the support is evaluated spl@supp #The case of adding knots explicitely BS_Middle=subsample(Bases$bs,c(floor(length(Base@der)/2))) spls=gather(spl,BS_Middle) plot(spls) rspls=refine(spls, newknots=c(0.2,0.5,0.85)) #two splines with partial support sets #by adding three knots to B-splines plot(rspls) #----------------------------------------------------# #------Refining splines over the larger range--------# #----------------------------------------------------# k=4 # order n = 25 # number of the internal knots (excluding the endpoints) xi = seq(0, 1, length.out = n+2) S=matrix(rnorm((n+2)*(k+1)),ncol=(k+1)) spl=construct(xi,k,S) plot(spl) # plotting a spline newknots=c(-0.1,0.4,0.6,1.2) #the added knots create larger range rspl=refine(spl,newknots=newknots) spl@supp #the original spline has the full support rspl@supp #the embedded spline has partial support spl@equid rspl@equid plot(rspl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.