annotate libinterp/dldfcn/amd.cc @ 18679:a142f35f3cb6

doc: Fix unbalanced parentheses in documentation. * errors.txi, install.txi, sparse.txi, vectorize.txi: Fix unbalanced parentheses. * data.cc (Fall, Feye): Fix unbalanced parentheses. * rand.cc (Frandn, Frande): Fix unbalanced parentheses. * amd.cc (Famd): Fix unbalanced parentheses. * ccolamd.cc (Fccolamd): Fix unbalanced parentheses. * DASPK-opts.in: Fix unbalanced parentheses. * cplxpair.m, javamem.m, glpk.m, area.m, peaks.m, hgload.m, hotelling_test_2.m, hgsave.m: Fix unbalanced parentheses.
author Rik <rik@octave.org>
date Fri, 25 Apr 2014 15:49:03 -0700
parents 175b392e91fe
children c53e11fab75f
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
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 16313
diff changeset
3 Copyright (C) 2008-2013 David Bateman
7619
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
16313
6aafe87a3144 use int64_t for idx type if --enable-64
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
47 #ifdef USE_64_BIT_IDX_T
7619
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,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
54 "-*- texinfo -*-\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
55 @deftypefn {Loadable Function} {@var{p} =} amd (@var{S})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
56 @deftypefnx {Loadable Function} {@var{p} =} amd (@var{S}, @var{opts})\n\
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 \n\
14038
b0cdd60db5e5 doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
58 Return the approximate minimum degree permutation of a matrix. This\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
59 permutation such that the Cholesky@tie{}factorization of @code{@var{S}\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
60 (@var{p}, @var{p})} tends to be sparser than the Cholesky@tie{}factorization\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
61 of @var{S} itself. @code{amd} is typically faster than @code{symamd} but\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
62 serves a similar purpose.\n\
7619
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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
65 behavior of @code{amd}. The fields of the 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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
68 @item @var{opts}.dense\n\
7619
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\
18679
a142f35f3cb6 doc: Fix unbalanced parentheses in documentation.
Rik <rik@octave.org>
parents: 17787
diff changeset
70 input matrix. Rows or columns with more than @code{max (16, (dense *\n\
a142f35f3cb6 doc: Fix unbalanced parentheses in documentation.
Rik <rik@octave.org>
parents: 17787
diff changeset
71 sqrt (@var{n})))} entries, where @var{n} is the order of the matrix @var{S},\n\
9066
be150a172010 Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents: 9064
diff changeset
72 are ignored by @code{amd} during the calculation of the permutation\n\
7619
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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
75 @item @var{opts}.aggressive\n\
9066
be150a172010 Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents: 9064
diff changeset
76 If this value is a non zero scalar, then @code{amd} performs aggressive\n\
be150a172010 Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents: 9064
diff changeset
77 absorption. The default is not to perform aggressive 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\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
80 The author of the code itself is Timothy A. Davis\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
81 @email{davis@@cise.ufl.edu}, University of Florida (see\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
82 @url{http://www.cise.ufl.edu/research/sparse/amd}).\n\
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
83 @seealso{symamd, colamd}\n\
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
84 @end deftypefn")
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
85 {
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
86 octave_value_list retval;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
87
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
88 #ifdef HAVE_AMD
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
89 int nargin = args.length ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
90
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
91 if (nargin < 1 || nargin > 2)
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
92 print_usage ();
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
93 else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
94 {
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10154
diff changeset
95 octave_idx_type n_row, n_col;
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
96 const octave_idx_type *ridx, *cidx;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
97 SparseMatrix sm;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
98 SparseComplexMatrix scm;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
99
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
100 if (args(0).is_sparse_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
101 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
102 if (args(0).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
103 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
104 scm = args(0).sparse_complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
105 n_row = scm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
106 n_col = scm.cols ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
107 ridx = scm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
108 cidx = scm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
109 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
110 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
111 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
112 sm = args(0).sparse_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
113 n_row = sm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
114 n_col = sm.cols ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
115 ridx = sm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
116 cidx = sm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
117 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
118 }
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
119 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
120 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
121 if (args(0).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
122 sm = SparseMatrix (real (args(0).complex_matrix_value ()));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
123 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
124 sm = SparseMatrix (args(0).matrix_value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
125
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
126 n_row = sm.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
127 n_col = sm.cols ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
128 ridx = sm.xridx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
129 cidx = sm.xcidx ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
130 }
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
131
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
132 if (!error_state && n_row != n_col)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
133 error ("amd: matrix S must be square");
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
134
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
135 if (!error_state)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
136 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
137 OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
138 AMD_NAME (_defaults) (Control) ;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
139 if (nargin > 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
140 {
11046
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
141 octave_scalar_map arg1 = args(1).scalar_map_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
142
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
143 if (!error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
144 {
11046
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
145 octave_value tmp;
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
146
11053
c33b7054f1f9 in recent Octave_map -> octave_scalar_map changes, use GETFIELD to access map elements, not CONTENTS
John W. Eaton <jwe@octave.org>
parents: 11046
diff changeset
147 tmp = arg1.getfield ("dense");
11046
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
148 if (tmp.is_defined ())
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
149 Control[AMD_DENSE] = tmp.double_value ();
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
150
11053
c33b7054f1f9 in recent Octave_map -> octave_scalar_map changes, use GETFIELD to access map elements, not CONTENTS
John W. Eaton <jwe@octave.org>
parents: 11046
diff changeset
151 tmp = arg1.getfield ("aggressive");
11046
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
152 if (tmp.is_defined ())
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
153 Control[AMD_AGGRESSIVE] = tmp.double_value ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
154 }
11046
14993c9e857e amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
155 else
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
156 error ("amd: OPTS argument must be a scalar structure");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
157 }
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
158
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
159 if (!error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
160 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
161 OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
162 Matrix xinfo (AMD_INFO, 1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
163 double *Info = xinfo.fortran_vec ();
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
164
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
165 // FIXME: how can we manage the memory allocation of amd
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
166 // in a cleaner manner?
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
167 amd_malloc = malloc;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
168 amd_free = free;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
169 amd_calloc = calloc;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
170 amd_realloc = realloc;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
171 amd_printf = printf;
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
172
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
173 octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
174 Control, Info);
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
175
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
176 switch (result)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
177 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
178 case AMD_OUT_OF_MEMORY:
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
179 error ("amd: out of memory");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
180 break;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
181 case AMD_INVALID:
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
182 error ("amd: matrix S is corrupted");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
183 break;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
184 default:
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
185 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
186 if (nargout > 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
187 retval(1) = xinfo;
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
188
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
189 Matrix Pout (1, n_col);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
190 for (octave_idx_type i = 0; i < n_col; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
191 Pout.xelem (i) = P[i] + 1;
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
192
14844
5bc9b9cb4362 maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
193 retval(0) = Pout;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
194 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
195 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
196 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
197 }
7619
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
198 }
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
199 #else
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
200
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
201 error ("amd: not available in this version of Octave");
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 #endif
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 return retval;
56012914972a Add the amd function
David Bateman <dbateman@free.fr>
parents:
diff changeset
206 }