TransferFunction: Constructing and Testing TransferFunction Objects

View source: R/TransferFunction.R

TransferFunctionR Documentation

Constructing and Testing TransferFunction Objects

Description

The function TransferFunction() is the constructor for TransferFunction objects.

is.TransferFunction() tests whether an object is a valid TransferFunction object.
as.TransferFunction() converts other variables to a TransferFunction object, and is designed to be overridden by other packages.

Usage

TransferFunction( fun, funinv, domain, range, id=NULL )

is.TransferFunction(x)

## Default S3 method:
as.TransferFunction( ... )

Arguments

fun

a function that accepts a numeric argument, and returns one of the same length. The dimension of fun is determined by the arguments domain and range. The function must be injective and this is checked if the function is univariate. The requirements for univariate and multivariate functions are very different, see Details.

funinv

a function that the inverse for fun. If fun is univariate and funinv=NULL, then an approximation for the inverse is computed using stats::splinefun(). If fun is multivariate and funinv=NULL, then it is an ERROR.

domain

a 2xN matrix, or a numeric vector that can be converted to such a matrix, by column. In each column, the entry in row 1 must be strictly less than the entry in row 2. The columns of domain define N intervals whose product is a box in R^N that is the domain of fun. The box must be finite. If N=1 then the box is just an interval, and fun is univariate. Otherwise, fun is multivariate with dimension N.

range

a 2xN matrix, or a numeric vector that can be converted to such a matrix, by column. The N here must be equal to the N for domain. The matrix defines a box that encloses the image of domain under fun. The box must be finite.

id

a character string that is helpful when printing the object, and in logging messages. If id=NULL then an appropriate string is created from the function call.

x

an R object to test for being a valid TransferFunction object.

...

arguments for use in other packages.

Details

If fun is univariate, then it must be able to accept a numeric vector of any length, and apply the function to each number in the vector; i.e. fun must be vectorized. If a number in the vector is NA, then the function must silently return NA for that number; usually this is not a problem. The function is *not* required to test whether the number is in the domain interval; this is handled by the TransferFunction code.
If fun is multivariate with dimension N, then it must be able to accept a vector of length N and return a vector of length N. It is *not* required to accept an MxN matrix. It is *not* required to test whether the vector is in the domain box.
The function funinv has the same requirements as fun.

Value

TransferFunction() returns a TransferFunction object, or NULL in case of ERROR.

is.TransferFunction() returns TRUE or FALSE. It only checks the class, using base::inherits().

as.TransferFunction.default() issues an ERROR message and returns NULL..

See Also

dimension(), composition(), is.invertible(), metadata(), inverse(), transfer(), orientation(), validate(), print.TransferFunction(), plot.TransferFunction()

Examples

#  make a test TransferFunction

myfun = function(x) {x*x}

test  = TransferFunction( myfun, sqrt, domain=c(0,3), range=c(0,9), id='test.TF' )

#  print it
test
#--------------------   test.TF    ---------------------#
## test.TF is a univariate TransferFunction.
## domain:      [0,3]  (x)
## range:       [0,9]  (y)
## invertible:  Yes
## orientation: preserving
## range-test points = 1300, max(distance)=0.
## validation:  Passed

# and now plot it
plot( test )

spacesRGB documentation built on June 22, 2024, 6:46 p.m.