Function File: B = funm (A, F)

Compute matrix equivalent of function F; F can be a function name or a function handle and A must be a square matrix.

For trigonometric and hyperbolic functions, thfm is automatically invoked as that is based on expm and diagonalization is avoided. For other functions diagonalization is invoked, which implies that -depending on the properties of input matrix A- the results can be very inaccurate without any warning. For easy diagonizable and stable matrices results of funm will be sufficiently accurate.

Note that you should not use funm for ’sqrt’, ’log’ or ’exp’; instead use sqrtm, logm and expm as these are more robust.

Examples:

  B = funm (A, sin);
  (Compute matrix equivalent of sin() )
  function bk1 = besselk1 (x)
     bk1 = besselk(1, x);
  endfunction 
  B = funm (A, besselk1);
  (Compute matrix equivalent of bessel function K1();
   a helper function is needed here to convey extra
   arguments for besselk() )

See also: thfm, expm, logm, sqrtm.

Package: linear-algebra