https://github.com/cran/fields
Raw File
Tip revision: a90a276958eddf06f679a66612277cb9e1b2c7ad authored by Doug Nychka on 23 June 2011, 05:46:58 UTC
version 6.5.2
Tip revision: a90a276
fields.mkpoly.R
# fields, Tools for spatial data
# Copyright 2004-2011, 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 <- .Fortran("mkpoly", as.integer(m), as.integer(d), 
#        nterms = as.integer(0), PACKAGE = "fields")$nterms
#    print(nterms)
    nterms<- choose((m + d -1),d)
    temp <- .Fortran("dmaket", 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), PACKAGE = "fields")
    temp2 <- matrix(temp$tmatrix, nrow = n)
    attr(temp2, "ptab") <- matrix(temp$ptab, nrow = nterms, ncol = d)
    temp2
}
back to top