Mercurial > octave-nkf
annotate libinterp/dldfcn/amd.cc @ 20267:a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
* liboctave/array/Array.h (Array::length): deprecate for ::numel.
* liboctave/array/Sparse.h (Sparse::length): deprecate for ::numel.
* libgui/graphics/QtHandlesUtils.cc, libgui/src/octave-qt-link.cc,
libinterp/corefcn/Cell.cc, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/cellfun.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl-render.h, libinterp/corefcn/graphics.cc,
libinterp/corefcn/graphics.in.h, libinterp/corefcn/help.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc,
libinterp/corefcn/ls-oct-ascii.h, libinterp/corefcn/lsode.cc,
libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h,
libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-stream.cc,
libinterp/corefcn/oct-stream.h, libinterp/corefcn/pr-output.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/rand.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/strfns.cc,
libinterp/corefcn/sub2ind.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/tsearch.cc,
libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc,
libinterp/corefcn/variables.cc, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xpow.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__magick_read__.cc,
libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/ccolamd.cc,
libinterp/dldfcn/colamd.cc, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h,
libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc,
libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov.cc,
libinterp/operators/op-int.h, libinterp/parse-tree/pt-pr-code.cc,
liboctave/array/Array-util.cc, liboctave/array/Array.cc,
liboctave/array/CColVector.cc, liboctave/array/CDiagMatrix.cc,
liboctave/array/CMatrix.cc, liboctave/array/CRowVector.cc,
liboctave/array/DiagArray2.cc, liboctave/array/DiagArray2.h,
liboctave/array/MArray.cc, liboctave/array/PermMatrix.cc,
liboctave/array/PermMatrix.h, liboctave/array/Sparse.cc,
liboctave/array/boolMatrix.cc, liboctave/array/chMatrix.cc,
liboctave/array/chNDArray.cc, liboctave/array/dColVector.cc,
liboctave/array/dDiagMatrix.cc, liboctave/array/dMatrix.cc,
liboctave/array/dRowVector.cc, liboctave/array/fCColVector.cc,
liboctave/array/fCDiagMatrix.cc, liboctave/array/fCMatrix.cc,
liboctave/array/fCRowVector.cc, liboctave/array/fColVector.cc,
liboctave/array/fDiagMatrix.cc, liboctave/array/fMatrix.cc,
liboctave/array/fRowVector.cc, liboctave/array/idx-vector.cc,
liboctave/array/intNDArray.cc, liboctave/numeric/CmplxCHOL.cc,
liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxQR.cc,
liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc,
liboctave/numeric/DASSL.cc, liboctave/numeric/LSODE.cc,
liboctave/numeric/ODES.cc, liboctave/numeric/ODES.h,
liboctave/numeric/base-dae.h, liboctave/numeric/base-lu.cc,
liboctave/numeric/dbleCHOL.cc, liboctave/numeric/dbleLU.cc,
liboctave/numeric/dbleQR.cc, liboctave/numeric/eigs-base.cc,
liboctave/numeric/fCmplxCHOL.cc, liboctave/numeric/fCmplxLU.cc,
liboctave/numeric/fCmplxQR.cc, liboctave/numeric/floatCHOL.cc,
liboctave/numeric/floatLU.cc, liboctave/numeric/floatQR.cc,
liboctave/numeric/lo-specfun.cc, liboctave/numeric/oct-rand.cc,
liboctave/numeric/oct-spparms.cc, liboctave/numeric/sparse-base-chol.cc,
liboctave/operators/mx-inlines.cc, liboctave/system/file-ops.cc,
liboctave/util/glob-match.h, liboctave/util/kpse.cc,
liboctave/util/lo-regexp.cc, liboctave/util/oct-glob.cc,
liboctave/util/pathsearch.cc, liboctave/util/str-vec.cc,
liboctave/util/str-vec.h, liboctave/util/url-transfer.cc: replace all usage
of Array::length() and Sparse::length() with ::numel().
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sat, 30 May 2015 03:14:07 +0100 |
parents | 075a5e2e1ba5 |
children | f90c8372b7ba |
rev | line source |
---|---|
7619 | 1 /* |
2 | |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19242
diff
changeset
|
3 Copyright (C) 2008-2015 David Bateman |
7619 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 // This is the octave interface to amd, which bore the copyright given | |
24 // in the help of the functions. | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include <config.h> | |
28 #endif | |
29 | |
30 #include <cstdlib> | |
31 | |
32 #include <string> | |
33 #include <vector> | |
34 | |
35 #include "ov.h" | |
36 #include "defun-dld.h" | |
37 #include "pager.h" | |
38 #include "ov-re-mat.h" | |
39 | |
40 #include "ov-re-sparse.h" | |
41 #include "ov-cx-sparse.h" | |
42 #include "oct-map.h" | |
43 | |
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 | 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 | 48 #define AMD_NAME(name) amd_l ## name |
49 #else | |
50 #define AMD_NAME(name) amd ## name | |
51 #endif | |
52 | |
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 | 57 \n\ |
20198
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
58 Return the approximate minimum degree permutation of a matrix.\n\ |
7619 | 59 \n\ |
20198
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
60 This is a permutation such that the Cholesky@tie{}factorization of\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
61 @code{@var{S} (@var{p}, @var{p})} tends to be sparser than the\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
62 Cholesky@tie{}factorization of @var{S} itself. @code{amd} is typically\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
63 faster than @code{symamd} but serves a similar purpose.\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
64 \n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
65 The optional parameter @var{opts} is a structure that controls the behavior\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
66 of @code{amd}. The fields of the structure are\n\ |
7619 | 67 \n\ |
68 @table @asis\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
69 @item @var{opts}.dense\n\ |
7619 | 70 Determines what @code{amd} considers to be a dense row or column of the\n\ |
18713
a142f35f3cb6
doc: Fix unbalanced parentheses in documentation.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
71 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
|
72 sqrt (@var{n})))} entries, where @var{n} is the order of the matrix @var{S},\n\ |
20198
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
73 are ignored by @code{amd} during the calculation of the permutation.\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
74 The value of dense must be a positive scalar and the default value is 10.0\n\ |
7619 | 75 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
76 @item @var{opts}.aggressive\n\ |
18848
53af80da6781
doc: Update documentation of sparse functions including seealso links.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
77 If this value is a nonzero scalar, then @code{amd} performs aggressive\n\ |
9066
be150a172010
Cleanup documentation for diagperm.texi, sparse.texi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
78 absorption. The default is not to perform aggressive absorption.\n\ |
7619 | 79 @end table\n\ |
80 \n\ | |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
81 The author of the code itself is Timothy A. Davis\n\ |
20198
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
82 @email{davis@@cise.ufl.edu}, University of Florida\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
83 (see @url{http://www.cise.ufl.edu/research/sparse/amd}).\n\ |
7619 | 84 @seealso{symamd, colamd}\n\ |
85 @end deftypefn") | |
86 { | |
87 octave_value_list retval; | |
88 | |
89 #ifdef HAVE_AMD | |
90 int nargin = args.length (); | |
91 | |
92 if (nargin < 1 || nargin > 2) | |
93 print_usage (); | |
94 else | |
95 { | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10154
diff
changeset
|
96 octave_idx_type n_row, n_col; |
7619 | 97 const octave_idx_type *ridx, *cidx; |
98 SparseMatrix sm; | |
99 SparseComplexMatrix scm; | |
100 | |
101 if (args(0).is_sparse_type ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
102 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
103 if (args(0).is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
104 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
105 scm = args(0).sparse_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
106 n_row = scm.rows (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
107 n_col = scm.cols (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
108 ridx = scm.xridx (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
109 cidx = scm.xcidx (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
110 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
111 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
112 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
113 sm = args(0).sparse_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
114 n_row = sm.rows (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
115 n_col = sm.cols (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
116 ridx = sm.xridx (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
117 cidx = sm.xcidx (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
118 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
119 } |
7619 | 120 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
121 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
122 if (args(0).is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
123 sm = SparseMatrix (real (args(0).complex_matrix_value ())); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
124 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
125 sm = SparseMatrix (args(0).matrix_value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
126 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
127 n_row = sm.rows (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
128 n_col = sm.cols (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
129 ridx = sm.xridx (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
130 cidx = sm.xcidx (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
131 } |
7619 | 132 |
133 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
|
134 error ("amd: matrix S must be square"); |
7619 | 135 |
136 if (!error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
137 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
138 OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
139 AMD_NAME (_defaults) (Control) ; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
140 if (nargin > 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
141 { |
11046
14993c9e857e
amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
10846
diff
changeset
|
142 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
|
143 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
144 if (!error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
145 { |
11046
14993c9e857e
amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
10846
diff
changeset
|
146 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
|
147 |
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
|
148 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
|
149 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
|
150 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
|
151 |
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
|
152 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
|
153 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
|
154 Control[AMD_AGGRESSIVE] = tmp.double_value (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
155 } |
11046
14993c9e857e
amd.cc, cellfun.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
10846
diff
changeset
|
156 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
157 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
|
158 } |
7619 | 159 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
160 if (!error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
161 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
162 OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
163 Matrix xinfo (AMD_INFO, 1); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
164 double *Info = xinfo.fortran_vec (); |
7619 | 165 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 // 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
|
167 // in a cleaner manner? |
19173
afd6179d2616
allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents:
18850
diff
changeset
|
168 SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc); |
afd6179d2616
allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents:
18850
diff
changeset
|
169 SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free); |
afd6179d2616
allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents:
18850
diff
changeset
|
170 SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc); |
afd6179d2616
allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents:
18850
diff
changeset
|
171 SUITESPARSE_ASSIGN_FPTR (realloc_func, amd_realloc, realloc); |
afd6179d2616
allow building with new version of SuiteSparse (bug #43063)
John W. Eaton <jwe@octave.org>
parents:
18850
diff
changeset
|
172 SUITESPARSE_ASSIGN_FPTR (printf_func, amd_printf, printf); |
7619 | 173 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
174 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
|
175 Control, Info); |
7619 | 176 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
177 switch (result) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
178 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
179 case AMD_OUT_OF_MEMORY: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
180 error ("amd: out of memory"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
181 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
182 case AMD_INVALID: |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
183 error ("amd: matrix S is corrupted"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
184 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
185 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
186 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
187 if (nargout > 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
188 retval(1) = xinfo; |
7619 | 189 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
190 Matrix Pout (1, n_col); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
191 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
|
192 Pout.xelem (i) = P[i] + 1; |
7619 | 193 |
14844
5bc9b9cb4362
maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
194 retval(0) = Pout; |
10154
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 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
198 } |
7619 | 199 } |
200 #else | |
201 | |
202 error ("amd: not available in this version of Octave"); | |
203 | |
204 #endif | |
205 | |
206 return retval; | |
207 } | |
19178
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
208 /* |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
209 %!shared A, A2, opts |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
210 %! A = ones (20, 30); |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
211 %! A2 = ones (30, 30); |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
212 %! |
19242
5f21e0bff135
Use %!testif HAVE_AMD for amd tests added in cset e99d7a2e7367
Mike Miller <mtmiller@ieee.org>
parents:
19178
diff
changeset
|
213 %!testif HAVE_AMD |
19178
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
214 %! assert(amd (A2), [1:30]) |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
215 %! opts.dense = 25; |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
216 %! assert(amd (A2, opts), [1:30]) |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
217 %! opts.aggressive = 1; |
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
218 %! assert(amd (A2, opts), [1:30]) |
19242
5f21e0bff135
Use %!testif HAVE_AMD for amd tests added in cset e99d7a2e7367
Mike Miller <mtmiller@ieee.org>
parents:
19178
diff
changeset
|
219 |
5f21e0bff135
Use %!testif HAVE_AMD for amd tests added in cset e99d7a2e7367
Mike Miller <mtmiller@ieee.org>
parents:
19178
diff
changeset
|
220 %!error <matrix S must be square|not available in this version> amd (A) |
5f21e0bff135
Use %!testif HAVE_AMD for amd tests added in cset e99d7a2e7367
Mike Miller <mtmiller@ieee.org>
parents:
19178
diff
changeset
|
221 %!error amd (A2, 2) |
5f21e0bff135
Use %!testif HAVE_AMD for amd tests added in cset e99d7a2e7367
Mike Miller <mtmiller@ieee.org>
parents:
19178
diff
changeset
|
222 %!error <matrix S is corrupted|not available in this version> amd ([]) |
19178
e99d7a2e7367
* amd.cc: Tests added.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19173
diff
changeset
|
223 */ |