Mercurial > octave
annotate libinterp/dldfcn/symbfact.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 | 55f7de37b618 |
children | bac0d6f07a3e |
rev | line source |
---|---|
5506 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19139
diff
changeset
|
3 Copyright (C) 2005-2015 David Bateman |
11523 | 4 Copyright (C) 1998-2005 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5506 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5506 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5506 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21229
diff
changeset
|
25 # include "config.h" |
5506 | 26 #endif |
27 | |
21186
7f35125714b4
don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents:
21145
diff
changeset
|
28 #include "oct-locbuf.h" |
7f35125714b4
don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents:
21145
diff
changeset
|
29 #include "oct-sparse.h" |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
30 #include "oct-spparms.h" |
21186
7f35125714b4
don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents:
21145
diff
changeset
|
31 #include "sparse-chol.h" |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
32 #include "sparse-util.h" |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
33 |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
34 #include "ov-re-sparse.h" |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
35 #include "ov-cx-sparse.h" |
5506 | 36 #include "defun-dld.h" |
37 #include "error.h" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
38 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
39 #include "ovl.h" |
5506 | 40 #include "utils.h" |
41 | |
42 DEFUN_DLD (symbfact, args, nargout, | |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
43 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
44 @deftypefn {} {[@var{count}, @var{h}, @var{parent}, @var{post}, @var{R}] =} symbfact (@var{S}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
45 @deftypefnx {} {[@dots{}] =} symbfact (@var{S}, @var{typ}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
46 @deftypefnx {} {[@dots{}] =} symbfact (@var{S}, @var{typ}, @var{mode}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
47 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
48 Perform a symbolic factorization analysis of the sparse matrix @var{S}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
49 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
50 The input variables are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
51 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
52 @table @var |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
53 @item S |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
54 @var{S} is a real or complex sparse matrix. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
55 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
56 @item typ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
57 Is the type of the factorization and can be one of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
58 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
59 @table @asis |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
60 @item @qcode{"sym"} (default) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
61 Factorize @var{S}. Assumes @var{S} is symmetric and uses the upper |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
62 triangular portion of the matrix. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
63 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
64 @item @qcode{"col"} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
65 Factorize @tcode{@var{S}' * @var{S}}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
66 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
67 @item @qcode{"row"} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
68 Factorize @tcode{@var{S} * @var{S}'}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
69 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
70 @item @qcode{"lo"} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
71 Factorize @tcode{@var{S}'}. Assumes @var{S} is symmetric and uses the lower |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
72 triangular portion of the matrix. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
73 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
74 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
75 @item mode |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
76 When @var{mode} is unspecified return the Cholesky@tie{}factorization for |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
77 @var{R}. If @var{mode} is @qcode{"lower"} or @qcode{"L"} then return |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
78 the conjugate transpose @tcode{@var{R}'} which is a lower triangular factor. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
79 The conjugate transpose version is faster and uses less memory, but still |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
80 returns the same values for all other outputs: @var{count}, @var{h}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
81 @var{parent}, and @var{post}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
82 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
83 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
84 The output variables are: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
85 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
86 @table @var |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
87 @item count |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
88 The row counts of the Cholesky@tie{}factorization as determined by |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
89 @var{typ}. The computational difficulty of performing the true |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
90 factorization using @code{chol} is @code{sum (@var{count} .^ 2)}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
91 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
92 @item h |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
93 The height of the elimination tree. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
94 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
95 @item parent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
96 The elimination tree itself. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
97 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
98 @item post |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
99 A sparse boolean matrix whose structure is that of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
100 Cholesky@tie{}factorization as determined by @var{typ}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
101 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
102 @seealso{chol, etree, treelayout} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
103 @end deftypefn */) |
5506 | 104 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
105 #if defined (HAVE_CHOLMOD) |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
106 |
5506 | 107 int nargin = args.length (); |
108 | |
21585 | 109 if (nargin < 1 || nargin > 3) |
20790
c2d9556d51d0
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
110 print_usage (); |
5506 | 111 |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
112 octave_value_list retval; |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21585
diff
changeset
|
113 |
5506 | 114 double dummy; |
115 cholmod_sparse Astore; | |
116 cholmod_sparse *A = &Astore; | |
5527 | 117 A->packed = true; |
118 A->sorted = true; | |
7520 | 119 A->nz = 0; |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
120 #if defined (OCTAVE_ENABLE_64) |
5506 | 121 A->itype = CHOLMOD_LONG; |
122 #else | |
123 A->itype = CHOLMOD_INT; | |
124 #endif | |
125 A->dtype = CHOLMOD_DOUBLE; | |
126 A->stype = 1; | |
127 A->x = &dummy; | |
128 | |
129 if (args(0).is_real_type ()) | |
130 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
131 const SparseMatrix a = args(0).sparse_matrix_value (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
132 A->nrow = a.rows (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
133 A->ncol = a.cols (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
134 A->p = a.cidx (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
135 A->i = a.ridx (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
136 A->nzmax = a.nnz (); |
5506 | 137 A->xtype = CHOLMOD_REAL; |
138 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
139 if (a.rows () > 0 && a.cols () > 0) |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
140 A->x = a.data (); |
5506 | 141 } |
142 else if (args(0).is_complex_type ()) | |
143 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
144 const SparseComplexMatrix a = args(0).sparse_complex_matrix_value (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
145 A->nrow = a.rows (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
146 A->ncol = a.cols (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
147 A->p = a.cidx (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
148 A->i = a.ridx (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
149 A->nzmax = a.nnz (); |
5506 | 150 A->xtype = CHOLMOD_COMPLEX; |
151 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
152 if (a.rows () > 0 && a.cols () > 0) |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
153 A->x = a.data (); |
5506 | 154 } |
155 else | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
156 err_wrong_type_arg ("symbfact", args(0)); |
5506 | 157 |
5527 | 158 octave_idx_type coletree = false; |
5506 | 159 octave_idx_type n = A->nrow; |
160 | |
161 if (nargin > 1) | |
162 { | |
21585 | 163 std::string str = args(1).xstring_value ("TYP must be a string"); |
164 // FIXME: The input validation could be improved to use strncmp | |
5506 | 165 char ch; |
21585 | 166 ch = tolower (str[0]); |
167 if (ch == 'r') // 'row' | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
168 A->stype = 0; |
21585 | 169 else if (ch == 'c') // 'col' |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
170 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
171 n = A->ncol; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
172 coletree = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
173 A->stype = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
174 } |
21585 | 175 else if (ch == 's') // 'sym' (default) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
176 A->stype = 1; |
21585 | 177 else if (ch == 'l') // 'lo' |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
178 A->stype = -1; |
5506 | 179 else |
21585 | 180 error ("symbfact: unrecognized TYP \"%s\"", str.c_str ()); |
181 } | |
182 | |
183 if (nargin == 3) | |
184 { | |
185 std::string str = args(2).xstring_value ("MODE must be a string"); | |
186 // FIXME: The input validation could be improved to use strncmp | |
187 char ch; | |
188 ch = toupper (str[0]); | |
189 if (ch != 'L') | |
190 error ("symbfact: unrecognized MODE \"%s\"", str.c_str ()); | |
5506 | 191 } |
192 | |
193 if (A->stype && A->nrow != A->ncol) | |
21110
3d0d84305600
Use err_square_matrix_required more widely.
Rik <rik@octave.org>
parents:
21109
diff
changeset
|
194 err_square_matrix_required ("symbfact", "S"); |
5506 | 195 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
196 OCTAVE_LOCAL_BUFFER (octave_idx_type, Parent, n); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
197 OCTAVE_LOCAL_BUFFER (octave_idx_type, Post, n); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
198 OCTAVE_LOCAL_BUFFER (octave_idx_type, ColCount, n); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
199 OCTAVE_LOCAL_BUFFER (octave_idx_type, First, n); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
200 OCTAVE_LOCAL_BUFFER (octave_idx_type, Level, n); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
201 |
21585 | 202 cholmod_common Common; |
203 cholmod_common *cm = &Common; | |
204 CHOLMOD_NAME(start) (cm); | |
205 | |
206 double spu = octave_sparse_params::get_key ("spumoni"); | |
207 if (spu == 0.) | |
208 { | |
209 cm->print = -1; | |
210 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, 0); | |
211 } | |
212 else | |
213 { | |
214 cm->print = static_cast<int> (spu) + 2; | |
215 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &SparseCholPrint); | |
216 } | |
217 | |
218 cm->error_handler = &SparseCholError; | |
219 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex); | |
220 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot); | |
221 | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
222 cholmod_sparse *F = CHOLMOD_NAME(transpose) (A, 0, cm); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
223 cholmod_sparse *Aup, *Alo; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
224 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
225 if (A->stype == 1 || coletree) |
5506 | 226 { |
21585 | 227 Aup = A; |
228 Alo = F; | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
229 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
230 else |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
231 { |
21585 | 232 Aup = F; |
233 Alo = A; | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
234 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
235 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
236 CHOLMOD_NAME(etree) (Aup, Parent, cm); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
237 |
21585 | 238 ColumnVector tmp (n); // Declaration must precede any goto cleanup. |
239 std::string err_msg; | |
240 | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
241 if (cm->status < CHOLMOD_OK) |
21585 | 242 { |
243 err_msg = "symbfact: matrix corrupted"; | |
244 goto cleanup; | |
245 } | |
5506 | 246 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
247 if (CHOLMOD_NAME(postorder) (Parent, n, 0, Post, cm) != n) |
21585 | 248 { |
249 err_msg = "symbfact: postorder failed"; | |
250 goto cleanup; | |
251 } | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
252 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
253 CHOLMOD_NAME(rowcolcounts) (Alo, 0, 0, Parent, Post, 0, |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
254 ColCount, First, Level, cm); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
255 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
256 if (cm->status < CHOLMOD_OK) |
21585 | 257 { |
258 err_msg = "symbfact: matrix corrupted"; | |
259 goto cleanup; | |
260 } | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
261 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
262 if (nargout > 4) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
263 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
264 cholmod_sparse *A1, *A2; |
5506 | 265 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
266 if (A->stype == 1) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
267 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
268 A1 = A; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
269 A2 = 0; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
270 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
271 else if (A->stype == -1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
272 { |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
273 A1 = F; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
274 A2 = 0; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
275 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
276 else if (coletree) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
277 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
278 A1 = F; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
279 A2 = A; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
280 } |
5506 | 281 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
282 { |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
283 A1 = A; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
284 A2 = F; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
285 } |
5506 | 286 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
287 // count the total number of entries in L |
21585 | 288 octave_idx_type lnz = 0; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
289 for (octave_idx_type j = 0 ; j < n ; j++) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
290 lnz += ColCount[j]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
291 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
292 // allocate the output matrix L (pattern-only) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
293 SparseBoolMatrix L (n, n, lnz); |
5506 | 294 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
295 // initialize column pointers |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
296 lnz = 0; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
297 for (octave_idx_type j = 0 ; j < n ; j++) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
298 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
299 L.xcidx(j) = lnz; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
300 lnz += ColCount[j]; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
301 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
302 L.xcidx(n) = lnz; |
5506 | 303 |
20946 | 304 // create a copy of the column pointers |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
305 octave_idx_type *W = First; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
306 for (octave_idx_type j = 0 ; j < n ; j++) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
307 W[j] = L.xcidx (j); |
5506 | 308 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
309 // get workspace for computing one row of L |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
310 cholmod_sparse *R |
21585 | 311 = CHOLMOD_NAME(allocate_sparse) (n, 1, n, false, true, |
312 0, CHOLMOD_PATTERN, cm); | |
313 octave_idx_type *Rp = static_cast<octave_idx_type *> (R->p); | |
314 octave_idx_type *Ri = static_cast<octave_idx_type *> (R->i); | |
5506 | 315 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
316 // compute L one row at a time |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
317 for (octave_idx_type k = 0 ; k < n ; k++) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
318 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
319 // get the kth row of L and store in the columns of L |
21585 | 320 CHOLMOD_NAME(row_subtree) (A1, A2, k, Parent, R, cm); |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
321 for (octave_idx_type p = 0 ; p < Rp[1] ; p++) |
21585 | 322 L.xridx (W[Ri[p]]++) = k; |
5506 | 323 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
324 // add the diagonal entry |
21585 | 325 L.xridx (W[k]++) = k; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
326 } |
5506 | 327 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
328 // free workspace |
21585 | 329 CHOLMOD_NAME(free_sparse) (&R, cm); |
5506 | 330 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
331 // transpose L to get R, or leave as is |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
332 if (nargin < 3) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
333 L = L.transpose (); |
5506 | 334 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
335 // fill numerical values of L with one's |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
336 for (octave_idx_type p = 0 ; p < lnz ; p++) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
337 L.xdata(p) = true; |
5506 | 338 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
339 retval(4) = L; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
340 } |
5506 | 341 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
342 if (nargout > 3) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
343 { |
5506 | 344 for (octave_idx_type i = 0; i < n; i++) |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
345 tmp(i) = Post[i] + 1; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
346 retval(3) = tmp; |
5506 | 347 } |
348 | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
349 if (nargout > 2) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
350 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
351 for (octave_idx_type i = 0; i < n; i++) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
352 tmp(i) = Parent[i] + 1; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
353 retval(2) = tmp; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
354 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
355 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
356 if (nargout > 1) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
357 { |
20946 | 358 // compute the elimination tree height |
21585 | 359 octave_idx_type height = 0; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
360 for (int i = 0 ; i < n ; i++) |
21585 | 361 height = std::max (height, Level[i]); |
362 height++; | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
363 retval(1) = static_cast<double> (height); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
364 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
365 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
366 for (octave_idx_type i = 0; i < n; i++) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
367 tmp(i) = ColCount[i]; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
368 retval(0) = tmp; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
369 |
21585 | 370 cleanup: |
371 CHOLMOD_NAME(free_sparse) (&F, cm); | |
372 CHOLMOD_NAME(finish) (cm); | |
373 | |
374 if (! err_msg.empty ()) | |
375 error (err_msg.c_str ()); | |
376 | |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20898
diff
changeset
|
377 return retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20898
diff
changeset
|
378 |
5512 | 379 #else |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
380 |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
381 octave_unused_parameter (args); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
382 octave_unused_parameter (nargout); |
21937
55f7de37b618
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
383 |
21109
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
384 err_disabled_feature ("symbfact", "CHOLMOD"); |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
385 |
5512 | 386 #endif |
5506 | 387 } |
21585 | 388 |
389 /* | |
390 %!testif HAVE_CHOLMOD | |
391 %! A = sparse (magic (3)); | |
392 %! [count, h, parent, post, r] = symbfact (A); | |
393 %! assert (count, [3; 2; 1]); | |
394 %! assert (h, 3); | |
395 %! assert (parent, [2; 3; 0]); | |
396 %! assert (r, sparse (triu (true (3)))); | |
397 | |
398 %!testif HAVE_CHOLMOD | |
399 %! ## Test MODE "lower" | |
400 %! A = sparse (magic (3)); | |
401 %! [~, ~, ~, ~, l] = symbfact (A, "sym", "lower"); | |
402 %! assert (l, sparse (tril (true (3)))); | |
403 | |
404 %!testif HAVE_CHOLMOD | |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21585
diff
changeset
|
405 %! ## Bug #42587, singular matrix |
21585 | 406 %! A = sparse ([1 0 8;0 1 8;8 8 1]); |
407 %! [count, h, parent, post, r] = symbfact (A); | |
408 | |
409 ## Test input validation | |
410 %!testif HAVE_CHOLMOD | |
411 %! fail ("symbfact ()"); | |
412 %! fail ("symbfact (1,2,3,4)"); | |
413 %! fail ("symbfact ({1})", "wrong type argument 'cell'"); | |
414 %! fail ("symbfact (sparse (1), {1})", "TYP must be a string"); | |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21585
diff
changeset
|
415 %! fail ("symbfact (sparse (1), 'foobar')", 'unrecognized TYP "foobar"'); |
21585 | 416 %! fail ("symbfact (sparse (1), 'sym', {'L'})", "MODE must be a string"); |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21585
diff
changeset
|
417 %! fail ('symbfact (sparse (1), "sym", "foobar")', 'unrecognized MODE "foobar"'); |
21585 | 418 %! fail ("symbfact (sparse ([1, 2; 3, 4; 5, 6]))", "S must be a square matrix"); |
419 | |
420 */ |