annotate libinterp/dldfcn/symbfact.cc @ 20939:b17fda023ca6

maint: Use new C++ archetype in more files. Place input validation first in files. Move declaration of retval down in function to be closer to point of usage. Eliminate else clause after if () error. Use "return ovl()" where it makes sense. * find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, givens.cc, graphics.cc, help.cc, hess.cc, hex2num.cc, input.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc, mappers.cc, matrix_type.cc, mgorth.cc, nproc.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, profiler.cc, psi.cc, quad.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sparse.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, __glpk__.cc, __magick_read__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, chol.cc, colamd.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.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-java.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-re-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-usr-fcn.cc, ov.cc, octave.cc: Use new C++ archetype in more files.
author Rik <rik@octave.org>
date Fri, 18 Dec 2015 15:37:22 -0800
parents 8da80da1ac37
children 48b2ad5ee801
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
1 /*
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
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
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
4 Copyright (C) 1998-2005 Andy Adler
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
5
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
6 This file is part of Octave.
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
7
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
11 option) any later version.
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
12
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
16 for more details.
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
17
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
20 <http://www.gnu.org/licenses/>.
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
21
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
22 */
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
23
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
25 #include <config.h>
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
26 #endif
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
27
7515
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7036
diff changeset
28 #include "SparseCmplxCHOL.h"
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7036
diff changeset
29 #include "SparsedbleCHOL.h"
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7036
diff changeset
30 #include "oct-spparms.h"
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7036
diff changeset
31 #include "sparse-util.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
32 #include "oct-locbuf.h"
7515
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
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
36 #include "defun-dld.h"
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
37 #include "error.h"
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
38 #include "gripes.h"
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
39 #include "oct-obj.h"
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
40 #include "utils.h"
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
41
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
42 DEFUN_DLD (symbfact, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
43 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20792
diff changeset
44 @deftypefn {} {[@var{count}, @var{h}, @var{parent}, @var{post}, @var{r}] =} symbfact (@var{S})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20792
diff changeset
45 @deftypefnx {} {[@dots{}] =} symbfact (@var{S}, @var{typ})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20792
diff changeset
46 @deftypefnx {} {[@dots{}] =} symbfact (@var{S}, @var{typ}, @var{mode})\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
47 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
48 Perform a symbolic factorization analysis on the sparse matrix @var{S}.\n\
20163
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
49 \n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
50 The input variables are\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
51 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
52 @table @var\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
53 @item S\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
54 @var{S} is a complex or real sparse matrix.\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
55 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
56 @item typ\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
57 Is the type of the factorization and can be one of\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
58 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
59 @table @samp\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
60 @item sym\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
61 Factorize @var{S}. This is the default.\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
62 \n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
63 @item col\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
64 Factorize @code{@var{S}' * @var{S}}.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
65 \n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
66 @item row\n\
17268
1c21f264d26f doc: Rename @xcode macro to @tcode (transpose code) for clarity.
Rik <rik@octave.org>
parents: 16316
diff changeset
67 Factorize @tcode{@var{S} * @var{S}'}.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
68 \n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
69 @item lo\n\
17268
1c21f264d26f doc: Rename @xcode macro to @tcode (transpose code) for clarity.
Rik <rik@octave.org>
parents: 16316
diff changeset
70 Factorize @tcode{@var{S}'}\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
71 @end table\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
72 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
73 @item mode\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
74 The default is to return the Cholesky@tie{}factorization for @var{r}, and if\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17268
diff changeset
75 @var{mode} is @qcode{'L'}, the conjugate transpose of the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17268
diff changeset
76 Cholesky@tie{}factorization is returned. The conjugate transpose version is\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17268
diff changeset
77 faster and uses less memory, but returns the same values for @var{count},\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17268
diff changeset
78 @var{h}, @var{parent} and @var{post} outputs.\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
79 @end table\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
80 \n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
81 The output variables are\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
82 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
83 @table @var\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
84 @item count\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
85 The row counts of the Cholesky@tie{}factorization as determined by @var{typ}.\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
86 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
87 @item h\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
88 The height of the elimination tree.\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
89 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
90 @item parent\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
91 The elimination tree itself.\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
92 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
93 @item post\n\
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
94 A sparse boolean matrix whose structure is that of the Cholesky\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
95 factorization as determined by @var{typ}.\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
96 @end table\n\
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
97 @end deftypefn")
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
98 {
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20853
diff changeset
99 #ifdef HAVE_CHOLMOD
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20853
diff changeset
100
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
101 int nargin = args.length ();
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
102
20792
d0991cbd6141 maint: Remove extra spaces in if () conditionals.
Rik <rik@octave.org>
parents: 20790
diff changeset
103 if (nargin < 1 || nargin > 3 || nargout > 5)
20790
c2d9556d51d0 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
104 print_usage ();
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
105
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20853
diff changeset
106 octave_value_list retval;
5512
7c8767d0ffc0 [project @ 2005-10-27 02:20:17 by jwe]
jwe
parents: 5506
diff changeset
107
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
108 cholmod_common Common;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
109 cholmod_common *cm = &Common;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
110 CHOLMOD_NAME(start) (cm);
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
111
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5823
diff changeset
112 double spu = octave_sparse_params::get_key ("spumoni");
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
113 if (spu == 0.)
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
114 {
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
115 cm->print = -1;
19139
afd6179d2616 allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
116 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, 0);
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
117 }
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
118 else
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
119 {
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5717
diff changeset
120 cm->print = static_cast<int> (spu) + 2;
19139
afd6179d2616 allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
121 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &SparseCholPrint);
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
122 }
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
123
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
124 cm->error_handler = &SparseCholError;
19139
afd6179d2616 allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
125 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
afd6179d2616 allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
126 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
127
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
128 double dummy;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
129 cholmod_sparse Astore;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
130 cholmod_sparse *A = &Astore;
5527
ce71ed4c6da6 [project @ 2005-11-01 22:15:49 by jwe]
jwe
parents: 5512
diff changeset
131 A->packed = true;
ce71ed4c6da6 [project @ 2005-11-01 22:15:49 by jwe]
jwe
parents: 5512
diff changeset
132 A->sorted = true;
7520
b166043585a8 use 0 instead of NULL
John W. Eaton <jwe@octave.org>
parents: 7515
diff changeset
133 A->nz = 0;
16313
6aafe87a3144 use int64_t for idx type if --enable-64
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
134 #ifdef USE_64_BIT_IDX_T
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
135 A->itype = CHOLMOD_LONG;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
136 #else
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
137 A->itype = CHOLMOD_INT;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
138 #endif
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
139 A->dtype = CHOLMOD_DOUBLE;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
140 A->stype = 1;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
141 A->x = &dummy;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
142
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
143 if (args(0).is_real_type ())
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
144 {
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
145 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
146 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
147 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
148 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
149 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
150 A->nzmax = a.nnz ();
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
151 A->xtype = CHOLMOD_REAL;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
152
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
153 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
154 A->x = a.data ();
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
155 }
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
156 else if (args(0).is_complex_type ())
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
157 {
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
158 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
159 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
160 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
161 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
162 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
163 A->nzmax = a.nnz ();
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
164 A->xtype = CHOLMOD_COMPLEX;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
165
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
166 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
167 A->x = a.data ();
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
168 }
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
169 else
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7520
diff changeset
170 gripe_wrong_type_arg ("symbfact", args(0));
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
171
5527
ce71ed4c6da6 [project @ 2005-11-01 22:15:49 by jwe]
jwe
parents: 5512
diff changeset
172 octave_idx_type coletree = false;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
173 octave_idx_type n = A->nrow;
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
174
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
175 if (nargin > 1)
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
176 {
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
177 char ch;
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
178 std::string str = args(1).string_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
179 ch = tolower (str.c_str ()[0]);
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
180 if (ch == 'r')
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
181 A->stype = 0;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
182 else if (ch == 'c')
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
183 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
184 n = A->ncol;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
185 coletree = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
186 A->stype = 0;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
187 }
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
188 else if (ch == 's')
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
189 A->stype = 1;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
190 else if (ch == 's')
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
191 A->stype = -1;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
192 else
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
193 error ("symbfact: unrecognized TYP in symbolic factorization");
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
194 }
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
195
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
196 if (A->stype && A->nrow != A->ncol)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
197 error ("symbfact: S must be a square matrix");
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
198
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
199 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
200 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
201 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
202 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
203 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
204
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
205 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
206 cholmod_sparse *Aup, *Alo;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
207
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
208 if (A->stype == 1 || coletree)
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
209 {
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
210 Aup = A ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
211 Alo = F ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
212 }
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
213 else
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
214 {
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
215 Aup = F ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
216 Alo = A ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
217 }
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
218
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
219 CHOLMOD_NAME(etree) (Aup, Parent, cm);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
220
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
221 if (cm->status < CHOLMOD_OK)
20726
25d676f9619c Preface error() messages with name of function when possible.
Rik <rik@octave.org>
parents: 20667
diff changeset
222 error ("symbfact: matrix corrupted");
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
223
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
224 if (CHOLMOD_NAME(postorder) (Parent, n, 0, Post, cm) != n)
20726
25d676f9619c Preface error() messages with name of function when possible.
Rik <rik@octave.org>
parents: 20667
diff changeset
225 error ("symbfact: postorder failed");
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
226
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
227 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
228 ColCount, First, Level, cm);
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 if (cm->status < CHOLMOD_OK)
20726
25d676f9619c Preface error() messages with name of function when possible.
Rik <rik@octave.org>
parents: 20667
diff changeset
231 error ("symbfact: matrix corrupted");
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
232
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
233 if (nargout > 4)
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 cholmod_sparse *A1, *A2;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
236
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
237 if (A->stype == 1)
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 A1 = A;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
240 A2 = 0;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
241 }
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
242 else if (A->stype == -1)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
243 {
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
244 A1 = F;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
245 A2 = 0;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
246 }
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
247 else if (coletree)
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 A1 = F;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
250 A2 = A;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
251 }
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
252 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
253 {
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
254 A1 = A;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
255 A2 = F;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
256 }
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
257
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
258 // count the total number of entries in L
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
259 octave_idx_type lnz = 0 ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
260 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
261 lnz += ColCount[j];
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
262
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
263
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
264 // allocate the output matrix L (pattern-only)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
265 SparseBoolMatrix L (n, n, lnz);
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
266
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
267 // initialize column pointers
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
268 lnz = 0;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
269 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
270 {
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
271 L.xcidx(j) = lnz;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
272 lnz += ColCount[j];
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
273 }
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
274 L.xcidx(n) = lnz;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
275
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
276
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
277 /* create a copy of the column pointers */
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
278 octave_idx_type *W = First;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
279 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
280 W[j] = L.xcidx (j);
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
281
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
282 // 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
283 cholmod_sparse *R
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
284 = CHOLMOD_NAME (allocate_sparse) (n, 1, n, false, true,
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
285 0, CHOLMOD_PATTERN, cm);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
286 octave_idx_type *Rp = static_cast<octave_idx_type *>(R->p);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
287 octave_idx_type *Ri = static_cast<octave_idx_type *>(R->i);
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
288
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
289 // compute L one row at a time
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
290 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
291 {
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
292 // get the kth row of L and store in the columns of L
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
293 CHOLMOD_NAME (row_subtree) (A1, A2, k, Parent, R, cm) ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
294 for (octave_idx_type p = 0 ; p < Rp[1] ; p++)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
295 L.xridx (W[Ri[p]]++) = k ;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
296
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
297 // add the diagonal entry
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
298 L.xridx (W[k]++) = k ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
299 }
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
300
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
301 // free workspace
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
302 CHOLMOD_NAME (free_sparse) (&R, cm) ;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
303
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
304
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
305 // 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
306 if (nargin < 3)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
307 L = L.transpose ();
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
308
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
309 // 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
310 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
311 L.xdata(p) = true;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
312
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
313 retval(4) = L;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
314 }
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
315
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
316 ColumnVector tmp (n);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
317 if (nargout > 3)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
318 {
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
319 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
320 tmp(i) = Post[i] + 1;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
321 retval(3) = tmp;
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
322 }
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
323
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
324 if (nargout > 2)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
325 {
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
326 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
327 tmp(i) = Parent[i] + 1;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
328 retval(2) = tmp;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
329 }
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
330
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
331 if (nargout > 1)
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 /* compute the elimination tree height */
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
334 octave_idx_type height = 0 ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
335 for (int i = 0 ; i < n ; i++)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
336 height = (height > Level[i] ? height : Level[i]);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
337 height++ ;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
338 retval(1) = static_cast<double> (height);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
339 }
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
340
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
341 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
342 tmp(i) = ColCount[i];
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
343 retval(0) = tmp;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
344
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20898
diff changeset
345 return retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20898
diff changeset
346
5512
7c8767d0ffc0 [project @ 2005-10-27 02:20:17 by jwe]
jwe
parents: 5506
diff changeset
347 #else
7c8767d0ffc0 [project @ 2005-10-27 02:20:17 by jwe]
jwe
parents: 5506
diff changeset
348 error ("symbfact: not available in this version of Octave");
7c8767d0ffc0 [project @ 2005-10-27 02:20:17 by jwe]
jwe
parents: 5506
diff changeset
349 #endif
5506
b4cfbb0ec8c4 [project @ 2005-10-23 19:09:32 by dbateman]
dbateman
parents:
diff changeset
350 }