Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gebhardt, Albrecht
akima
Commits
c477e6bb
Commit
c477e6bb
authored
Jan 31, 2006
by
agebhard
Browse files
fix interpp.new
drop ncp parameter
parent
b7940cf6
Changes
5
Hide whitespace changes
Inline
Side-by-side
R/interp.R
View file @
c477e6bb
interp
<-
function
(
x
,
y
,
z
,
xo
=
seq
(
min
(
x
),
max
(
x
),
length
=
40
),
yo
=
seq
(
min
(
y
),
max
(
y
),
length
=
40
),
ncp
=
0
,
extrap
=
FALSE
,
duplicate
=
"error"
,
dupfun
=
NULL
)
yo
=
seq
(
min
(
y
),
max
(
y
),
length
=
40
),
linear
=
TRUE
,
extrap
=
FALSE
,
duplicate
=
"error"
,
dupfun
=
NULL
,
ncp
=
NULL
)
{
if
(
ncp
==
0
)
# for backward compatibility
if
(
!
is.null
(
ncp
)){
warning
(
'use of \'ncp\' parameter is deprecated!'
)
if
(
ncp
==
0
)
linear
<-
TRUE
else
if
(
ncp
>
0
)
linear
<-
FALSE
else
stop
(
'ncp < 0 ?'
)
}
if
(
linear
)
## use the old version for linear interpolation
interp.old
(
x
,
y
,
z
,
xo
=
xo
,
yo
=
yo
,
ncp
=
ncp
,
interp.old
(
x
,
y
,
z
,
xo
=
xo
,
yo
=
yo
,
ncp
=
0
,
extrap
=
extrap
,
duplicate
=
duplicate
,
dupfun
=
dupfun
)
else
## use the new one
interp.new
(
x
,
y
,
z
,
xo
=
xo
,
yo
=
yo
,
linear
=
FALSE
,
...
...
R/interpp.R
View file @
c477e6bb
"interpp"
<-
function
(
x
,
y
,
z
,
xo
,
yo
,
ncp
=
0
,
extrap
=
FALSE
,
duplicate
=
"error"
,
dupfun
=
NULL
)
"interpp"
<-
function
(
x
,
y
,
z
,
xo
,
yo
,
linear
=
TRUE
,
extrap
=
FALSE
,
duplicate
=
"error"
,
dupfun
=
NULL
,
ncp
=
NULL
)
{
# interpp.new has some bugs at the moment (segfaults), so use
# the old Akima code:
interpp.old
(
x
,
y
,
z
,
xo
,
yo
,
ncp
,
extrap
,
duplicate
,
dupfun
)
# for backward compatibility
if
(
!
is.null
(
ncp
)){
warning
(
'use of \'ncp\' parameter is deprecated!'
)
if
(
ncp
==
0
)
linear
<-
TRUE
else
if
(
ncp
>
0
)
linear
<-
FALSE
else
stop
(
'ncp < 0 ?'
)
}
if
(
linear
)
# the old Akima code:
interpp.old
(
x
,
y
,
z
,
xo
,
yo
,
ncp
=
0
,
extrap
,
duplicate
,
dupfun
)
else
# new code for splines
interpp.new
(
x
,
y
,
z
,
xo
,
yo
,
extrap
,
duplicate
,
dupfun
)
}
R/interpp.new.R
View file @
c477e6bb
"interpp.new"
<-
function
(
x
,
y
,
z
,
xo
,
yo
,
ncp
=
0
,
extrap
=
FALSE
,
"interpp.new"
<-
function
(
x
,
y
,
z
,
xo
,
yo
,
extrap
=
FALSE
,
duplicate
=
"error"
,
dupfun
=
NULL
)
{
if
(
!
(
all
(
is.finite
(
x
))
&&
all
(
is.finite
(
y
))
&&
all
(
is.finite
(
z
))))
...
...
@@ -7,10 +7,9 @@
stop
(
"xo missing"
)
if
(
is.null
(
yo
))
stop
(
"yo missing"
)
if
(
ncp
>
25
){
ncp
<-
25
cat
(
"ncp too large, using ncp=25\n"
)
}
drx
<-
diff
(
range
(
x
))
dry
<-
diff
(
range
(
y
))
if
(
drx
==
0
||
dry
==
0
)
...
...
@@ -58,11 +57,9 @@
storage.mode
(
zo
)
<-
"double"
miss
<-
!
extrap
#if not extrapolating use missing values
extrap
<-
seq
(
TRUE
,
np
)
if
(
extrap
&
ncp
==
0
)
warning
(
"Cannot extrapolate with linear option"
)
ans
<-
.Fortran
(
"sdbi3p"
,
as.integer
(
1
),
# as.integer(ncp),
as.integer
(
n
),
as.double
(
x
),
as.double
(
y
),
...
...
@@ -71,11 +68,12 @@
x
=
as.double
(
xo
),
y
=
as.double
(
yo
),
z
=
zo
,
double
(
17
*
n
),
integer
(
25
*
n
),
ier
=
integer
(
1
),
wk
=
double
(
17
*
n
),
iwk
=
integer
(
25
*
n
),
extrap
=
as.logical
(
extrap
),
near
=
integer
(
n
),
n
e
t
=
integer
(
n
),
n
x
t
=
integer
(
n
),
dist
=
double
(
n
),
PACKAGE
=
"akima"
)
temp
<-
ans
[
c
(
"x"
,
"y"
,
"z"
,
"extrap"
)]
...
...
man/interp.Rd
View file @
c477e6bb
...
...
@@ -12,7 +12,7 @@
\usage{
interp(x, y, z, xo=seq(min(x), max(x), length = 40),
yo=seq(min(y), max(y), length = 40),
ncp = 0
, extrap=FALSE, duplicate = "error", dupfun = NULL)
linear = TRUE
, extrap=FALSE, duplicate = "error", dupfun =
NULL, ncp =
NULL)
interp.old(x, y, z, xo= seq(min(x), max(x), length = 40),
yo=seq(min(y), max(y), length = 40), ncp = 0,
extrap=FALSE, duplicate = "error", dupfun = NULL)
...
...
@@ -53,8 +53,12 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40),
}
\item{yo}{vector of y-coordinates of output grid; analogous to
\code{xo}, see above.}
\item{linear}{logical, switch to linear interpolation in \code{interp.new}.}
\item{linear}{logical -- indicating wether linear or spline
interpolation should be used. supersedes old \code{ncp} parameter}
\item{ncp}{
deprecated, use parameter \code{linear}.
meaning was:
number of additional points to be used in computing partial
derivatives at each data point.
\code{ncp} must be either \code{0} (partial derivatives are not used), or at
...
...
man/interpp.Rd
View file @
c477e6bb
...
...
@@ -6,7 +6,8 @@
\alias{interpp.old}
\alias{interpp.new}
\usage{
interpp(x, y, z, xo, yo, ncp=0, extrap=FALSE, duplicate = "error", dupfun = NULL)
interpp(x, y, z, xo, yo, linear=TRUE, extrap=FALSE, duplicate = "error",
dupfun = NULL, ncp)
}
\arguments{
\item{x}{
...
...
@@ -33,18 +34,22 @@ interpp(x, y, z, xo, yo, ncp=0, extrap=FALSE, duplicate = "error", dupfun = NULL
\item{yo}{
vector of y-coordinates of points at which to evaluate the interpolating
function.}
\item{ncp}{
number of additional points to be used in computing partial
derivatives at each data point.
\code{ncp} must be either \code{0} (partial derivatives are not used, =
linear interpolation), or at
least 2 but smaller than the number of data points (and smaller than 25).
}
\item{extrap}{
logical flag: should extrapolation be used outside of the
convex hull determined by the data points?}
\item{duplicate}{
\item{linear}{logical -- indicating wether linear or spline
interpolation should be used. supersedes old \code{ncp} parameter}
\item{ncp}{
deprecated, use parameter \code{linear}.
meaning was:
number of additional points to be used in computing partial
derivatives at each data point.
\code{ncp} must be either \code{0} (partial derivatives are not used, =
linear interpolation), or at
least 2 but smaller than the number of data points (and smaller than 25).
}
\item{extrap}{
logical flag: should extrapolation be used outside of the
convex hull determined by the data points?}
\item{duplicate}{
indicates how to handle duplicate data points. Possible values are
\code{"error"} - produces an error message, \code{"strip"} - remove
duplicate z values, \code{"mean"},\code{"median"},\code{"user"} -
...
...
@@ -115,5 +120,10 @@ interpp(x, y, z, xo, yo, ncp=0, extrap=FALSE, duplicate = "error", dupfun = NULL
data(akima)
# linear interpolation at points (1,2), (5,6) and (10,12)
akima.lip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12))
akima.lip$z
# spline interpolation
akima.lip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12),
linear=FALSE)
akima.lip$z
}
\keyword{dplot}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment