R/derivs.R

Defines functions derivs

derivs <- function(tnow, y, bwtlist) {
	#  Sets up a linear differential equation of order m
	#  as a system of m first order equations
	#  Arguments:
	#  TNOW    ... A vector of values of the independent variable t
	#  Y       ... A matrix of m values of Y corresponding to TNOW
	#  BWTLIST ... A functional data object containing coefficient functions
	#  Returns:
	#  DY      ... A matrix of derivative values corresponding to Y
	
	#  Last modified:  26 October 2005
	
  m  <- length(bwtlist);
  wmat <- matrix(0, m, m)
  wmat[1:(m-1),2:m] <- diag(rep(1,m-1))
  for (j in 1:m) {
	   bfdParj <- bwtlist[[j]]
	   wj      <- eval.fd(tnow, bfdParj$fd)
	   wmat[m,j] <- -wj
  }
  dy <- wmat %*% y
  return(dy)
}

Try the fda package in your browser

Any scripts or data that you put into this service are public.

fda documentation built on Sept. 30, 2024, 9:19 a.m.