annotate src/DLD-FUNCTIONS/amd.cc @ 9064:7c02ec148a3c

Check grammar on all .cc files Same check as previously done on .m files Attempt to enforce some conformity in documentation text for rules such as two spaces after a period, commas around latin abbreviations, etc.
author Rik <rdrider0-list@yahoo.com>
date Sat, 28 Mar 2009 13:57:22 -0700
parents 25bc2d31e1bf
children be150a172010
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
1 /*
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
2
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 Copyright (C) 2008 David Bateman
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
4
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 This file is part of Octave.
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
6
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 option) any later version.
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
11
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 for more details.
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
16
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
20
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
21 */
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
22
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
23 // This is the octave interface to amd, which bore the copyright given
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 // in the help of the functions.
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
25
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
27 #include <config.h>
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
28 #endif
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
29
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
30 #include <cstdlib>
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
31
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
32 #include <string>
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 #include <vector>
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
34
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
35 #include "ov.h"
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
36 #include "defun-dld.h"
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
37 #include "pager.h"
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
38 #include "ov-re-mat.h"
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
39
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 #include "ov-re-sparse.h"
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
41 #include "ov-cx-sparse.h"
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
42 #include "oct-map.h"
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
43
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
44 #include "oct-sparse.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8333
diff changeset
45 #include "oct-locbuf.h"
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
46
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 #ifdef IDX_TYPE_LONG
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 #define AMD_NAME(name) amd_l ## name
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
49 #else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 #define AMD_NAME(name) amd ## name
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
51 #endif
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
52
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 DEFUN_DLD (amd, args, nargout,
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
54 "-*- texinfo -*-\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
55 @deftypefn {Loadable Function} {@var{p} =} amd (@var{s})\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
56 @deftypefnx {Loadable Function} {@var{p} =} amd (@var{s}, @var{opts})\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 \n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8377
diff changeset
58 Returns the approximate minimum degree permutation of a matrix. This\n\
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
59 permutation such that the Cholesky factorization of @code{@var{s} (@var{p},\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
60 @var{p})} tends to be sparser than the Cholesky factorization of @var{s}\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8377
diff changeset
61 itself. @code{amd} is typically faster than @code{symamd} but serves a\n\
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
62 similar purpose.\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
63 \n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
64 The optional parameter @var{opts} is a structure that controls the\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8377
diff changeset
65 behavior of @code{amd}. The fields of these structure are\n\
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
66 \n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
67 @table @asis\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
68 @item opts.dense\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
69 Determines what @code{amd} considers to be a dense row or column of the\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8377
diff changeset
70 input matrix. Rows or columns with more that @code{max(16, (dense *\n\
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
71 sqrt (@var{n})} entries, where @var{n} is the order of the matrix @var{s},\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
72 are igorned by @code{amd} during the calculation of the permutation\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
73 The value of dense must be a positive scalar and its default value is 10.0\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
74 \n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
75 @item opts.aggressive\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
76 If this value is a non zero scalar, then @code{amd} performs agressive\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8377
diff changeset
77 absorption. The default is not to perform agressive absorption.\n\
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
78 @end table\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
79 \n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
80 The author of the code itself is Timothy A. Davis (davis@@cise.ufl.edu),\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
81 University of Florida (see @url{http://www.cise.ufl.edu/research/sparse/amd}).\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
82 @seealso{symamd, colamd}\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
83 @end deftypefn")
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
84 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
85 octave_value_list retval;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
86
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
87 #ifdef HAVE_AMD
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
88 int nargin = args.length ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
89
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
90 if (nargin < 1 || nargin > 2)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
91 print_usage ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
92 else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
93 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
94 octave_idx_type n_row, n_col, nnz;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
95 const octave_idx_type *ridx, *cidx;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
96 SparseMatrix sm;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
97 SparseComplexMatrix scm;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
98
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
99 if (args(0).is_sparse_type ())
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
100 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
101 if (args(0).is_complex_type ())
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
102 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
103 scm = args(0).sparse_complex_matrix_value ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
104 n_row = scm.rows ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
105 n_col = scm.cols ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
106 nnz = scm.nzmax ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
107 ridx = scm.xridx ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
108 cidx = scm.xcidx ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
109 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
110 else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
111 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
112 sm = args(0).sparse_matrix_value ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
113 n_row = sm.rows ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
114 n_col = sm.cols ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
115 nnz = sm.nzmax ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
116 ridx = sm.xridx ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
117 cidx = sm.xcidx ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
118 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
119 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
120 else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
121 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
122 if (args(0).is_complex_type ())
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
123 sm = SparseMatrix (real (args(0).complex_matrix_value ()));
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
124 else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
125 sm = SparseMatrix (args(0).matrix_value ());
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
126
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
127 n_row = sm.rows ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
128 n_col = sm.cols ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
129 nnz = sm.nzmax ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
130 ridx = sm.xridx ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
131 cidx = sm.xcidx ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
132 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
133
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
134 if (!error_state && n_row != n_col)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
135 error ("amd: input matrix must be square");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
136
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
137 if (!error_state)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
138 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
139 OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL);
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
140 AMD_NAME (_defaults) (Control) ;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
141 if (nargin > 1)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
142 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
143 Octave_map arg1 = args(1).map_value ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
144
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
145 if (!error_state)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
146 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
147 if (arg1.contains ("dense"))
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
148 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
149 Cell c = arg1.contents ("dense");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
150 if (c.length() == 1)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
151 Control[AMD_DENSE] = c.elem(0).double_value ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
152 else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
153 error ("amd: invalid options structure");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
154 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
155 if (arg1.contains ("aggressive"))
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
156 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
157 Cell c = arg1.contents ("aggressive");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
158 if (c.length() == 1)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
159 Control[AMD_AGGRESSIVE] = c.elem(0).double_value ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
160 else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
161 error ("amd: invalid options structure");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
162 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
163 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
164 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
165
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
166 if (!error_state)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
167 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
168 OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col);
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
169 Matrix xinfo (AMD_INFO, 1);
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
170 double *Info = xinfo.fortran_vec ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
171
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 7619
diff changeset
172 // FIXME -- how can we manage the memory allocation of
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 7619
diff changeset
173 // amd in a cleaner manner?
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
174 amd_malloc = malloc;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
175 amd_free = free;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
176 amd_calloc = calloc;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
177 amd_realloc = realloc;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
178 amd_printf = printf;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
179
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
180 octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P,
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
181 Control, Info);
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
182
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
183 switch (result)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
184 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
185 case AMD_OUT_OF_MEMORY:
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
186 error ("amd: out of memory");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
187 break;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
188 case AMD_INVALID:
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
189 error ("amd: input matrix is corrupted");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
190 break;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
191 default:
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
192 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
193 if (nargout > 1)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
194 retval(1) = xinfo;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
195
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
196 Matrix Pout (1, n_col);
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
197 for (octave_idx_type i = 0; i < n_col; i++)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
198 Pout.xelem (i) = P[i] + 1;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
199
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
200 retval (0) = Pout;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
201 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
202 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
203 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
204 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
205 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
206 #else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
207
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
208 error ("amd: not available in this version of Octave");
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
209
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
210 #endif
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
211
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
212 return retval;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
213 }