Function Matrix

Function vectors or matrices are vectors or matrices whose entries are functions instead of numbers. When they are called, the argument is passed to each element function, the outcome is a vector or matrix built from the return values of each element function call. For example
f = [cos, -sin; sin, cos];
defines a function

>> f = [cos, -sin; sin, cos];
>> f(pi/4)
    0.707    -0.707    
    0.707     0.707
Note that the elements of the matrix can be data of other type that can be used as functions, and are not restricted to functions (user or built-in). As long as one element is a function, the whole matrix is evaluated to a function matrix. The following example creates a function matrix
f = [exp <> cos, 2; x -> sqrt(1 + x^2), exp <> (-sin)]
which represents the following function

Note that <> is the symbol of function composition.

In general, all the elements of a matrix function should have the same number of input arguments, and the return values should be compatible for building a matrix.



oz 2009-12-22