https://github.com/cran/fields
Tip revision: fd0fd2f186c7b6b0721880f6a0061ec076e1be79 authored by Douglas Nychka on 28 February 2015, 06:50:20 UTC
version 8.2-1
version 8.2-1
Tip revision: fd0fd2f
fields.mkpoly.R
# fields, Tools for spatial data
# Copyright 2004-2013, Institute for Mathematics Applied Geosciences
# University Corporation for Atmospheric Research
# Licensed under the GPL -- www.gpl.org/licenses/gpl.html
"fields.mkpoly" <- function(x, m = 2) {
if (m < 1)
stop("'m' has to be larger than zero.")
if (!is.matrix(x))
x <- as.matrix(x)
d <- ncol(x)
n <- nrow(x)
nterms <- choose((m + d - 1), d)
temp <- .Fortran("dmaket",PACKAGE="fields", m = as.integer(m), n = as.integer(n),
dim = as.integer(d), des = as.double(x), lddes = as.integer(n),
npoly = as.integer(nterms), tmatrix = as.double(rep(0,
n * (nterms))), ldt = as.integer(n), wptr = as.integer(rep(0,
d * m)), info = as.integer(0), ptab = as.integer(rep(0,
nterms * d)), ldptab = as.integer(nterms))
temp2 <- matrix(temp$tmatrix, nrow = n)
attr(temp2, "ptab") <- matrix(temp$ptab, nrow = nterms, ncol = d)
temp2
}