Mercurial > octave-nkf
comparison liboctave/COLAMD/colamdmex.c @ 5438:49ff3dd744ee
[project @ 2005-09-04 12:25:21 by dbateman]
author | dbateman |
---|---|
date | Sun, 04 Sep 2005 12:25:21 +0000 |
parents | 57077d0ddc8e |
children |
comparison
equal
deleted
inserted
replaced
5437:009606303874 | 5438:49ff3dd744ee |
---|---|
1 /* ========================================================================== */ | 1 /* ========================================================================== */ |
2 /* === colamd mexFunction =================================================== */ | 2 /* === colamd mexFunction =================================================== */ |
3 /* ========================================================================== */ | 3 /* ========================================================================== */ |
4 | 4 |
5 /* | 5 /* COLAMD Version 2.4 |
6 | |
6 Usage: | 7 Usage: |
7 | 8 |
8 P = colamd (A) ; | 9 P = colamd (A) ; |
9 | |
10 P = colamd (A, knobs) ; | |
11 | |
12 [ P, stats ] = colamd (A) ; | |
13 | |
14 [ P, stats ] = colamd (A, knobs) ; | 10 [ P, stats ] = colamd (A, knobs) ; |
15 | 11 |
16 Returns a permutation vector P such that the LU factorization of A (:,P) | 12 see colamd.m for a description. |
17 tends to be sparser than that of A. The Cholesky factorization of | |
18 (A (:,P))'*(A (:,P)) will also tend to be sparser than that of A'*A. | |
19 This routine provides the same functionality as COLMMD, but is much faster | |
20 and returns a better permutation vector. Note that the COLMMD m-file in | |
21 MATLAB 5.2 also performs a column elimination tree post-ordering. This | |
22 mexFunction does not do this post-ordering. This mexFunction is a | |
23 replacement for the p = sparsfun ('colmmd', A) operation. | |
24 | |
25 The knobs and stats vectors are optional: | |
26 | |
27 knobs (1) rows with more than (knobs (1))*n_col entries | |
28 are removed prior to ordering. If knobs is not present, | |
29 then the default is used (0.5). | |
30 | |
31 knobs (2) columns with more than (knobs (2))*n_row entries | |
32 are removed prior to ordering, and placed last in the | |
33 column permutation. If knobs is not present, | |
34 then the default is used (0.5). | |
35 | |
36 knobs (3) print level, similar to spparms ('spumoni') | |
37 | |
38 stats (1) the number of dense (or empty) rows ignored | |
39 | |
40 stats (2) the number of dense (or empty) columms. These | |
41 are ordered last, in their natural order. | |
42 | |
43 stats (3) the number of garbage collections performed. | |
44 | |
45 stats (4) return status: | |
46 | |
47 0: matrix is a valid MATLAB matrix. | |
48 | |
49 1: matrix has duplicate entries or unsorted columns. | |
50 This should not occur in a valid MATLAB matrix, | |
51 but the ordering proceeded anyway by sorting the | |
52 row indices in each column and by ignoring the | |
53 duplicate row indices in each column. See | |
54 stats (5:7) for more information. | |
55 | |
56 stats (5) highest numbered column that is unsorted or has | |
57 duplicate entries (zero if none) | |
58 | |
59 stats (6) last seen duplicate or unsorted row index | |
60 (zero if none) | |
61 | |
62 stats (7) number of duplicate or unsorted row indices | |
63 | 13 |
64 Authors: | 14 Authors: |
65 | 15 |
66 The authors of the code itself are Stefan I. Larimore and Timothy A. | 16 The authors of the code itself are Stefan I. Larimore and Timothy A. |
67 Davis (davis@cise.ufl.edu), University of Florida. The algorithm was | 17 Davis (davis at cise.ufl.edu), University of Florida. The algorithm was |
68 developed in collaboration with John Gilbert, Xerox PARC, and Esmond | 18 developed in collaboration with John Gilbert, Xerox PARC, and Esmond |
69 Ng, Oak Ridge National Laboratory. | 19 Ng, Oak Ridge National Laboratory. |
70 | 20 |
71 Date: | |
72 | |
73 September 8, 2003. Version 2.3. | |
74 | |
75 Acknowledgements: | 21 Acknowledgements: |
76 | 22 |
77 This work was supported by the National Science Foundation, under | 23 This work was supported by the National Science Foundation, under |
78 grants DMS-9504974 and DMS-9803599. | 24 grants DMS-9504974 and DMS-9803599. |
79 | 25 |
80 Notice: | 26 Notice: |
81 | 27 |
82 Copyright (c) 1998-2003 by the University of Florida. | 28 Copyright (c) 1998-2005, Timothy A. Davis, All Rights Reserved. |
83 All Rights Reserved. | |
84 | 29 |
85 See http://www.cise.ufl.edu/research/sparse/colamd (the colamd.c | 30 See http://www.cise.ufl.edu/research/sparse/colamd (the colamd.c |
86 file) for the License. | 31 file) for the License. |
87 | 32 |
88 Availability: | 33 Availability: |
136 int i ; /* loop counter */ | 81 int i ; /* loop counter */ |
137 mxArray *Ainput ; /* input matrix handle */ | 82 mxArray *Ainput ; /* input matrix handle */ |
138 int spumoni ; /* verbosity variable */ | 83 int spumoni ; /* verbosity variable */ |
139 int stats [COLAMD_STATS] ; /* stats for colamd */ | 84 int stats [COLAMD_STATS] ; /* stats for colamd */ |
140 | 85 |
86 colamd_printf = mexPrintf ; /* COLAMD printf routine */ | |
87 | |
141 /* === Check inputs ===================================================== */ | 88 /* === Check inputs ===================================================== */ |
142 | 89 |
143 if (nrhs < 1 || nrhs > 2 || nlhs < 0 || nlhs > 2) | 90 if (nrhs < 1 || nrhs > 2 || nlhs < 0 || nlhs > 2) |
144 { | 91 { |
145 mexErrMsgTxt ( | 92 mexErrMsgTxt ( |
154 /* check for user-passed knobs */ | 101 /* check for user-passed knobs */ |
155 if (nrhs == 2) | 102 if (nrhs == 2) |
156 { | 103 { |
157 in_knobs = mxGetPr (prhs [1]) ; | 104 in_knobs = mxGetPr (prhs [1]) ; |
158 i = mxGetNumberOfElements (prhs [1]) ; | 105 i = mxGetNumberOfElements (prhs [1]) ; |
159 if (i > 0) knobs [COLAMD_DENSE_ROW] = in_knobs [COLAMD_DENSE_ROW] ; | 106 if (i > 0) knobs [COLAMD_DENSE_ROW] = in_knobs [0] ; |
160 if (i > 1) knobs [COLAMD_DENSE_COL] = in_knobs [COLAMD_DENSE_COL] ; | 107 if (i > 1) knobs [COLAMD_DENSE_COL] = in_knobs [1] ; |
161 if (i > 2) spumoni = (int) in_knobs [2] ; | 108 if (i > 2) spumoni = (int) (in_knobs [2] != 0) ; |
162 } | 109 } |
163 | 110 |
164 /* print knob settings if spumoni is set */ | 111 /* print knob settings if spumoni is set */ |
165 if (spumoni > 0) | 112 if (spumoni) |
166 { | 113 { |
167 mexPrintf ("colamd: dense row fraction: %f\n", | 114 mexPrintf ("\ncolamd version %d.%d, %s:\n", |
168 knobs [COLAMD_DENSE_ROW]) ; | 115 COLAMD_MAIN_VERSION, COLAMD_SUB_VERSION, COLAMD_DATE) ; |
169 mexPrintf ("colamd: dense col fraction: %f\n", | 116 if (knobs [COLAMD_DENSE_ROW] >= 0) |
170 knobs [COLAMD_DENSE_COL]) ; | 117 { |
118 mexPrintf ("knobs(1): %g, rows with > max(16,%g*sqrt(size(A,2)))" | |
119 " entries removed\n", in_knobs [0], knobs [COLAMD_DENSE_ROW]) ; | |
120 } | |
121 else | |
122 { | |
123 mexPrintf ("knobs(1): %g, only completely dense rows removed\n", | |
124 in_knobs [0]) ; | |
125 } | |
126 if (knobs [COLAMD_DENSE_COL] >= 0) | |
127 { | |
128 mexPrintf ("knobs(2): %g, cols with > max(16,%g*sqrt(min(size(A)))" | |
129 " entries removed\n", in_knobs [1], knobs [COLAMD_DENSE_COL]) ; | |
130 } | |
131 else | |
132 { | |
133 mexPrintf ("knobs(2): %g, only completely dense columns removed\n", | |
134 in_knobs [1]) ; | |
135 } | |
136 mexPrintf ("knobs(3): %g, statistics and knobs printed\n", | |
137 in_knobs [2]) ; | |
171 } | 138 } |
172 | 139 |
173 /* === If A is full, convert to a sparse matrix ========================= */ | 140 /* === If A is full, convert to a sparse matrix ========================= */ |
174 | 141 |
175 Ainput = (mxArray *) prhs [0] ; | 142 Ainput = (mxArray *) prhs [0] ; |
225 } | 192 } |
226 mxFree (p) ; | 193 mxFree (p) ; |
227 | 194 |
228 /* === Return the stats vector ========================================== */ | 195 /* === Return the stats vector ========================================== */ |
229 | 196 |
230 /* print stats if spumoni > 0 */ | 197 /* print stats if spumoni is set */ |
231 if (spumoni > 0) | 198 if (spumoni) |
232 { | 199 { |
233 colamd_report (stats) ; | 200 colamd_report (stats) ; |
234 } | 201 } |
235 | 202 |
236 if (nlhs == 2) | 203 if (nlhs == 2) |