Mercurial > octave
annotate libinterp/corefcn/symbfact.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 83f9f8bda883 |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
3 // Copyright (C) 1998-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
5506 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21229
diff
changeset
|
27 # include "config.h" |
5506 | 28 #endif |
29 | |
23024
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
30 #include <cmath> |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
31 |
25050
e376a35f168f
symfact.cc: Fix use of unitialized SparseBoolMatrix (bug #53507).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
32 #include <algorithm> |
23024
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
33 #include <string> |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
34 |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
35 #include "CSparse.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
36 #include "boolSparse.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
37 #include "dColVector.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
38 #include "dSparse.h" |
21186
7f35125714b4
don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents:
21145
diff
changeset
|
39 #include "oct-locbuf.h" |
7f35125714b4
don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents:
21145
diff
changeset
|
40 #include "oct-sparse.h" |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
41 #include "oct-spparms.h" |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
42 #include "sparse-util.h" |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
43 |
28024
c28b8ba841fb
move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
44 #include "defun.h" |
5506 | 45 #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
|
46 #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
|
47 #include "ovl.h" |
27859
1a75fca6ad5d
Lock amd and symbfact to avoid segmentation fault with SuiteSparse (bug #57435).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26389
diff
changeset
|
48 #include "parse.h" |
5506 | 49 #include "utils.h" |
50 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
51 OCTAVE_BEGIN_NAMESPACE(octave) |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29872
diff
changeset
|
52 |
28024
c28b8ba841fb
move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
53 DEFUN (symbfact, args, nargout, |
c28b8ba841fb
move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
54 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
55 @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
|
56 @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
|
57 @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
|
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 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
|
60 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
61 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
|
62 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
63 @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
|
64 @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
|
65 @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
|
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 typ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
68 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
|
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 @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
|
71 @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
|
72 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
|
73 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
|
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 @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
|
76 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
|
77 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
78 @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
|
79 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
|
80 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
81 @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
|
82 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
|
83 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
|
84 @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
|
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 @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
|
87 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
|
88 @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
|
89 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
|
90 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
|
91 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
|
92 @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
|
93 @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
|
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 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
|
96 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
97 @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
|
98 @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
|
99 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
|
100 @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
|
101 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
|
102 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
103 @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
|
104 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
|
105 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
106 @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
|
107 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
|
108 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21937
diff
changeset
|
109 @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
|
110 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
|
111 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
|
112 @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
|
113 @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
|
114 @end deftypefn */) |
5506 | 115 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
116 #if defined (HAVE_CHOLMOD) |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
117 |
5506 | 118 int nargin = args.length (); |
119 | |
21585 | 120 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
|
121 print_usage (); |
5506 | 122 |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
123 octave_value_list retval; |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21585
diff
changeset
|
124 |
5506 | 125 double dummy; |
126 cholmod_sparse Astore; | |
127 cholmod_sparse *A = &Astore; | |
5527 | 128 A->packed = true; |
129 A->sorted = true; | |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
130 A->nz = nullptr; |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
131 #if defined (OCTAVE_ENABLE_64) |
5506 | 132 A->itype = CHOLMOD_LONG; |
133 #else | |
134 A->itype = CHOLMOD_INT; | |
135 #endif | |
136 A->dtype = CHOLMOD_DOUBLE; | |
137 A->stype = 1; | |
138 A->x = &dummy; | |
139 | |
29390
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
140 SparseMatrix sm; |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
141 SparseComplexMatrix scm; |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
142 |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23581
diff
changeset
|
143 if (args(0).isreal ()) |
5506 | 144 { |
29390
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
145 sm = args(0).sparse_matrix_value (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
146 A->nrow = sm.rows (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
147 A->ncol = sm.cols (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
148 A->p = sm.cidx (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
149 A->i = sm.ridx (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
150 A->nzmax = sm.nnz (); |
5506 | 151 A->xtype = CHOLMOD_REAL; |
152 | |
29390
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
153 if (A->nrow > 0 && A->ncol > 0) |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
154 A->x = sm.data (); |
5506 | 155 } |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
156 else if (args(0).iscomplex ()) |
5506 | 157 { |
29390
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
158 scm = args(0).sparse_complex_matrix_value (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
159 A->nrow = scm.rows (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
160 A->ncol = scm.cols (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
161 A->p = scm.cidx (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
162 A->i = scm.ridx (); |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
163 A->nzmax = scm.nnz (); |
5506 | 164 A->xtype = CHOLMOD_COMPLEX; |
165 | |
29390
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
166 if (A->nrow > 0 && A->ncol > 0) |
1f9e755bd91e
Fix occasional segfault in symbfact (bug #60101).
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
167 A->x = scm.data (); |
5506 | 168 } |
169 else | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
170 err_wrong_type_arg ("symbfact", args(0)); |
5506 | 171 |
26389
d0a061e6d70f
symbfact.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
172 bool coletree = false; |
5506 | 173 octave_idx_type n = A->nrow; |
174 | |
175 if (nargin > 1) | |
176 { | |
21585 | 177 std::string str = args(1).xstring_value ("TYP must be a string"); |
178 // FIXME: The input validation could be improved to use strncmp | |
5506 | 179 char ch; |
21585 | 180 ch = tolower (str[0]); |
181 if (ch == 'r') // 'row' | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
182 A->stype = 0; |
21585 | 183 else if (ch == 'c') // 'col' |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
184 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
185 n = A->ncol; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
186 coletree = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
187 A->stype = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
188 } |
21585 | 189 else if (ch == 's') // 'sym' (default) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
190 A->stype = 1; |
21585 | 191 else if (ch == 'l') // 'lo' |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
192 A->stype = -1; |
5506 | 193 else |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
194 error (R"(symbfact: unrecognized TYP "%s")", str.c_str ()); |
21585 | 195 } |
196 | |
197 if (nargin == 3) | |
198 { | |
199 std::string str = args(2).xstring_value ("MODE must be a string"); | |
200 // FIXME: The input validation could be improved to use strncmp | |
201 char ch; | |
202 ch = toupper (str[0]); | |
203 if (ch != 'L') | |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
204 error (R"(symbfact: unrecognized MODE "%s")", str.c_str ()); |
5506 | 205 } |
206 | |
207 if (A->stype && A->nrow != A->ncol) | |
21110
3d0d84305600
Use err_square_matrix_required more widely.
Rik <rik@octave.org>
parents:
21109
diff
changeset
|
208 err_square_matrix_required ("symbfact", "S"); |
5506 | 209 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
210 OCTAVE_LOCAL_BUFFER (suitesparse_integer, Parent, n); |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
211 OCTAVE_LOCAL_BUFFER (suitesparse_integer, Post, n); |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
212 OCTAVE_LOCAL_BUFFER (suitesparse_integer, ColCount, n); |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
213 OCTAVE_LOCAL_BUFFER (suitesparse_integer, First, n); |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
214 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
|
215 |
21585 | 216 cholmod_common Common; |
217 cholmod_common *cm = &Common; | |
218 CHOLMOD_NAME(start) (cm); | |
219 | |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
220 double spu = sparse_params::get_key ("spumoni"); |
26389
d0a061e6d70f
symbfact.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
221 if (spu == 0.0) |
21585 | 222 { |
223 cm->print = -1; | |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
224 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, nullptr); |
21585 | 225 } |
226 else | |
227 { | |
228 cm->print = static_cast<int> (spu) + 2; | |
229 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &SparseCholPrint); | |
230 } | |
231 | |
232 cm->error_handler = &SparseCholError; | |
233 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex); | |
234 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot); | |
235 | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
236 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
|
237 cholmod_sparse *Aup, *Alo; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
238 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
239 if (A->stype == 1 || coletree) |
5506 | 240 { |
21585 | 241 Aup = A; |
242 Alo = F; | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
243 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
244 else |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
245 { |
21585 | 246 Aup = F; |
247 Alo = A; | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
248 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
249 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
250 CHOLMOD_NAME(etree) (Aup, Parent, cm); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
251 |
21585 | 252 ColumnVector tmp (n); // Declaration must precede any goto cleanup. |
253 std::string err_msg; | |
254 | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
255 if (cm->status < CHOLMOD_OK) |
21585 | 256 { |
257 err_msg = "symbfact: matrix corrupted"; | |
258 goto cleanup; | |
259 } | |
5506 | 260 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
261 if (CHOLMOD_NAME(postorder) (Parent, n, nullptr, Post, cm) != n) |
21585 | 262 { |
263 err_msg = "symbfact: postorder failed"; | |
264 goto cleanup; | |
265 } | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
266 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
267 CHOLMOD_NAME(rowcolcounts) (Alo, nullptr, 0, Parent, Post, nullptr, ColCount, |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
268 First, to_suitesparse_intptr (Level), cm); |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
269 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
270 if (cm->status < CHOLMOD_OK) |
21585 | 271 { |
272 err_msg = "symbfact: matrix corrupted"; | |
273 goto cleanup; | |
274 } | |
20667
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 if (nargout > 4) |
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 cholmod_sparse *A1, *A2; |
5506 | 279 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
280 if (A->stype == 1) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
281 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
282 A1 = A; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
283 A2 = nullptr; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
284 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
285 else if (A->stype == -1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
286 { |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
287 A1 = F; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
288 A2 = nullptr; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
289 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
290 else if (coletree) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
291 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
292 A1 = F; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
293 A2 = A; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
294 } |
5506 | 295 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
296 { |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
297 A1 = A; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
298 A2 = F; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
299 } |
5506 | 300 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
301 // count the total number of entries in L |
21585 | 302 octave_idx_type lnz = 0; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
303 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
|
304 lnz += ColCount[j]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
305 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
306 // allocate the output matrix L (pattern-only) |
25050
e376a35f168f
symfact.cc: Fix use of unitialized SparseBoolMatrix (bug #53507).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
307 SparseBoolMatrix L (dim_vector (n, n), lnz); |
5506 | 308 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
309 // initialize column pointers |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
310 lnz = 0; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
311 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
|
312 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
313 L.xcidx(j) = lnz; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
314 lnz += ColCount[j]; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
315 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
316 L.xcidx(n) = lnz; |
5506 | 317 |
20946 | 318 // create a copy of the column pointers |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
319 suitesparse_integer *W = First; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
320 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
|
321 W[j] = L.xcidx (j); |
5506 | 322 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
323 // 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
|
324 cholmod_sparse *R |
21585 | 325 = CHOLMOD_NAME(allocate_sparse) (n, 1, n, false, true, |
326 0, CHOLMOD_PATTERN, cm); | |
327 octave_idx_type *Rp = static_cast<octave_idx_type *> (R->p); | |
328 octave_idx_type *Ri = static_cast<octave_idx_type *> (R->i); | |
5506 | 329 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
330 // compute L one row at a time |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
331 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
|
332 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
333 // get the kth row of L and store in the columns of L |
21585 | 334 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
|
335 for (octave_idx_type p = 0 ; p < Rp[1] ; p++) |
21585 | 336 L.xridx (W[Ri[p]]++) = k; |
5506 | 337 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
338 // add the diagonal entry |
21585 | 339 L.xridx (W[k]++) = k; |
20667
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 // free workspace |
21585 | 343 CHOLMOD_NAME(free_sparse) (&R, cm); |
5506 | 344 |
25050
e376a35f168f
symfact.cc: Fix use of unitialized SparseBoolMatrix (bug #53507).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
345 // fill L with one's |
e376a35f168f
symfact.cc: Fix use of unitialized SparseBoolMatrix (bug #53507).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
346 std::fill_n (L.xdata (), lnz, true); |
e376a35f168f
symfact.cc: Fix use of unitialized SparseBoolMatrix (bug #53507).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
347 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
348 // 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
|
349 if (nargin < 3) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
350 L = L.transpose (); |
5506 | 351 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
352 retval(4) = L; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
353 } |
5506 | 354 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
355 if (nargout > 3) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
356 { |
5506 | 357 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
|
358 tmp(i) = Post[i] + 1; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
359 retval(3) = tmp; |
5506 | 360 } |
361 | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
362 if (nargout > 2) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
363 { |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
364 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
|
365 tmp(i) = Parent[i] + 1; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
366 retval(2) = tmp; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
367 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
368 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
369 if (nargout > 1) |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
370 { |
20946 | 371 // compute the elimination tree height |
21585 | 372 octave_idx_type height = 0; |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
373 for (int i = 0 ; i < n ; i++) |
21585 | 374 height = std::max (height, Level[i]); |
375 height++; | |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
376 retval(1) = static_cast<double> (height); |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
377 } |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
378 |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
379 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
|
380 tmp(i) = ColCount[i]; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
381 retval(0) = tmp; |
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
382 |
21585 | 383 cleanup: |
384 CHOLMOD_NAME(free_sparse) (&F, cm); | |
385 CHOLMOD_NAME(finish) (cm); | |
386 | |
387 if (! err_msg.empty ()) | |
26149
242aa7b2c783
Silence unnecessary warnings about security-format (bug #55046).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
388 error ("%s", err_msg.c_str ()); |
21585 | 389 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20898
diff
changeset
|
390 return retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20898
diff
changeset
|
391 |
5512 | 392 #else |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
393 |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
394 octave_unused_parameter (args); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
395 octave_unused_parameter (nargout); |
21937
55f7de37b618
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
396 |
21109
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
397 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
|
398 |
5512 | 399 #endif |
5506 | 400 } |
21585 | 401 |
402 /* | |
403 %!testif HAVE_CHOLMOD | |
404 %! A = sparse (magic (3)); | |
405 %! [count, h, parent, post, r] = symbfact (A); | |
406 %! assert (count, [3; 2; 1]); | |
407 %! assert (h, 3); | |
408 %! assert (parent, [2; 3; 0]); | |
409 %! assert (r, sparse (triu (true (3)))); | |
410 | |
411 %!testif HAVE_CHOLMOD | |
412 %! ## Test MODE "lower" | |
413 %! A = sparse (magic (3)); | |
414 %! [~, ~, ~, ~, l] = symbfact (A, "sym", "lower"); | |
415 %! assert (l, sparse (tril (true (3)))); | |
416 | |
23573
1b4f4ec53b4a
use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents:
23572
diff
changeset
|
417 %!testif HAVE_CHOLMOD <*42587> |
22489
93ea313301f9
test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
418 %! ## singular matrix |
21585 | 419 %! A = sparse ([1 0 8;0 1 8;8 8 1]); |
420 %! [count, h, parent, post, r] = symbfact (A); | |
421 | |
422 ## Test input validation | |
423 %!testif HAVE_CHOLMOD | |
424 %! fail ("symbfact ()"); | |
425 %! fail ("symbfact (1,2,3,4)"); | |
426 %! fail ("symbfact ({1})", "wrong type argument 'cell'"); | |
427 %! 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
|
428 %! fail ("symbfact (sparse (1), 'foobar')", 'unrecognized TYP "foobar"'); |
21585 | 429 %! fail ("symbfact (sparse (1), 'sym', {'L'})", "MODE must be a string"); |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
430 %! fail ('symbfact (sparse (1), "sym", "foobar")', |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
431 %! 'unrecognized MODE "foobar"'); |
21585 | 432 %! fail ("symbfact (sparse ([1, 2; 3, 4; 5, 6]))", "S must be a square matrix"); |
433 | |
434 */ | |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29872
diff
changeset
|
435 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
436 OCTAVE_END_NAMESPACE(octave) |