39 DEFUN (inv, args, nargout,
41 @deftypefn {Built-in Function} {@var{x} =} inv (@var{A})\n\
42 @deftypefnx {Built-in Function} {[@var{x}, @var{rcond}] =} inv (@var{A})\n\
43 Compute the inverse of the square matrix @var{A}. Return an estimate\n\
44 of the reciprocal condition number if requested, otherwise warn of an\n\
45 ill-conditioned matrix if the reciprocal condition number is small.\n\
47 In general it is best to avoid calculating the inverse of a matrix\n\
48 directly. For example, it is both faster and more accurate to solve\n\
49 systems of equations (@var{A}*@math{x} = @math{b}) with\n\
50 @code{@var{y} = @var{A} \\ @math{b}}, rather than\n\
51 @code{@var{y} = inv (@var{A}) * @math{b}}.\n\
53 If called with a sparse matrix, then in general @var{x} will be a full\n\
54 matrix requiring significantly more storage. Avoid forming the inverse\n\
55 of a sparse matrix if possible.\n\
56 @seealso{ldivide, rdivide}\n\
61 int nargin = args.
length ();
74 int arg_is_empty =
empty_arg (
"inverse", nr, nc);
78 else if (arg_is_empty > 0)
142 result = m.
inverse (mattyp, info, frcond, 1);
143 args(0).matrix_type (mattyp);
152 result = m.
inverse (mattyp, info, frcond, 1);
153 args(0).matrix_type (mattyp);
167 result = m.
inverse (mattyp, info, rcond, 1);
168 args(0).matrix_type (mattyp);
177 result = m.
inverse (mattyp, info, rcond, 1);
178 args(0).matrix_type (mattyp);
190 result = m.
inverse (mattyp, info, rcond, 1);
191 args(0).matrix_type (mattyp);
200 result = m.
inverse (mattyp, info, rcond, 1);
201 args(0).matrix_type (mattyp);
216 volatile double xrcond = rcond;
218 if (nargout < 2 && (info == -1 || xrcond == 1.0))
219 warning (
"inverse: matrix singular to machine precision, rcond = %g",
239 DEFUN (inverse, args, nargout,
241 @deftypefn {Built-in Function} {@var{x} =} inverse (@var{A})\n\
242 @deftypefnx {Built-in Function} {[@var{x}, @var{rcond}] =} inverse (@var{A})\n\
243 Compute the inverse of the square matrix @var{A}.\n\
245 This is an alias for @code{inv}.\n\
249 return Finv (args, nargout);