-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathint2Lfd.R
52 lines (37 loc) · 1.32 KB
/
int2Lfd.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
int2Lfd <- function(m=0)
{
#INT2LFD converts a nonnegative integer to a linear differential
# operator object that is equivalent to D^m. The range of the
# functional data object in any cell is set to [0,1], and is
# not actually used when a linear differential operator object
# of this nature is applied.
# In the event that m is already a linear differential operator
# object, it returns the object immediately. Thus, INT2LFD can
# be used to screen whether an object is an integer or not.
# Last modified 17 September 2005
# check M
if (inherits(m, "Lfd")) {
Lfdobj <- m
return(Lfdobj)
}
if (!is.numeric(m))
stop("Argument not numeric and not a linear differential operator.")
if (length(m) != 1) stop("Argument is not a scalar.")
if (round(m) != m) stop("Argument is not an integer.")
if (m < 0) stop("Argument is negative.")
# all the checks passed, set up a functional data object
# The range will not be used in this case, and can be set
# to [0, 1]
# set up the list object for the homogeneous part
if (m==0) {
# if derivative is zero, BWTLIST is empty
bwtlist <- NULL
} else {
basisobj <- create.constant.basis(c(0,1))
bwtlist <- vector("list", m)
for (j in 1:m) bwtlist[[j]] <- fd(0, basisobj)
}
# define the Lfd object
Lfdobj <- Lfd(m, bwtlist)
return(Lfdobj)
}