comparison libinterp/corefcn/lu.cc @ 21966:112b20240c87

move docstrings in C++ files out of C strings and into comments * __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, cellfun.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, det.cc, dirfns.cc, dlmread.cc, dot.cc, eig.cc, ellipj.cc, error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, graphics.cc, hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc, ls-oct-text.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mgorth.cc, nproc.cc, oct-hist.cc, octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, ov-base.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-range.cc, ov-re-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, octave.cc, pt-arg-list.cc, pt-binop.cc, pt-eval.cc, pt-mat.cc, lex.ll, oct-parse.in.yy: Docstrings are now comments instead of C strings. * build-aux/mk-opts.pl: Emit docstrings as comments instead of C strings. * DASPK-opts.in, LSODE-opts.in: Don't quote " in docstring fragments. * builtins.h: Include builtin-defun-decls.h unconditionally. * defun.h (DEFUN, DEFUNX, DEFCONSTFUN): Simply emit declaration. (DEFALIAS): Always expand to nothing. * defun-dld.h: No special macro expansions for MAKE_BUILTINS. (DEFUN_DLD): Use FORWARD_DECLARE_FUN. (DEFUNX_DLD): Use FORWARD_DECLARE_FUNX. * defun-int.h: No special macro expansions for MAKE_BUILTINS. (FORWARD_DECLARE_FUN, FORWARD_DECLARE_FUNX): New macros. (DEFINE_FUN_INSTALLER_FUN): If compiling an Octave source file, pass "external-doc" to DEFINE_FUNX_INSTALLER_FUN. (DEFUN_INTERNAL, DEFCONSTFUN_INTERNAL, DEFUNX_INTERNAL, DEFALIAS_INTERNAL): Delete. * common.mk (move_if_change_rule): New macro. (simple_move_if_change_rule): Define using move_if_change_rule. * find-defun-files.sh (DEFUN_PATTERN): Update. Don't transform file name extension to ".df". * libinterp/mk-pkg-add, gendoc.pl: Operate directly on source files. * mkbuiltins: New argument, SRCDIR. Operate directly on source files. * mkdefs: Delete. * libinterp/module.mk (BUILT_SOURCES): Update list to contain only files included in other source files. (GENERATED_MAKE_BUILTINS_INCS, DEF_FILES): Delete. (LIBINTERP_BUILT_DISTFILES): Include $(OPT_HANDLERS) here. (LIBINTERP_BUILT_NODISTFILES): Not here. Remove $(ALL_DEF_FILES from the list. (libinterp_EXTRA_DIST): Remove mkdefs from the list. (FOUND_DEFUN_FILES): Rename from SRC_DEF_FILES. (DLDFCN_DEFUN_FILES): Rename from DLDFCN_DEF_FILES. (SRC_DEFUN_FILES): Rename from SRC_DEF_FILES. (ALL_DEFUN_FILES): Rename from ALL_DEF_FILES. (%.df: %.cc): Delete pattern rule. (libinterp/build-env-features.cc, libinterp/builtins.cc, libinterp/dldfcn/PKG_ADD): Use mv instead of move-if-change. (libinterp/builtins.cc, libinterp/builtin-defun-decls.h): Update mkbuiltins command. ($(srcdir)/libinterp/DOCSTRINGS): Update gendoc.pl command. * liboctave/module.mk (BUILT_SOURCES): Don't include liboctave-build-info.cc in the list.
author John W. Eaton <jwe@octave.org>
date Tue, 21 Jun 2016 16:07:51 -0400
parents aba2e6293dd8
children 6ca3acf5fad8
comparison
equal deleted inserted replaced
21965:da218a61ce4a 21966:112b20240c87
56 else 56 else
57 return U; 57 return U;
58 } 58 }
59 59
60 DEFUN (lu, args, nargout, 60 DEFUN (lu, args, nargout,
61 "-*- texinfo -*-\n\ 61 doc: /* -*- texinfo -*-
62 @deftypefn {} {[@var{L}, @var{U}] =} lu (@var{A})\n\ 62 @deftypefn {} {[@var{L}, @var{U}] =} lu (@var{A})
63 @deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} lu (@var{A})\n\ 63 @deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} lu (@var{A})
64 @deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} lu (@var{S})\n\ 64 @deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} lu (@var{S})
65 @deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}, @var{R}] =} lu (@var{S})\n\ 65 @deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}, @var{R}] =} lu (@var{S})
66 @deftypefnx {} {[@dots{}] =} lu (@var{S}, @var{thres})\n\ 66 @deftypefnx {} {[@dots{}] =} lu (@var{S}, @var{thres})
67 @deftypefnx {} {@var{y} =} lu (@dots{})\n\ 67 @deftypefnx {} {@var{y} =} lu (@dots{})
68 @deftypefnx {} {[@dots{}] =} lu (@dots{}, \"vector\")\n\ 68 @deftypefnx {} {[@dots{}] =} lu (@dots{}, "vector")
69 @cindex LU decomposition\n\ 69 @cindex LU decomposition
70 Compute the LU@tie{}decomposition of @var{A}.\n\ 70 Compute the LU@tie{}decomposition of @var{A}.
71 \n\ 71
72 If @var{A} is full then subroutines from @sc{lapack} are used, and if\n\ 72 If @var{A} is full then subroutines from @sc{lapack} are used, and if
73 @var{A} is sparse then @sc{umfpack} is used.\n\ 73 @var{A} is sparse then @sc{umfpack} is used.
74 \n\ 74
75 The result is returned in a permuted form, according to the optional return\n\ 75 The result is returned in a permuted form, according to the optional return
76 value @var{P}. For example, given the matrix @code{a = [1, 2; 3, 4]},\n\ 76 value @var{P}. For example, given the matrix @code{a = [1, 2; 3, 4]},
77 \n\ 77
78 @example\n\ 78 @example
79 [l, u, p] = lu (@var{a})\n\ 79 [l, u, p] = lu (@var{a})
80 @end example\n\ 80 @end example
81 \n\ 81
82 @noindent\n\ 82 @noindent
83 returns\n\ 83 returns
84 \n\ 84
85 @example\n\ 85 @example
86 @group\n\ 86 @group
87 l =\n\ 87 l =
88 \n\ 88
89 1.00000 0.00000\n\ 89 1.00000 0.00000
90 0.33333 1.00000\n\ 90 0.33333 1.00000
91 \n\ 91
92 u =\n\ 92 u =
93 \n\ 93
94 3.00000 4.00000\n\ 94 3.00000 4.00000
95 0.00000 0.66667\n\ 95 0.00000 0.66667
96 \n\ 96
97 p =\n\ 97 p =
98 \n\ 98
99 0 1\n\ 99 0 1
100 1 0\n\ 100 1 0
101 @end group\n\ 101 @end group
102 @end example\n\ 102 @end example
103 \n\ 103
104 The matrix is not required to be square.\n\ 104 The matrix is not required to be square.
105 \n\ 105
106 When called with two or three output arguments and a sparse input matrix,\n\ 106 When called with two or three output arguments and a sparse input matrix,
107 @code{lu} does not attempt to perform sparsity preserving column\n\ 107 @code{lu} does not attempt to perform sparsity preserving column
108 permutations. Called with a fourth output argument, the sparsity\n\ 108 permutations. Called with a fourth output argument, the sparsity
109 preserving column transformation @var{Q} is returned, such that\n\ 109 preserving column transformation @var{Q} is returned, such that
110 @code{@var{P} * @var{A} * @var{Q} = @var{L} * @var{U}}.\n\ 110 @code{@var{P} * @var{A} * @var{Q} = @var{L} * @var{U}}.
111 \n\ 111
112 Called with a fifth output argument and a sparse input matrix,\n\ 112 Called with a fifth output argument and a sparse input matrix,
113 @code{lu} attempts to use a scaling factor @var{R} on the input matrix\n\ 113 @code{lu} attempts to use a scaling factor @var{R} on the input matrix
114 such that\n\ 114 such that
115 @code{@var{P} * (@var{R} \\ @var{A}) * @var{Q} = @var{L} * @var{U}}.\n\ 115 @code{@var{P} * (@var{R} \ @var{A}) * @var{Q} = @var{L} * @var{U}}.
116 This typically leads to a sparser and more stable factorization.\n\ 116 This typically leads to a sparser and more stable factorization.
117 \n\ 117
118 An additional input argument @var{thres}, that defines the pivoting\n\ 118 An additional input argument @var{thres}, that defines the pivoting
119 threshold can be given. @var{thres} can be a scalar, in which case\n\ 119 threshold can be given. @var{thres} can be a scalar, in which case
120 it defines the @sc{umfpack} pivoting tolerance for both symmetric and\n\ 120 it defines the @sc{umfpack} pivoting tolerance for both symmetric and
121 unsymmetric cases. If @var{thres} is a 2-element vector, then the first\n\ 121 unsymmetric cases. If @var{thres} is a 2-element vector, then the first
122 element defines the pivoting tolerance for the unsymmetric @sc{umfpack}\n\ 122 element defines the pivoting tolerance for the unsymmetric @sc{umfpack}
123 pivoting strategy and the second for the symmetric strategy. By default,\n\ 123 pivoting strategy and the second for the symmetric strategy. By default,
124 the values defined by @code{spparms} are used ([0.1, 0.001]).\n\ 124 the values defined by @code{spparms} are used ([0.1, 0.001]).
125 \n\ 125
126 Given the string argument @qcode{\"vector\"}, @code{lu} returns the values\n\ 126 Given the string argument @qcode{"vector"}, @code{lu} returns the values
127 of @var{P} and @var{Q} as vector values, such that for full matrix,\n\ 127 of @var{P} and @var{Q} as vector values, such that for full matrix,
128 @code{@var{A}(@var{P},:) = @var{L} * @var{U}}, and @code{@var{R}(@var{P},:)\n\ 128 @code{@var{A}(@var{P},:) = @var{L} * @var{U}}, and @code{@var{R}(@var{P},:)
129 * @var{A}(:,@var{Q}) = @var{L} * @var{U}}.\n\ 129 * @var{A}(:,@var{Q}) = @var{L} * @var{U}}.
130 \n\ 130
131 With two output arguments, returns the permuted forms of the upper and\n\ 131 With two output arguments, returns the permuted forms of the upper and
132 lower triangular matrices, such that @code{@var{A} = @var{L} * @var{U}}.\n\ 132 lower triangular matrices, such that @code{@var{A} = @var{L} * @var{U}}.
133 With one output argument @var{y}, then the matrix returned by the\n\ 133 With one output argument @var{y}, then the matrix returned by the
134 @sc{lapack} routines is returned. If the input matrix is sparse then the\n\ 134 @sc{lapack} routines is returned. If the input matrix is sparse then the
135 matrix @var{L} is embedded into @var{U} to give a return value similar to\n\ 135 matrix @var{L} is embedded into @var{U} to give a return value similar to
136 the full case. For both full and sparse matrices, @code{lu} loses the\n\ 136 the full case. For both full and sparse matrices, @code{lu} loses the
137 permutation information.\n\ 137 permutation information.
138 @seealso{luupdate, ilu, chol, hess, qr, qz, schur, svd}\n\ 138 @seealso{luupdate, ilu, chol, hess, qr, qz, schur, svd}
139 @end deftypefn") 139 @end deftypefn */)
140 { 140 {
141 int nargin = args.length (); 141 int nargin = args.length ();
142 bool issparse = (nargin > 0 && args(0).is_sparse_type ()); 142 bool issparse = (nargin > 0 && args(0).is_sparse_type ());
143 143
144 if (nargin < 1 || (issparse && nargin > 3) || (! issparse && nargin > 2)) 144 if (nargin < 1 || (issparse && nargin > 3) || (! issparse && nargin > 2))
564 && k == std::min (m, n) 564 && k == std::min (m, n)
565 && (p.is_undefined () || p.rows () == m)); 565 && (p.is_undefined () || p.rows () == m));
566 } 566 }
567 567
568 DEFUN (luupdate, args, , 568 DEFUN (luupdate, args, ,
569 "-*- texinfo -*-\n\ 569 doc: /* -*- texinfo -*-
570 @deftypefn {} {[@var{L}, @var{U}] =} luupdate (@var{L}, @var{U}, @var{x}, @var{y})\n\ 570 @deftypefn {} {[@var{L}, @var{U}] =} luupdate (@var{L}, @var{U}, @var{x}, @var{y})
571 @deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} luupdate (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})\n\ 571 @deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} luupdate (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})
572 Given an LU@tie{}factorization of a real or complex matrix\n\ 572 Given an LU@tie{}factorization of a real or complex matrix
573 @w{@var{A} = @var{L}*@var{U}}, @var{L}@tie{}lower unit trapezoidal and\n\ 573 @w{@var{A} = @var{L}*@var{U}}, @var{L}@tie{}lower unit trapezoidal and
574 @var{U}@tie{}upper trapezoidal, return the LU@tie{}factorization\n\ 574 @var{U}@tie{}upper trapezoidal, return the LU@tie{}factorization
575 of @w{@var{A} + @var{x}*@var{y}.'}, where @var{x} and @var{y} are\n\ 575 of @w{@var{A} + @var{x}*@var{y}.'}, where @var{x} and @var{y} are
576 column vectors (rank-1 update) or matrices with equal number of columns\n\ 576 column vectors (rank-1 update) or matrices with equal number of columns
577 (rank-k update).\n\ 577 (rank-k update).
578 \n\ 578
579 Optionally, row-pivoted updating can be used by supplying a row permutation\n\ 579 Optionally, row-pivoted updating can be used by supplying a row permutation
580 (pivoting) matrix @var{P}; in that case, an updated permutation matrix is\n\ 580 (pivoting) matrix @var{P}; in that case, an updated permutation matrix is
581 returned. Note that if @var{L}, @var{U}, @var{P} is a pivoted\n\ 581 returned. Note that if @var{L}, @var{U}, @var{P} is a pivoted
582 LU@tie{}factorization as obtained by @code{lu}:\n\ 582 LU@tie{}factorization as obtained by @code{lu}:
583 \n\ 583
584 @example\n\ 584 @example
585 [@var{L}, @var{U}, @var{P}] = lu (@var{A});\n\ 585 [@var{L}, @var{U}, @var{P}] = lu (@var{A});
586 @end example\n\ 586 @end example
587 \n\ 587
588 @noindent\n\ 588 @noindent
589 then a factorization of @tcode{@var{A}+@var{x}*@var{y}.'} can be obtained\n\ 589 then a factorization of @tcode{@var{A}+@var{x}*@var{y}.'} can be obtained
590 either as\n\ 590 either as
591 \n\ 591
592 @example\n\ 592 @example
593 [@var{L1}, @var{U1}] = lu (@var{L}, @var{U}, @var{P}*@var{x}, @var{y})\n\ 593 [@var{L1}, @var{U1}] = lu (@var{L}, @var{U}, @var{P}*@var{x}, @var{y})
594 @end example\n\ 594 @end example
595 \n\ 595
596 @noindent\n\ 596 @noindent
597 or\n\ 597 or
598 \n\ 598
599 @example\n\ 599 @example
600 [@var{L1}, @var{U1}, @var{P1}] = lu (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})\n\ 600 [@var{L1}, @var{U1}, @var{P1}] = lu (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})
601 @end example\n\ 601 @end example
602 \n\ 602
603 The first form uses the unpivoted algorithm, which is faster, but less\n\ 603 The first form uses the unpivoted algorithm, which is faster, but less
604 stable. The second form uses a slower pivoted algorithm, which is more\n\ 604 stable. The second form uses a slower pivoted algorithm, which is more
605 stable.\n\ 605 stable.
606 \n\ 606
607 The matrix case is done as a sequence of rank-1 updates; thus, for large\n\ 607 The matrix case is done as a sequence of rank-1 updates; thus, for large
608 enough k, it will be both faster and more accurate to recompute the\n\ 608 enough k, it will be both faster and more accurate to recompute the
609 factorization from scratch.\n\ 609 factorization from scratch.
610 @seealso{lu, cholupdate, qrupdate}\n\ 610 @seealso{lu, cholupdate, qrupdate}
611 @end deftypefn") 611 @end deftypefn */)
612 { 612 {
613 int nargin = args.length (); 613 int nargin = args.length ();
614 614
615 if (nargin != 4 && nargin != 5) 615 if (nargin != 4 && nargin != 5)
616 print_usage (); 616 print_usage ();