R/knots_mat2list.R

Defines functions knots_mat2list

Documented in knots_mat2list

##' convert the knots matrix into the knots list
##'
##' @export
knots_mat2list <- function(knots.mat, splineArgs)
  {
    out <- list()
    comp <- splineArgs$comp
    knots.remain <- knots.mat

    if("thinplate.s" %in% comp)
      {
        ks <- splineArgs$thinplate.s.dim[1]
        m <- splineArgs$thinplate.s.dim[2]

        knots4s.idx <- 1:(ks*m)
        knots4s <- knots.mat[knots4s.idx]
        knots.remain <- knots.remain[-(knots4s.idx)]
        out[["thinplate.s"]] <- matrix(knots4s, ks, m, byrow = TRUE)
      }

    if("thinplate.a" %in% comp)
      {
        ka <- sum(splineArgs$thinplate.a.locate)

        knots4a.idx <- 1:ka
        knots4a <- knots.remain[knots4a.idx]

        knots.remain <- knots.remain[-(knots4a.idx)]
        out[["thinplate.a"]] <- matrix(knots4a, , 1)
      }
    return(out)
  }
##----------------------------------------------------------------------------------------
## TESTS:
##----------------------------------------------------------------------------------------
thiyangt/fformpp documentation built on Jan. 5, 2024, 5:44 a.m.