Skip to content

Commit 151dcae

Browse files
committed
allow small violations of arg values
1 parent fb79e63 commit 151dcae

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

R/Data2fd.R

+16-8
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,23 @@ argvalsySwap = function(argvals=NULL, y=NULL, basisobj=NULL) {
214214

215215
# set up a safety zone for argvals out of range by a tiny amount
216216
delta <- 1e-7*(rangeval[2]-rangeval[1]) # the tiny amount
217-
arng <- range(argvals)
218-
if ((rangeval[1]-arng[1]) < delta) all(argvals < rangeval[1]) <- rangeval[1]
219-
if ((rangeval[2]-arng[2]) < -delta) all(argvals > rangeval[2]) <- rangeval[2]
220-
# test for argvals being out of range by more than delta
221-
if((rangeval[1] <= arng[1]) && (arng[2] <= rangeval[2])) {
222-
return(list(argvals=argvals, y=y, basisobj=basisobj))
223-
} else {
217+
errwrd <- FALSE
218+
for (i in 1:length(argvals)) {
219+
argi <- argvals[i]
220+
if (argi < rangeval[1] && argi >= rangeval[1]-delta) {
221+
argi <- rangeval[1]
222+
} else {
223+
errwrd <- TRUE
224+
}
225+
if (argi > rangeval[2] && argi <= rangeval[2]+delta) {
226+
argi <- rangeval[2]
227+
} else {
228+
errwrd <- TRUE
229+
}
230+
}
231+
if (errwrd) {
224232
# error message
225-
stop("There are argvals not contained within basisobj$rangeval")
233+
stop("There are argvals not contained within interval basisobj$rangeval")
226234
}
227235

228236
}

man/Data2fd.Rd

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
The roughness is essentially controlled by how many basis functions are used.
114114
In more sophisticated applications, it would be better to use the function
115115
\code{\link{smooth.basisPar}}.
116+
117+
It may happen that a value in argvals is outside the basis object interval
118+
due to rounding error and other causes of small violations. The code tests
119+
for this and pulls these near values into the interval if they are within
120+
1e-7 times the interval width.
116121
}
117122
118123
\value{

0 commit comments

Comments
 (0)