annotate src/DLD-FUNCTIONS/ccolamd.cc @ 10846:a4f482e66b65

Grammarcheck more of the documentation. Use @noindent macro appropriately. Limit line length to 80 characters.
author Rik <octave@nomad.inbox5.com>
date Sun, 01 Aug 2010 20:22:17 -0700
parents 89f4d7e294cc
children fd0a3ac60b0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
1 /*
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
2
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
3 Copyright (C) 2005, 2006, 2007, 2008 David Bateman
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
4
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5771
diff changeset
5 This file is part of Octave.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5771
diff changeset
6
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
8 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: 5771
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5771
diff changeset
10 option) any later version.
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
11
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
15 for more details.
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
16
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
17 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: 5771
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5771
diff changeset
19 <http://www.gnu.org/licenses/>.
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
20
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
21 */
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
22
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
23 // This is the octave interface to ccolamd, which bore the copyright given
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
24 // in the help of the functions.
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
25
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
27 #include <config.h>
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
28 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
29
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
30 #include <cstdlib>
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
31
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
32 #include <string>
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
33 #include <vector>
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
34
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
35 #include "ov.h"
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
36 #include "defun-dld.h"
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
37 #include "pager.h"
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
38 #include "ov-re-mat.h"
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
39
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
40 #include "ov-re-sparse.h"
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
41 #include "ov-cx-sparse.h"
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
42
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
43 #include "oct-sparse.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7520
diff changeset
44 #include "oct-locbuf.h"
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
45
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
46 #ifdef IDX_TYPE_LONG
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
47 #define CCOLAMD_NAME(name) ccolamd_l ## name
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
48 #define CSYMAMD_NAME(name) csymamd_l ## name
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
49 #else
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
50 #define CCOLAMD_NAME(name) ccolamd ## name
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
51 #define CSYMAMD_NAME(name) csymamd ## name
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
52 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
53
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
54 DEFUN_DLD (ccolamd, args, nargout,
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
55 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
56 @deftypefn {Loadable Function} {@var{p} =} ccolamd (@var{s})\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
57 @deftypefnx {Loadable Function} {@var{p} =} ccolamd (@var{s}, @var{knobs})\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
58 @deftypefnx {Loadable Function} {@var{p} =} ccolamd (@var{s}, @var{knobs}, @var{cmember})\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
59 @deftypefnx {Loadable Function} {[@var{p}, @var{stats}] =} ccolamd (@dots{})\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
60 \n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
61 Constrained column approximate minimum degree permutation.\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
62 @code{@var{p} = ccolamd (@var{s})} returns the column approximate minimum\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
63 degree permutation vector for the sparse matrix @var{s}. For a non-symmetric\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
64 matrix\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
65 @var{s},\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
66 @code{@var{s} (:, @var{p})} tends to have sparser LU factors than @var{s}.\n\
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
67 @code{chol (@var{s} (:, @var{p})' * @var{s} (:, @var{p}))} also tends to be\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
68 sparser than @code{chol (@var{s}' * @var{s})}.\n\
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
69 @code{@var{p} = ccolamd\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
70 (@var{s}, 1)} optimizes the ordering for @code{lu (@var{s} (:, @var{p}))}.\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
71 The ordering is followed by a column elimination tree post-ordering.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
72 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
73 @var{knobs} is an optional one- to five-element input vector, with a default\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
74 value of @code{[0 10 10 1 0]} if not present or empty. Entries not present\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
75 are set to their defaults.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
76 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
77 @table @code\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
78 @item @var{knobs}(1)\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
79 if nonzero, the ordering is optimized for @code{lu (S (:, p))}. It will be a\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
80 poor ordering for @code{chol (@var{s} (:, @var{p})' * @var{s} (:,\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
81 @var{p}))}. This is the most important knob for ccolamd.\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
82 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
83 @item @var{knob}(2)\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
84 if @var{s} is m-by-n, rows with more than @code{max (16, @var{knobs} (2) *\n\
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
85 sqrt (n))} entries are ignored.\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
86 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
87 @item @var{knob}(3)\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
88 columns with more than @code{max (16, @var{knobs} (3) * sqrt (min (@var{m},\n\
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
89 @var{n})))} entries are ignored and ordered last in the output permutation\n\
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
90 (subject to the cmember constraints).\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
91 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
92 @item @var{knob}(4)\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
93 if nonzero, aggressive absorption is performed.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
94 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
95 @item @var{knob}(5)\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
96 if nonzero, statistics and knobs are printed.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
97 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
98 @end table\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
99 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
100 @var{cmember} is an optional vector of length n. It defines the constraints\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
101 on the column ordering. If @code{@var{cmember} (j) = @var{c}}, then column\n\
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
102 @var{j} is in constraint set @var{c} (@var{c} must be in the range 1 to\n\
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
103 @var{n}). In the output permutation @var{p}, all columns in set 1 appear\n\
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
104 first, followed by all columns in set 2, and so on. @code{@var{cmember} =\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
105 ones(1,n)} if not present or empty.\n\
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
106 @code{ccolamd (@var{s}, [], 1 : @var{n})} returns @code{1 : @var{n}}\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
107 \n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
108 @code{@var{p} = ccolamd (@var{s})} is about the same as\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
109 @code{@var{p} = colamd (@var{s})}. @var{knobs} and its default values\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
110 differ. @code{colamd} always does aggressive absorption, and it finds an\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
111 ordering suitable for both @code{lu (@var{s} (:, @var{p}))} and @code{chol\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
112 (@var{S} (:, @var{p})' * @var{s} (:, @var{p}))}; it cannot optimize its\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
113 ordering for @code{lu (@var{s} (:, @var{p}))} to the extent that\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
114 @code{ccolamd (@var{s}, 1)} can.\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
115 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
116 @var{stats} is an optional 20-element output vector that provides data\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
117 about the ordering and the validity of the input matrix @var{s}. Ordering\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
118 statistics are in @code{@var{stats} (1 : 3)}. @code{@var{stats} (1)} and\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
119 @code{@var{stats} (2)} are the number of dense or empty rows and columns\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
120 ignored by @sc{ccolamd} and @code{@var{stats} (3)} is the number of garbage\n\
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
121 collections performed on the internal data structure used by @sc{ccolamd}\n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
122 (roughly of size @code{2.2 * nnz (@var{s}) + 4 * @var{m} + 7 * @var{n}}\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
123 integers).\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
124 \n\
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7017
diff changeset
125 @code{@var{stats} (4 : 7)} provide information if CCOLAMD was able to\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
126 continue. The matrix is OK if @code{@var{stats} (4)} is zero, or 1 if\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
127 invalid. @code{@var{stats} (5)} is the rightmost column index that is\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
128 unsorted or contains duplicate entries, or zero if no such column exists.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
129 @code{@var{stats} (6)} is the last seen duplicate or out-of-order row\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
130 index in the column index given by @code{@var{stats} (5)}, or zero if no\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
131 such row index exists. @code{@var{stats} (7)} is the number of duplicate\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
132 or out-of-order row indices. @code{@var{stats} (8 : 20)} is always zero in\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
133 the current version of @sc{ccolamd} (reserved for future use).\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
134 \n\
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents: 10527
diff changeset
135 The authors of the code itself are S. Larimore, T. Davis (Univ. of Florida)\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
136 and S. Rajamanickam in collaboration with J. Bilbert and E. Ng. Supported\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
137 by the National Science Foundation (DMS-9504974, DMS-9803599, CCR-0203270),\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
138 and a grant from Sandia National Lab. See\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
139 @url{http://www.cise.ufl.edu/research/sparse} for ccolamd, csymamd, amd,\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
140 colamd, symamd, and other related orderings.\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5631
diff changeset
141 @seealso{colamd, csymamd}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5631
diff changeset
142 @end deftypefn")
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
143 {
5771
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
144 octave_value_list retval;
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
145
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
146 #ifdef HAVE_CCOLAMD
5771
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
147
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
148 int nargin = args.length ();
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
149 int spumoni = 0;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
150
10282
c9780d8e228c fix invalid checks in amd functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
151 if (nargout > 2 || nargin < 1 || nargin > 3)
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
152 usage ("ccolamd: incorrect number of input and/or output arguments");
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
153 else
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
154 {
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
155 // Get knobs
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
156 OCTAVE_LOCAL_BUFFER (double, knobs, CCOLAMD_KNOBS);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
157 CCOLAMD_NAME (_set_defaults) (knobs);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
158
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
159 // Check for user-passed knobs
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
160 if (nargin > 1)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
161 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
162 NDArray User_knobs = args(1).array_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
163 int nel_User_knobs = User_knobs.length ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
164
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
165 if (nel_User_knobs > 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
166 knobs [CCOLAMD_LU] = (User_knobs (0) != 0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
167 if (nel_User_knobs > 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
168 knobs [CCOLAMD_DENSE_ROW] = User_knobs (1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
169 if (nel_User_knobs > 2)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
170 knobs [CCOLAMD_DENSE_COL] = User_knobs (2);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
171 if (nel_User_knobs > 3)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
172 knobs [CCOLAMD_AGGRESSIVE] = (User_knobs (3) != 0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
173 if (nel_User_knobs > 4)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
174 spumoni = (User_knobs (4) != 0);
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
175
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
176 // print knob settings if spumoni is set
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
177 if (spumoni)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
178 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
179 octave_stdout << "\nccolamd version " << CCOLAMD_MAIN_VERSION << "."
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
180 << CCOLAMD_SUB_VERSION << ", " << CCOLAMD_DATE
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
181 << ":\nknobs(1): " << User_knobs (0) << ", order for ";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
182 if ( knobs [CCOLAMD_LU] != 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
183 octave_stdout << "lu(A)\n";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
184 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
185 octave_stdout << "chol(A'*A)\n";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
186
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
187 if (knobs [CCOLAMD_DENSE_ROW] >= 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
188 octave_stdout << "knobs(2): " << User_knobs (1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
189 << ", rows with > max(16,"
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
190 << knobs [CCOLAMD_DENSE_ROW] << "*sqrt(size(A,2)))"
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
191 << " entries removed\n";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
192 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
193 octave_stdout << "knobs(2): " << User_knobs (1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
194 << ", no dense rows removed\n";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
195
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
196 if (knobs [CCOLAMD_DENSE_COL] >= 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
197 octave_stdout << "knobs(3): " << User_knobs (2)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
198 << ", cols with > max(16,"
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
199 << knobs [CCOLAMD_DENSE_COL] << "*sqrt(size(A)))"
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
200 << " entries removed\n";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
201 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
202 octave_stdout << "knobs(3): " << User_knobs (2)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
203 << ", no dense columns removed\n";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
204
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
205 if (knobs [CCOLAMD_AGGRESSIVE] != 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
206 octave_stdout << "knobs(4): " << User_knobs(3)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
207 << ", aggressive absorption: yes";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
208 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
209 octave_stdout << "knobs(4): " << User_knobs(3)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
210 << ", aggressive absorption: no";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
211
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
212 octave_stdout << "knobs(5): " << User_knobs (4)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
213 << ", statistics and knobs printed\n";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
214 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
215 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
216
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
217 octave_idx_type n_row, n_col, nnz;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
218 octave_idx_type *ridx, *cidx;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
219 SparseComplexMatrix scm;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
220 SparseMatrix sm;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
221
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
222 if (args(0).is_sparse_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
223 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
224 if (args(0).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
225 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
226 scm = args(0). sparse_complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
227 n_row = scm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
228 n_col = scm.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10282
diff changeset
229 nnz = scm.nnz ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
230 ridx = scm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
231 cidx = scm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
232 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
233 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
234 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
235 sm = args(0).sparse_matrix_value ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
236
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
237 n_row = sm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
238 n_col = sm.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10282
diff changeset
239 nnz = sm.nnz ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
240 ridx = sm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
241 cidx = sm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
242 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
243 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
244 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
245 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
246 if (args(0).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
247 sm = SparseMatrix (real (args(0).complex_matrix_value ()));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
248 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
249 sm = SparseMatrix (args(0).matrix_value ());
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
250
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
251 n_row = sm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
252 n_col = sm.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10282
diff changeset
253 nnz = sm.nnz ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
254 ridx = sm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
255 cidx = sm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
256 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
257
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
258 // Allocate workspace for ccolamd
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
259 OCTAVE_LOCAL_BUFFER (octave_idx_type, p, n_col+1);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
260 for (octave_idx_type i = 0; i < n_col+1; i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
261 p[i] = cidx [i];
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
262
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
263 octave_idx_type Alen = CCOLAMD_NAME (_recommended) (nnz, n_row, n_col);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
264 OCTAVE_LOCAL_BUFFER (octave_idx_type, A, Alen);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
265 for (octave_idx_type i = 0; i < nnz; i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
266 A[i] = ridx [i];
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
267
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
268 OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, CCOLAMD_STATS);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
269
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
270 if (nargin > 2)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
271 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
272 NDArray in_cmember = args(2).array_value();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
273 octave_idx_type cslen = in_cmember.length();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
274 OCTAVE_LOCAL_BUFFER (octave_idx_type, cmember, cslen);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
275 for (octave_idx_type i = 0; i < cslen; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
276 // convert cmember from 1-based to 0-based
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
277 cmember[i] = static_cast<octave_idx_type>(in_cmember(i) - 1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
278
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
279 if (cslen != n_col)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
280 error ("ccolamd: cmember must be of length equal to #cols of A");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
281 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
282 // Order the columns (destroys A)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
283 if (! CCOLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats, cmember))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
284 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
285 CCOLAMD_NAME (_report) (stats) ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
286 error ("ccolamd: internal error!");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
287 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
288 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
289 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
290 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
291 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
292 // Order the columns (destroys A)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
293 if (! CCOLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats, 0))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
294 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
295 CCOLAMD_NAME (_report) (stats) ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
296 error ("ccolamd: internal error!");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
297 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
298 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
299 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
300
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
301 // return the permutation vector
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
302 NDArray out_perm (dim_vector (1, n_col));
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
303 for (octave_idx_type i = 0; i < n_col; i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
304 out_perm(i) = p [i] + 1;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
305
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
306 retval (0) = out_perm;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
307
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
308 // print stats if spumoni > 0
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
309 if (spumoni > 0)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
310 CCOLAMD_NAME (_report) (stats) ;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
311
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
312 // Return the stats vector
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
313 if (nargout == 2)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
314 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
315 NDArray out_stats (dim_vector (1, CCOLAMD_STATS));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
316 for (octave_idx_type i = 0 ; i < CCOLAMD_STATS ; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
317 out_stats (i) = stats [i] ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
318 retval(1) = out_stats;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
319
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
320 // fix stats (5) and (6), for 1-based information on
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
321 // jumbled matrix. note that this correction doesn't
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
322 // occur if symamd returns FALSE
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
323 out_stats (CCOLAMD_INFO1) ++ ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
324 out_stats (CCOLAMD_INFO2) ++ ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
325 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
326 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
327
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
328 #else
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
329
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
330 error ("ccolamd: not available in this version of Octave");
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
331
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
332 #endif
5771
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
333
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
334 return retval;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
335 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
336
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
337 DEFUN_DLD (csymamd, args, nargout,
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
338 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
339 @deftypefn {Loadable Function} {@var{p} =} csymamd (@var{s})\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
340 @deftypefnx {Loadable Function} {@var{p} =} csymamd (@var{s}, @var{knobs})\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
341 @deftypefnx {Loadable Function} {@var{p} =} csymamd (@var{s}, @var{knobs}, @var{cmember})\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
342 @deftypefnx {Loadable Function} {[@var{p}, @var{stats}] =} csymamd (@dots{})\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
343 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
344 For a symmetric positive definite matrix @var{s}, returns the permutation\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
345 vector @var{p} such that @code{@var{s}(@var{p},@var{p})} tends to have a\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
346 sparser Cholesky factor than @var{s}. Sometimes @code{csymamd} works well\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
347 for symmetric indefinite matrices too. The matrix @var{s} is assumed to\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
348 be symmetric; only the strictly lower triangular part is referenced.\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
349 @var{s} must be square. The ordering is followed by an elimination tree\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
350 post-ordering.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
351 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
352 @var{knobs} is an optional one- to three-element input vector, with a\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
353 default value of @code{[10 1 0]} if present or empty. Entries not\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
354 present are set to their defaults.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
355 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
356 @table @code\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
357 @item @var{knobs}(1)\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
358 If @var{s} is n-by-n, then rows and columns with more than\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
359 @code{max(16,@var{knobs}(1)*sqrt(n))} entries are ignored, and ordered\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
360 last in the output permutation (subject to the cmember constraints).\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
361 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
362 @item @var{knobs}(2)\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
363 If nonzero, aggressive absorption is performed.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
364 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
365 @item @var{knobs}(3)\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
366 If nonzero, statistics and knobs are printed.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
367 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
368 @end table\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
369 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
370 @var{cmember} is an optional vector of length n. It defines the constraints\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
371 on the ordering. If @code{@var{cmember}(j) = @var{s}}, then row/column j is\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
372 in constraint set @var{c} (@var{c} must be in the range 1 to n). In the\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
373 output permutation @var{p}, rows/columns in set 1 appear first, followed\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
374 by all rows/columns in set 2, and so on. @code{@var{cmember} = ones(1,n)}\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
375 if not present or empty. @code{csymamd(@var{s},[],1:n)} returns @code{1:n}.\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
376 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
377 @code{@var{p} = csymamd(@var{s})} is about the same as @code{@var{p} =\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
378 symamd(@var{s})}. @var{knobs} and its default values differ.\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
379 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
380 @code{@var{stats} (4:7)} provide information if CCOLAMD was able to\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
381 continue. The matrix is OK if @code{@var{stats} (4)} is zero, or 1 if\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
382 invalid. @code{@var{stats} (5)} is the rightmost column index that is\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
383 unsorted or contains duplicate entries, or zero if no such column exists.\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
384 @code{@var{stats} (6)} is the last seen duplicate or out-of-order row\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
385 index in the column index given by @code{@var{stats} (5)}, or zero if no\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
386 such row index exists. @code{@var{stats} (7)} is the number of duplicate\n\
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
387 or out-of-order row indices. @code{@var{stats} (8:20)} is always zero in\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
388 the current version of @sc{ccolamd} (reserved for future use).\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
389 \n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
390 The authors of the code itself are S. Larimore, T. Davis (Uni of Florida)\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
391 and S. Rajamanickam in collaboration with J. Bilbert and E. Ng. Supported\n\
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
392 by the National Science Foundation (DMS-9504974, DMS-9803599, CCR-0203270),\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
393 and a grant from Sandia National Lab. See\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
394 @url{http://www.cise.ufl.edu/research/sparse} for ccolamd, csymamd, amd,\n\
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
395 colamd, symamd, and other related orderings.\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5631
diff changeset
396 @seealso{symamd, ccolamd}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5631
diff changeset
397 @end deftypefn")
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
398 {
5771
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
399 octave_value_list retval;
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
400
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
401 #if HAVE_CCOLAMD
5771
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
402
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
403 int nargin = args.length ();
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
404 int spumoni = 0;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
405
10282
c9780d8e228c fix invalid checks in amd functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
406 if (nargout > 2 || nargin < 1 || nargin > 3)
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
407 usage ("ccolamd: incorrect number of input and/or output arguments");
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
408 else
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
409 {
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
410 // Get knobs
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
411 OCTAVE_LOCAL_BUFFER (double, knobs, CCOLAMD_KNOBS);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
412 CCOLAMD_NAME (_set_defaults) (knobs);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
413
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
414 // Check for user-passed knobs
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
415 if (nargin > 1)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
416 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
417 NDArray User_knobs = args(1).array_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
418 int nel_User_knobs = User_knobs.length ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
419
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
420 if (nel_User_knobs > 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
421 knobs [CCOLAMD_DENSE_ROW] = User_knobs (0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
422 if (nel_User_knobs > 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
423 knobs [CCOLAMD_AGGRESSIVE] = User_knobs (1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
424 if (nel_User_knobs > 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
425 spumoni = static_cast<int> (User_knobs (2));
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
426
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
427 // print knob settings if spumoni is set
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
428 if (spumoni)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
429 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
430 octave_stdout << "\ncsymamd version " << CCOLAMD_MAIN_VERSION << "."
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
431 << CCOLAMD_SUB_VERSION << ", " << CCOLAMD_DATE << "\n";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
432
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
433 if (knobs [CCOLAMD_DENSE_ROW] >= 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
434 octave_stdout << "knobs(1): " << User_knobs (0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
435 << ", rows/cols with > max(16,"
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
436 << knobs [CCOLAMD_DENSE_ROW] << "*sqrt(size(A,2)))"
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
437 << " entries removed\n";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
438 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
439 octave_stdout << "knobs(1): " << User_knobs (0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
440 << ", no dense rows/cols removed\n";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
441
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
442 if (knobs [CCOLAMD_AGGRESSIVE] != 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
443 octave_stdout << "knobs(2): " << User_knobs(1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
444 << ", aggressive absorption: yes";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
445 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
446 octave_stdout << "knobs(2): " << User_knobs(1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
447 << ", aggressive absorption: no";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
448
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
449
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
450 octave_stdout << "knobs(3): " << User_knobs (2)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
451 << ", statistics and knobs printed\n";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
452 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
453 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
454
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
455 octave_idx_type n_row, n_col, nnz;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
456 octave_idx_type *ridx, *cidx;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
457 SparseMatrix sm;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
458 SparseComplexMatrix scm;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
459
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
460 if (args(0).is_sparse_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
461 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
462 if (args(0).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
463 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
464 scm = args(0).sparse_complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
465 n_row = scm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
466 n_col = scm.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10282
diff changeset
467 nnz = scm.nnz ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
468 ridx = scm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
469 cidx = scm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
470 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
471 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
472 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
473 sm = args(0).sparse_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
474 n_row = sm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
475 n_col = sm.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10282
diff changeset
476 nnz = sm.nnz ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
477 ridx = sm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
478 cidx = sm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
479 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
480 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
481 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
482 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
483 if (args(0).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
484 sm = SparseMatrix (real (args(0).complex_matrix_value ()));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
485 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
486 sm = SparseMatrix (args(0).matrix_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
487
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
488 n_row = sm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
489 n_col = sm.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10282
diff changeset
490 nnz = sm.nnz ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
491 ridx = sm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
492 cidx = sm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
493 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
494
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
495 if (n_row != n_col)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
496 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
497 error ("symamd: matrix must be square");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
498 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
499 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
500
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
501 // Allocate workspace for symamd
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
502 OCTAVE_LOCAL_BUFFER (octave_idx_type, perm, n_col+1);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
503 OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, CCOLAMD_STATS);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
504
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
505 if (nargin > 2)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
506 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
507 NDArray in_cmember = args(2).array_value();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
508 octave_idx_type cslen = in_cmember.length();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
509 OCTAVE_LOCAL_BUFFER (octave_idx_type, cmember, cslen);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
510 for (octave_idx_type i = 0; i < cslen; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
511 // convert cmember from 1-based to 0-based
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
512 cmember[i] = static_cast<octave_idx_type>(in_cmember(i) - 1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
513
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
514 if (cslen != n_col)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
515 error ("ccolamd: cmember must be of length equal to #cols of A");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
516 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
517 if (!CSYMAMD_NAME () (n_col, ridx, cidx, perm, knobs, stats,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
518 &calloc, &free, cmember, -1))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
519 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
520 CSYMAMD_NAME (_report) (stats) ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
521 error ("symamd: internal error!") ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
522 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
523 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
524 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
525 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
526 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
527 if (!CSYMAMD_NAME () (n_col, ridx, cidx, perm, knobs, stats,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
528 &calloc, &free, 0, -1))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
529 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
530 CSYMAMD_NAME (_report) (stats) ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
531 error ("symamd: internal error!") ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
532 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
533 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
534 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
535
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
536 // return the permutation vector
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
537 NDArray out_perm (dim_vector (1, n_col));
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
538 for (octave_idx_type i = 0; i < n_col; i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
539 out_perm(i) = perm [i] + 1;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
540
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
541 retval (0) = out_perm;
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
542
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
543 // Return the stats vector
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
544 if (nargout == 2)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
545 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
546 NDArray out_stats (dim_vector (1, CCOLAMD_STATS));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
547 for (octave_idx_type i = 0 ; i < CCOLAMD_STATS ; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
548 out_stats (i) = stats [i] ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
549 retval(1) = out_stats;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
550
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
551 // fix stats (5) and (6), for 1-based information on
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
552 // jumbled matrix. note that this correction doesn't
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
553 // occur if symamd returns FALSE
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
554 out_stats (CCOLAMD_INFO1) ++ ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
555 out_stats (CCOLAMD_INFO2) ++ ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
556 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
557
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
558 // print stats if spumoni > 0
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
559 if (spumoni > 0)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
560 CSYMAMD_NAME (_report) (stats) ;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
561
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
562 // Return the stats vector
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
563 if (nargout == 2)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
564 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
565 NDArray out_stats (dim_vector (1, CCOLAMD_STATS));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
566 for (octave_idx_type i = 0 ; i < CCOLAMD_STATS ; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
567 out_stats (i) = stats [i] ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
568 retval(1) = out_stats;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
569
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
570 // fix stats (5) and (6), for 1-based information on
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
571 // jumbled matrix. note that this correction doesn't
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
572 // occur if symamd returns FALSE
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
573 out_stats (CCOLAMD_INFO1) ++ ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
574 out_stats (CCOLAMD_INFO2) ++ ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
575 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
576 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
577
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
578 #else
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
579
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
580 error ("csymamd: not available in this version of Octave");
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
581
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
582 #endif
5771
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
583
9c7be8e14b5b [project @ 2006-04-18 19:17:33 by jwe]
jwe
parents: 5760
diff changeset
584 return retval;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents:
diff changeset
585 }