-
Notifications
You must be signed in to change notification settings - Fork 1
/
iterchk2.m
39 lines (36 loc) · 1.15 KB
/
iterchk2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [atype,afun,afcnstr] = iterchk(A)
%ITERCHK Checks arguments to iterative methods.
% [ATYPE,AFUN,AFCNSTR] = ITERCHK(A) returns the following:
% ATYPE is either 'matrix', 'function', 'expression' or 'inline object'.
% AFUN is the function name or inline object.
% AFUN is '' if ATYPE is 'matrix'.
% AFCNSTR is the function name if ATYPE is 'function'.
% AFCNSTR is the formula of the function if ATYPE is 'expression' or
% 'inline object'. AFCNSTR is '' if ATYPE is 'matrix'.
%
% See also BICG, BICGSTAB, CGS, GMRES, LSQR, MINRES, PCG, QMR, SYMMLQ.
% Copyright 1984-2013 The MathWorks, Inc.
[afun,afunmsg] = fcnchk(A);
if isempty(afunmsg)
if isa(afun,'inline')
if isa(A,'inline')
atype = 'inline object';
else
atype = 'expression';
end
afcnstr = formula(afun);
else % both function_handles @fun and function names 'fun'
atype = 'function';
if isa(A,'function_handle')
afcnstr = func2str(A);
else
afcnstr = A;
end
end
elseif isa(A,'float')
afun = A;
atype = 'matrix';
afcnstr = '';
else
error(message('MATLAB:iterchk:InvalidInput'));
end