Calculates the general matrix function.
FUNM(a, "fun", tol)
a |
- |
A square matrix. |
"fun" |
- |
A string, the matrix function. |
tol |
- |
Optional. A real, the imaginary value tolerance. Defaults to 1e-9. |
A square matrix.
W1: ravel(1..9, 3)
W2: funm(w1, "sinh")
W3: funm(w2, "asinh")
W1 == {{1, 4, 7},
{2, 5, 8},
{3, 6, 9}}
W2 == {{559452.165, 1266940.566, 1974428.967},
{687407.399, 1556707.149, 2426006.900},
{815362.634, 1846473.733, 2877584.832}}
W3 == {{1, 4, 7},
{2, 5, 8},
{3, 6, 9}}
W2 computes the matrix SINH function and W3 recovers the original matrix by computing the matrix ASINH function.
For square matrix A, the general matrix function F is computed as:
(V, D) = eig(A);
F = V *^ diag(feval(fun, diag(D))) /^ V;
The function string can refer to any unary built-in or user defined function that can operate on scalar values.
The imaginary component of the result is set to zero if all values are less than tol and the input was purely real.
See DADiSP/MatrixXL to significantly optimize FUNM.