firstderivative_backwardiff: Partial first derivative in backward difference approximation

Description Usage Arguments Author(s) References Examples

Description

Calculates the partial first derivative of any dependent vector to any independent vector. Returns a Vector

Usage

1
firstderivative_backwardiff(j = 4, Y = matrix(rep(0, 4), nrow = 4, ncol = 1), X = matrix(rep(0, 4), nrow = 4, ncol = 1))

Arguments

j
Y
X

Author(s)

Rafael Ventura

References

Klaus A Hoffmann & Steve T Chiang. Computational Fluid Dynamics Vol 1. Wichita, Kan: Engineering Eductation System, 2000. Junsei Kondo and Nobuko Saigusa. Modelling the Evaporation from Base Soil with a Formula for Vaporization in the Soil Pores. Meteorological Society of Japan.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (j = 4, Y = matrix(rep(0, 4), nrow = 4, ncol = 1), X = matrix(rep(0,
    4), nrow = 4, ncol = 1))
{
    nrow <- dim(X)[[1]]
    jminus1 <- if (j > 1) {
        j - 1
    }
    else {
        1
    }
    paddingj <- matrix(rep(0, nrow - j), nrow = nrow - j, ncol = 1)
    paddingjminus1 <- matrix(rep(0, nrow - jminus1), nrow = nrow -
        jminus1, ncol = 1)
    xj <- rbind(paddingj, X[1:j, , drop = FALSE])
    xjminus1 <- rbind(paddingjminus1, X[1:xminus1, , drop = FALSE])
    yj <- rbind(paddingj, Y[1:j, , drop = FALSE])
    yjminus1 <- rbind(paddingjminus1, X[1:xminus1, , drop = FALSE])
    dxj <- xj - xjminus1
    dydx <- mapply(function(x, y) x/y, yj - yjminus1, dxj)
    return(dydx)
  }

rventuradiaz/baresoilevap documentation built on Nov. 17, 2019, 11:06 a.m.