No BSD License
-
arnoldi(A,q1,m)
ARNOLDI Arnoldi iteration
-
ascent_seq(A)
ASCENT_SEQ Ascent sequence for square (singular) matrix.
-
cosm(A)
COSM Matrix cosine by double angle algorithm.
-
cosm_pade(A,m,sq)
COSM_PADE Evaluate Pade approximation to the matrix cosine.
-
cosmsinm(A)
COSMSINM Matrix cosine and sine by double angle algorithm.
-
cosmsinm_pade(A,m)
COSMSINM_PADE Evaluate Pade approximations to matrix cosine and sine.
-
expm_cond(A)
EXPM_COND Relative condition number of matrix exponential.
-
expm_frechet_pade(A,E,k)
EXPM_FRECHET_PADE Frechet derivative of matrix exponential via Pade approx.
-
expm_frechet_quad(A,E,theta,r...
EXPM_FRECHET_QUAD Frechet derivative of matrix exponential via quadrature.
-
fab_arnoldi(A,b,fun,m)
FAB_ARNOLDI f(A)*b approximated by Arnoldi method.
-
funm_condest1(A,fun,fun_frech...
FUNM_CONDEST1 Estimate of 1-norm condition number of matrix function.
-
funm_condest_fro(A,fun,fun_fr...
FUNM_CONDEST_FRO Estimate of Frobenius norm condition number of matrix function.
-
funm_ev(A,fun)
FUNM_EV Evaluate general matrix function via eigensystem.
-
funm_simple(A,fun)
FUNM_SIMPLE Simplified Schur-Parlett method for function of a matrix.
-
logm_cond(A)
LOGM_COND Relative condition number of matrix logarithm.
-
logm_frechet_pade(A,E)
LOGM_FRECHET_PADE Frechet derivative of matrix logarithm via Pade approx.
-
logm_iss(A)
LOGM_ISS Matrix logarithm by inverse scaling and squaring method.
-
logm_pade_pf(A,m)
LOGM_PADE_PF Evaluate Pade approximant to matrix log by partial fractions.
-
mft_test(n)
MFT_TEST Test the Matrix Function Toolbox.
-
mft_tolerance(A)
MFT_TOLERANCE Convergence tolerance for matrix iterations.
-
polar_newton(A)
POLAR_NEWTON Polar decomposition by scaled Newton iteration.
-
polar_svd(A)
POLAR_SVD Canonical polar decomposition via singular value decomposition.
-
polyvalm_ps(c,A,s)
POLYVALM_PS Evaluate polynomial at matrix argument by Paterson-Stockmeyer alg.
-
power_binary(A,m)
POWER_BINARY Power of matrix by binary powering (repeated squaring).
-
quasitriang_struct(R)
QUASITRIANG_STRUCT Block structure of upper quasitriangular matrix.
-
riccati_xaxb(A,B)
RICCATI_XAXB Solve Riccati equation XAX = B in positive definite matrices.
-
rootpm_newton(A,p,c)
ROOTPM_NEWTON Coupled Newton iteration for matrix pth root.
-
rootpm_real(A,p)
ROOTPM_REAL Pth root of real matrix via real Schur form.
-
rootpm_schur_newton(A,p)
ROOTPM_SCHUR_NEWTON Matrix pth root by Schur-Newton method.
-
rootpm_sign(A,p)
ROOTPM_SIGN Matrix Pth root via matrix sign function.
-
signm(A)
SIGNM Matrix sign decomposition.
-
signm_newton(A,scal)
SIGNM_NEWTON Matrix sign function by Newton iteration.
-
sqrtm_db(A,scale)
SQRTM_DB Matrix square root by Denman-Beavers iteration.
-
sqrtm_dbp(A,scale)
SQRTM_DBP Matrix square root by product form of Denman-Beavers iteration.
-
sqrtm_newton(A,scal,maxit)
SQRTM_NEWTON Matrix square root by Newton iteration (unstable).
-
sqrtm_newton_full(A, X0)
SQRTM_NEWTON_FULL Matrix square root by full Newton method.
-
sqrtm_pd(A)
SQRTM_PD Square root of positive definite matrix via polar decomposition.
-
sqrtm_pulay(A,D)
SQRTM_PULAY Matrix square root by Pulay iteration.
-
sqrtm_real(A)
SQRTM_REAL Square root of real matrix by real Schur method.
-
sqrtm_triang_min_norm(T)
SQRTM_TRIANG_MIN_NORM Estimated min norm square root of triangular matrix.
-
sylvsol(A,B,C)
SYLVSOL Solve Sylvester equation.
-
Contents.m
-
readme.m
-
View all files
from
The Matrix Function Toolbox
by Nick Higham
A MATLAB toolbox connected with functions of matrices.
|
| cosm(A) |
function [C,cost,s] = cosm(A)
%COSM Matrix cosine by double angle algorithm.
% [C,COST,s] = COSM(A) computes the cosine of the matrix A using the
% double angle algorithm with Pade approximation. The total number of
% matrix multiplications and linear systems solved is returned as
% COST and s specifies the amount of scaling (A is scaled to 2^(-s)*A).
n = length(A);
% theta_m for m=2:2:20.
theta = [0.00613443965526 0.11110098037055 0.43324697422211 0.98367255274344 ...
1.72463663220280 2.61357494421368 3.61521023400301 4.70271938553349 ...
5.85623410320942 7.06109053959248];
s = 0;
B = A^2;
normA2 = sqrt(norm(B,inf));
d = [2 4 6 8 12 16 20];
for i = d(1:6)
if normA2 < theta(i/2)
m = i;
cost = (m<=8)*(m/2+1) + (m==12)*6;
C = cosm_pade(B,m);
s = m;
return
end
end
if normA2 > theta(20/2)
s = ceil( log2( normA2/theta(20/2) ) );
B = B/(4^s);
normA2 = normA2/(2^s);
end
if normA2 > 2*theta(12/2)
m = 20; cost = 8;
elseif normA2 > theta(16/2)
B = B/4; m = 12; cost = 6; s = s+1;
else
m = 16; cost = 7;
end
C = cosm_pade(B,m);
for i = 1:s
C = 2*(C^2) - eye(n);
end
cost = cost+s;
|
|
Contact us at files@mathworks.com