Mercurial > octave-nkf
comparison liboctave/UMFPACK/UMFPACK/Doc/UserGuide.stex @ 5164:57077d0ddc8e
[project @ 2005-02-25 19:55:24 by jwe]
author | jwe |
---|---|
date | Fri, 25 Feb 2005 19:55:28 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5163:9f3299378193 | 5164:57077d0ddc8e |
---|---|
1 %------------------------------------------------------------------------------- | |
2 % The UserGuide.stex file. Processed into UserGuide.tex via sed. | |
3 %------------------------------------------------------------------------------- | |
4 | |
5 \documentclass[11pt]{article} | |
6 | |
7 \newcommand{\m}[1]{{\bf{#1}}} % for matrices and vectors | |
8 \newcommand{\tr}{^{\sf T}} % transpose | |
9 \newcommand{\he}{^{\sf H}} % complex conjugate transpose | |
10 \newcommand{\implies}{\rightarrow} | |
11 | |
12 \topmargin 0in | |
13 \textheight 9in | |
14 \oddsidemargin 0pt | |
15 \evensidemargin 0pt | |
16 \textwidth 6.5in | |
17 | |
18 \begin{document} | |
19 | |
20 \author{Timothy A. Davis \\ | |
21 Dept. of Computer and Information Science and Engineering \\ | |
22 Univ. of Florida, Gainesville, FL} | |
23 \title{UMFPACK Version 4.4 User Guide} | |
24 \date{Jan. 28, 2005} | |
25 \maketitle | |
26 | |
27 %------------------------------------------------------------------------------- | |
28 \begin{abstract} | |
29 UMFPACK is a set of routines for solving unsymmetric sparse linear | |
30 systems, $\m{Ax}=\m{b}$, using the Unsymmetric MultiFrontal method | |
31 and direct sparse LU factorization. It is written in ANSI/ISO C, with a | |
32 MATLAB interface. UMFPACK relies on the Level-3 Basic | |
33 Linear Algebra Subprograms (dense matrix multiply) for its performance. | |
34 This code works on Windows and many versions of Unix (Sun Solaris, | |
35 Red Hat Linux, IBM AIX, SGI IRIX, and Compaq Alpha). | |
36 \end{abstract} | |
37 %------------------------------------------------------------------------------- | |
38 | |
39 Technical Report TR-04-003 (revised) | |
40 | |
41 UMFPACK Version 4.4 (Jan. 28, 2005), Copyright\copyright 2005 by Timothy A. | |
42 Davis. All Rights Reserved. | |
43 | |
44 {\bf UMFPACK License:} | |
45 Your use or distribution of UMFPACK or any modified version of | |
46 UMFPACK implies that you agree to this License. | |
47 | |
48 THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY | |
49 EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
50 | |
51 Permission is hereby granted to use or copy this program, provided | |
52 that the Copyright, this License, and the Availability of the original | |
53 version is retained on all copies. User documentation of any code that | |
54 uses UMFPACK or any modified version of UMFPACK code must cite the | |
55 Copyright, this License, the Availability note, and ``Used by permission.'' | |
56 Permission to modify the code and to distribute modified code is granted, | |
57 provided the Copyright, this License, and the Availability note are | |
58 retained, and a notice that the code was modified is included. This | |
59 software was developed with support from the National Science Foundation, | |
60 and is provided to you free of charge. | |
61 | |
62 {\bf Availability:} | |
63 http://www.cise.ufl.edu/research/sparse/umfpack | |
64 | |
65 {\bf Acknowledgments:} | |
66 | |
67 This work was supported by the National Science Foundation, under | |
68 grants DMS-9504974, DMS-9803599, and CCR-0203270. | |
69 The upgrade to Version 4.1 and the inclusion of the | |
70 symmetric and 2-by-2 pivoting strategies | |
71 were done while the author was on sabbatical at | |
72 Stanford University and Lawrence Berkeley National Laboratory. | |
73 | |
74 %------------------------------------------------------------------------------- | |
75 \newpage | |
76 %------------------------------------------------------------------------------- | |
77 | |
78 \tableofcontents | |
79 | |
80 %------------------------------------------------------------------------------- | |
81 \newpage | |
82 \section{Overview} | |
83 %------------------------------------------------------------------------------- | |
84 | |
85 UMFPACK\footnote{Pronounced with two syllables: umph-pack} | |
86 Version 4.4 is a set of routines for solving systems of linear | |
87 equations, $\m{Ax}=\m{b}$, when $\m{A}$ is sparse and unsymmetric. It is based | |
88 on the Unsymmetric-pattern MultiFrontal method \cite{DavisDuff97,DavisDuff99}. | |
89 UMFPACK factorizes | |
90 $\m{PAQ}$, $\m{PRAQ}$, or $\m{PR}^{-1}\m{AQ}$ into the product $\m{LU}$, | |
91 where $\m{L}$ and $\m{U}$ | |
92 are lower and upper triangular, respectively, $\m{P}$ and $\m{Q}$ are | |
93 permutation matrices, and $\m{R}$ is a diagonal matrix of row scaling factors | |
94 (or $\m{R}=\m{I}$ if row-scaling is not used). Both $\m{P}$ and $\m{Q}$ are | |
95 chosen to reduce fill-in (new nonzeros in $\m{L}$ and $\m{U}$ that are not | |
96 present in $\m{A}$). The permutation $\m{P}$ has the dual role of reducing | |
97 fill-in and maintaining numerical accuracy (via relaxed partial pivoting | |
98 and row interchanges). | |
99 | |
100 The sparse matrix $\m{A}$ can be square or rectangular, singular | |
101 or non-singular, and real or complex (or any combination). Only square | |
102 matrices $\m{A}$ can be used to solve $\m{Ax}=\m{b}$ or related systems. | |
103 Rectangular matrices can only be factorized. | |
104 | |
105 UMFPACK first finds a column pre-ordering that reduces fill-in, without regard | |
106 to numerical values. It scales and analyzes the matrix, and then automatically | |
107 selects one of three strategies for pre-ordering the rows and columns: | |
108 {\em unsymmetric}, | |
109 {\em 2-by-2}, and | |
110 {\em symmetric}. These strategies are described below. | |
111 | |
112 First, all pivots with zero Markowitz cost are eliminated and placed in the | |
113 LU factors. The remaining submatrix $\m{S}$ is then analyzed. | |
114 The following rules are applied, and the first one that matches defines | |
115 the strategy. | |
116 | |
117 \begin{itemize} | |
118 \item Rule 1: $\m{A}$ rectangular $\implies$ unsymmetric. | |
119 \item Rule 2: | |
120 If the zero-Markowitz elimination results in a rectangular $\m{S}$, | |
121 or an $\m{S}$ whose diagonal has not been preserved, the | |
122 unsymmetric strategy is used. | |
123 \item The symmetry $\sigma_1$ of $\m{S}$ is computed. It is defined as | |
124 the number of {\em matched} off-diagonal entries, divided by the | |
125 total number of off-diagonal entries. An entry $s_{ij}$ is matched | |
126 if $s_{ji}$ is also an entry. They need not be numerically equal. | |
127 An {\em entry} is a value in $\m{A}$ which is present | |
128 in the input data structure. All nonzeros are entries, but some entries | |
129 may be numerically zero. | |
130 Rule 3: $\sigma_1 < 0.1 \implies$ unsymmetric. | |
131 The matrix is very unsymmetric. | |
132 \item Let $d$ be the number of nonzero entries on the diagonal of $\m{S}$. | |
133 Let $\m{S}$ be $\nu$-by-$\nu$. | |
134 Rule 4: $(\sigma_1 \ge 0.7) \:\wedge\: (d = \nu) \implies$ symmetric. | |
135 The matrix has a nearly symmetric nonzero pattern, and a zero-free | |
136 diagonal. | |
137 \end{itemize} | |
138 | |
139 If the strategy has not yet been determined, | |
140 the 2-by-2 strategy is attempted. A row permutation $\m{P}_2$ | |
141 is found which attempts to reduce the number of small | |
142 diagonal entries of $\m{P}_2 \m{S}$. | |
143 An entry $s_{ij}$ is determined to be small if | |
144 $|s_{ij}| < 0.01 \max |s_{*j}|$, or large otherwise. | |
145 If $s_{ii}$ is numerically small, the method attempts to swap | |
146 two rows $i$ and $j$, such that both $s_{ij}$ and $s_{ji}$ are large. | |
147 Once these rows are swapped, | |
148 they remain in place. Let $\sigma_2$ be the symmetry of $\m{P}_2 \m{S}$, | |
149 and let $d_2$ be the number of nonzero entries (either small or large) | |
150 on the diagonal of $\m{P}_2 \m{S}$. | |
151 | |
152 \begin{itemize} | |
153 \item Rule 5: | |
154 ($\sigma_2 > 1.1 \sigma_1) \:\wedge\: (d_2 > 0.9 \nu) \implies$ 2-by-2. | |
155 The 2-by-2 permutation has made the matrix significantly more symmetric. | |
156 \item Rule 6: $\sigma_2 < 0.7 \sigma_1 \implies$ unsymmetric. | |
157 The 2-by-2 strategy has significantly deteriorated the symmetry, | |
158 \item Rule 7: $\sigma_2 < 0.25 \implies$ unsymmetric. | |
159 The matrix is still very unsymmetric. | |
160 \item Rule 8: $\sigma_2 \ge 0.51 \implies$ 2-by-2. | |
161 The matrix is roughly symmetric. | |
162 \item Rule 9: $\sigma_2 \ge 0.999 \sigma_1 \implies$ 2-by-2. | |
163 The 2-by-2 permutation has preserved symmetry, or made it only | |
164 slightly worse. | |
165 \item Rule 10: if no rule has yet triggered, use the unsymmetric strategy. | |
166 \end{itemize} | |
167 | |
168 Each strategy is described below: | |
169 \begin{itemize} | |
170 \item {\em unsymmetric}: | |
171 The column pre-ordering of $\m{S}$ is computed by a modified version of COLAMD | |
172 \cite{DavisGilbertLarimoreNg00_algo,DavisGilbertLarimoreNg00,Larimore98}. | |
173 The method finds a symmetric permutation $\m{Q}$ of the matrix $\m{S}\tr\m{S}$ | |
174 (without forming $\m{S}\tr\m{S}$ explicitly). This is a good choice for | |
175 $\m{Q}$, since the Cholesky factors of $\m{(SQ)\tr(SQ)}$ are an upper bound (in | |
176 terms of nonzero pattern) of the factor $\m{U}$ for the unsymmetric LU | |
177 factorization ($\m{PSQ}=\m{LU}$) regardless of the choice of $\m{P}$ | |
178 \cite{GeorgeNg85,GeorgeNg87,GilbertNg93}. This modified version of | |
179 COLAMD also computes the column elimination tree and post-orders the | |
180 tree. It finds the upper bound on the number of nonzeros in L and U. | |
181 It also has a different threshold for determining dense rows and columns. | |
182 During factorization, the column pre-ordering can be modified. | |
183 Columns within a single super-column can be reshuffled, to reduce fill-in. | |
184 Threshold partial pivoting is used with no preference given to the diagonal | |
185 entry. Within a given pivot column $j$, an entry $a_{ij}$ can be chosen if | |
186 $|a_{ij}| \ge 0.1 \max |a_{*j}|$. Among those numerically acceptable | |
187 entries, the sparsest row $i$ is chosen as the pivot row. | |
188 | |
189 \item {\em 2-by-2}: | |
190 The symmetric strategy (see below) is applied to the matrix $\m{P}_2 \m{S}$, | |
191 rather than $\m{S}$. | |
192 | |
193 \item {\em symmetric}: | |
194 The column ordering is computed from AMD | |
195 \cite{AmestoyDavisDuff96,AmestoyDavisDuff03}, | |
196 applied to the pattern of $\m{S}+\m{S}\tr$ | |
197 followed by a post-ordering of the supernodal elimination | |
198 tree of $\m{S}+\m{S}\tr$. | |
199 No modification of the column pre-ordering is made during numerical | |
200 factorization. Threshold partial pivoting is used, with a strong | |
201 preference given to the diagonal entry. The diagonal entry is chosen if | |
202 $a_{jj} \ge 0.001 \max |a_{*j}|$. Otherwise, a sparse row is selected, | |
203 using the same method used by the unsymmetric strategy. | |
204 | |
205 \end{itemize} | |
206 | |
207 The symmetric and 2-by-2 strategies, and their automatic selection, | |
208 are new to Version 4.1. Version 4.0 only used the unsymmetric strategy. | |
209 | |
210 Once the strategy is selected, | |
211 the factorization of the matrix $\m{A}$ is broken down into the factorization | |
212 of a sequence of dense rectangular frontal matrices. The frontal matrices are | |
213 related to each other by a supernodal column elimination tree, in which each | |
214 node in the tree represents one frontal matrix. This analysis phase also | |
215 determines upper bounds on the memory usage, the floating-point operation count, | |
216 and the number of nonzeros in the LU factors. | |
217 | |
218 UMFPACK factorizes each {\em chain} of frontal matrices in a single working | |
219 array, similar to how the unifrontal method \cite{dusc:96} factorizes the whole | |
220 matrix. A chain of frontal matrices is a sequence of fronts where the parent | |
221 of front $i$ is $i$+1 in the supernodal column elimination tree. For the | |
222 nonsingular matrices factorized with the unsymmetric strategy, there are | |
223 exactly the same number of chains as there are leaves in the supernodal | |
224 column elimination tree. UMFPACK is an | |
225 outer-product based, right-looking method. At the $k$-th step of Gaussian | |
226 elimination, it represents the updated submatrix $\m{A}_k$ as an implicit | |
227 summation of a set of dense sub-matrices (referred to as {\em elements}, | |
228 borrowing a phrase from finite-element methods) that arise when the frontal | |
229 matrices are factorized and their pivot rows and columns eliminated. | |
230 | |
231 Each frontal matrix represents the elimination of one or more columns; | |
232 each column of $\m{A}$ will be eliminated in a specific frontal matrix, | |
233 and which frontal matrix will be used for which column is determined by | |
234 the pre-analysis phase. The pre-analysis phase also determines the worst-case | |
235 size of each frontal matrix so that they can hold any candidate pivot column | |
236 and any candidate pivot row. From the perspective of the analysis phase, any | |
237 candidate pivot column in the frontal matrix is identical (in terms of nonzero | |
238 pattern), and so is any row. However, the numeric factorization phase has | |
239 more information than the analysis phase. It uses this information to reorder | |
240 the columns within each frontal matrix to reduce fill-in. Similarly, since | |
241 the number of nonzeros in each row and column are maintained (more precisely, | |
242 COLMMD-style approximate degrees \cite{GilbertMolerSchreiber}), a pivot row can | |
243 be selected based on sparsity-preserving criteria (low degree) as well as | |
244 numerical considerations (relaxed threshold partial pivoting). | |
245 | |
246 When the symmetric or 2-by-2 strategies are used, | |
247 the column preordering is not refined during numeric factorization. | |
248 Row pivoting for sparsity and numerical accuracy is performed if the | |
249 diagonal entry is too small. | |
250 | |
251 More details of the method, including experimental results, are | |
252 described in \cite{Davis03,Davis03_algo}, available at | |
253 http://www.cise.ufl.edu/tech-reports. | |
254 | |
255 %------------------------------------------------------------------------------- | |
256 \section{Availability} | |
257 %------------------------------------------------------------------------------- | |
258 | |
259 In addition to appearing as a Collected Algorithm of the ACM, | |
260 UMFPACK Version 4.4 is available at http://www.cise.ufl.edu/research/sparse. | |
261 Version 4.3 is included as a built-in routine in MATLAB | |
262 7.1. Version 4.0 (in MATLAB 6.5) | |
263 does not have the symmetric or 2-by-2 strategies and it takes | |
264 less advantage of the level-3 | |
265 BLAS \cite{DaydeDuff99,ACM679a,ATLAS,GotoVandeGeijn02}. | |
266 Version 4.4 (and v4.3 through v4.1) tend to be much faster than Version 4.0, | |
267 particularly on unsymmetric matrices with mostly symmetric | |
268 nonzero pattern (such as finite element and circuit simulation matrices). | |
269 Version 3.0 and following make | |
270 use of a modified version of COLAMD V2.0 by Timothy A.~Davis, Stefan | |
271 Larimore, John Gilbert, and Esmond Ng. The original COLAMD V2.1 is available in | |
272 as a built-in routine in MATLAB V6.0 (or later), and at | |
273 http://www.cise.ufl.edu/research/sparse. | |
274 These codes are also available in Netlib \cite{netlib} at | |
275 http://www.netlib.org. | |
276 UMFPACK Versions 2.2.1 and earlier, co-authored with Iain Duff, | |
277 are available at http://www.cise.ufl.edu/research/sparse and as | |
278 MA38 (functionally equivalent to Version 2.2.1) in the Harwell | |
279 Subroutine Library. | |
280 | |
281 %------------------------------------------------------------------------------- | |
282 \section{Primary changes from prior versions} | |
283 %------------------------------------------------------------------------------- | |
284 | |
285 A detailed list of changes is in the {\tt ChangeLog} file. | |
286 | |
287 %------------------------------------------------------------------------------- | |
288 \subsection{Version 4.4} | |
289 %------------------------------------------------------------------------------- | |
290 | |
291 Bug fix in strategy selection in {\tt umfpack\_*\_qsymbolic}. | |
292 Added packed complex case for all complex input/output arguments. | |
293 Added {\tt umfpack\_get\_determinant}. | |
294 Added minimal support for Microsoft Visual Studio | |
295 (the {\tt umf\_multicompile.c} file). | |
296 | |
297 %------------------------------------------------------------------------------- | |
298 \subsection{Version 4.3.1} | |
299 %------------------------------------------------------------------------------- | |
300 | |
301 Minor bug fix in the forward/backsolve. This bug had the effect of turning | |
302 off iterative refinement when solving $\m{A}\tr\m{x}=\m{b}$ after factorizing | |
303 $\m{A}$. UMFPACK mexFunction now factorizes $\m{A}\tr$ in its forward-slash | |
304 operation. | |
305 | |
306 %------------------------------------------------------------------------------- | |
307 \subsection{Version 4.3} | |
308 %------------------------------------------------------------------------------- | |
309 | |
310 No changes are visible to the C or MATLAB user, except the presence of | |
311 one new control parameter in the {\tt Control} array, | |
312 and three new statistics in the {\tt Info} array. | |
313 The primary change is the addition of an (optional) drop tolerance. | |
314 | |
315 %------------------------------------------------------------------------------- | |
316 \subsection{Version 4.1} | |
317 %------------------------------------------------------------------------------- | |
318 | |
319 The following is a summary of the main changes that are visible to the C | |
320 or MATLAB user: | |
321 | |
322 \begin{enumerate} | |
323 | |
324 \item New ordering strategies added. No changes are required in user code | |
325 (either C or MATLAB) to use the new default strategy, which is an automatic | |
326 selection of the unsymmetric, symmetric, or 2-by-2 strategies. | |
327 | |
328 \item Row scaling added. This is only visible to the MATLAB caller when using | |
329 the form {\tt [L,U,P,Q,R] = umfpack (A)}, to retrieve the LU factors. | |
330 Likewise, it is only visible to the C caller when the LU factors are | |
331 retrieved, or when solving systems with just $\m{L}$ or $\m{U}$. | |
332 New C-callable and MATLAB-callable routines are included to get and to | |
333 apply the scale factors computed by UMFPACK. Row scaling is enabled by | |
334 default, but can be disabled. Row scaling usually leads to a better | |
335 factorization, particularly when the symmetric strategy is used. | |
336 | |
337 \item Error code {\tt UMFPACK\_ERROR\_problem\_to\_large} removed. | |
338 Version 4.0 would generate this error when the upper bound memory usage | |
339 exceeded 2GB (for the {\tt int} version), even when the actual memory | |
340 usage was less than this. The new version properly handles this case, | |
341 and can successfully factorize the matrix if sufficient memory is | |
342 available. | |
343 | |
344 \item New control parameters and statistics provided. | |
345 | |
346 \item The AMD symmetric approximate minimum degree ordering routine added | |
347 \cite{AmestoyDavisDuff96,AmestoyDavisDuff03}. | |
348 It is used by UMFPACK, and can also be called independently from C or | |
349 MATLAB. | |
350 | |
351 \item The {\tt umfpack} mexFunction now returns permutation matrices, not | |
352 permutation vectors, when using the form {\tt [L,U,P,Q] = umfpack (A)} | |
353 or the new form {\tt [L,U,P,Q,R] = umfpack (A)}. | |
354 | |
355 \item New arguments added to the user-callable routines | |
356 {\tt umfpack\_*\_symbolic}, | |
357 {\tt umfpack\_*\_qsymbolic}, | |
358 {\tt umfpack\_*\_get\_numeric}, and | |
359 {\tt umfpack\_*\_get\_symbolic}. | |
360 The symbolic analysis now makes use of the numerical values of the matrix | |
361 $\m{A}$, to guide the 2-by-2 strategy. The subsequent matrix passed to | |
362 the numeric factorization step does not have to have the same numerical | |
363 values. All of the new arguments are optional. If you do not wish to | |
364 include them, simply pass {\tt NULL} pointers instead. The 2-by-2 strategy | |
365 will assume all entries are numerically large, for example. | |
366 | |
367 \item New routines added to save and load the {\tt Numeric} and {\tt Symbolic} | |
368 objects to and from a binary file. | |
369 | |
370 \item A Fortran interface added. It provides access to a subset of | |
371 UMFPACK's features. | |
372 | |
373 \item You can compute an incomplete LU factorization, by dropping small | |
374 entries from $\m{L}$ and $\m{U}$. By default, no nonzero entry is | |
375 dropped, no matter how small in absolute value. This feature is new | |
376 to Version 4.3. | |
377 | |
378 \end{enumerate} | |
379 | |
380 %------------------------------------------------------------------------------- | |
381 \section{Using UMFPACK in MATLAB} | |
382 %------------------------------------------------------------------------------- | |
383 | |
384 The easiest way to use UMFPACK is within MATLAB. Version 4.3 is a built-in | |
385 routine in MATLAB 7.1, and is used in {\tt x = A}$\backslash${\tt b} when | |
386 {\tt A} is sparse, square, unsymmetric (or symmetric but not positive definite), | |
387 and with nonzero entries that are not confined in a narrow band. | |
388 It is also used for the {\tt [L,U,P,Q] = lu (A)} usage of {\tt lu}. | |
389 Type {\tt help lu} in MATLAB 6.5 or later for more details. | |
390 | |
391 To use the UMFPACK mexFunction, you must download and compile it, | |
392 since the mexFunction itself is not part of MATLAB. | |
393 The following discussion assumes that | |
394 you have MATLAB Version 6.0 or later (which includes the BLAS, and the | |
395 {\tt colamd} ordering routine). To compile both the UMFPACK and AMD | |
396 mexFunctions, just type {\tt make} in the Unix system shell, | |
397 while in the {\tt UMFPACK} directory. | |
398 You can also type {\tt umfpack\_make} in MATLAB, if you are in the | |
399 {\tt UMFPACK/MATLAB} directory, or if that directory is in your MATLAB path. | |
400 This works on any system with MATLAB, including Windows. | |
401 See Section~\ref{Install} for more details on how to install UMFPACK. | |
402 Once installed, the UMFPACK mexFunction can analyze, factor, and solve linear | |
403 systems. Table~\ref{matlab} summarizes some of the more common uses | |
404 of the UMFPACK mexFunction within MATLAB. | |
405 | |
406 An optional input argument can be used to modify the control parameters for | |
407 UMFPACK, and an optional output argument provides statistics on the | |
408 factorization. | |
409 | |
410 Refer to the AMD User Guide for more details about the AMD mexFunction. | |
411 | |
412 \begin{table} | |
413 \caption{Using UMFPACK's MATLAB interface} | |
414 \label{matlab} | |
415 \vspace{0.1in} | |
416 {\footnotesize | |
417 \begin{tabular}{l|l|l} | |
418 \hline | |
419 Function & Using UMFPACK & MATLAB 6.0 equivalent \\ | |
420 \hline | |
421 & & \\ | |
422 \begin{minipage}[t]{1.5in} | |
423 Solve $\m{Ax}=\m{b}$. | |
424 \end{minipage} | |
425 & | |
426 \begin{minipage}[t]{2.2in} | |
427 \begin{verbatim} | |
428 x = umfpack (A,'\',b) ; | |
429 \end{verbatim} | |
430 \end{minipage} | |
431 & | |
432 \begin{minipage}[t]{2.2in} | |
433 \begin{verbatim} | |
434 x = A \ b ; | |
435 \end{verbatim} | |
436 \end{minipage} | |
437 \\ | |
438 & & \\ | |
439 \hline | |
440 & & \\ | |
441 \begin{minipage}[t]{1.5in} | |
442 Solve $\m{Ax}=\m{b}$ using a different row and column pre-ordering | |
443 (symmetric ordering). | |
444 \end{minipage} | |
445 & | |
446 \begin{minipage}[t]{2.2in} | |
447 \begin{verbatim} | |
448 S = spones (A) ; | |
449 Q = symamd (S+S') ; | |
450 Control = umfpack ; | |
451 Control (6) = 3 ; | |
452 x = umfpack (A,Q,'\',b,Control) ; | |
453 \end{verbatim} | |
454 \end{minipage} | |
455 & | |
456 \begin{minipage}[t]{2.2in} | |
457 \begin{verbatim} | |
458 spparms ('autommd',0) ; | |
459 S = spones (A) ; | |
460 Q = symamd (S+S') ; | |
461 x = A (Q,Q) \ b (Q) ; | |
462 x (Q) = x ; | |
463 spparms ('autommd',1) ; | |
464 \end{verbatim} | |
465 \end{minipage} | |
466 \\ | |
467 & & \\ | |
468 \hline | |
469 & & \\ | |
470 \begin{minipage}[t]{1.5in} | |
471 Solve $\m{A}\tr\m{x}\tr = \m{b}\tr$. | |
472 \end{minipage} | |
473 & | |
474 \begin{minipage}[t]{2.2in} | |
475 \begin{verbatim} | |
476 x = umfpack (b,'/',A) ; | |
477 \end{verbatim} | |
478 Note: $\m{A}$ is factorized. | |
479 \end{minipage} | |
480 & | |
481 \begin{minipage}[t]{2.2in} | |
482 \begin{verbatim} | |
483 x = b / A ; | |
484 \end{verbatim} | |
485 Note: $\m{A}\tr$ is factorized. | |
486 \end{minipage} | |
487 \\ | |
488 & & \\ | |
489 \hline | |
490 & & \\ | |
491 \begin{minipage}[t]{1.5in} | |
492 Scale and factorize $\m{A}$, then solve $\m{Ax}=\m{b}$. | |
493 \end{minipage} | |
494 & | |
495 \begin{minipage}[t]{2.2in} | |
496 \begin{verbatim} | |
497 [L,U,P,Q,R] = umfpack (A) ; | |
498 c = P * (R \ b) ; | |
499 x = Q * (U \ (L \ c)) ; | |
500 \end{verbatim} | |
501 \end{minipage} | |
502 & | |
503 \begin{minipage}[t]{2.2in} | |
504 \begin{verbatim} | |
505 [m n] = size (A) ; | |
506 r = full (sum (abs (A), 2)) ; | |
507 r (find (r == 0)) = 1 ; | |
508 R = spdiags (r, 0, m, m) ; | |
509 I = speye (n) ; | |
510 Q = I (:, colamd (A)) ; | |
511 [L,U,P] = lu ((R\A)*Q) ; | |
512 c = P * (R \ b) ; | |
513 x = Q * (U \ (L \ c)) ; | |
514 \end{verbatim} | |
515 \end{minipage} | |
516 \\ | |
517 & & \\ | |
518 \hline | |
519 \end{tabular} | |
520 } | |
521 \end{table} | |
522 | |
523 Note: in MATLAB 6.5 or later, use {\tt spparms ('autoamd',0)} in addition to | |
524 {\tt spparms ('autommd',0)}, in Table~\ref{matlab}, to turn off MATLAB's | |
525 default reordering. | |
526 | |
527 UMFPACK requires | |
528 {\tt b} to be a dense vector (real or complex) of the appropriate dimension. | |
529 This is more restrictive than what you can do with MATLAB's | |
530 backslash or forward slash. See {\tt umfpack\_solve} for an M-file that | |
531 removes this restriction. | |
532 This restriction does not apply to the built-in backslash operator | |
533 in MATLAB 6.5 or later, which uses UMFPACK to factorize the matrix. | |
534 You can do this yourself in MATLAB: | |
535 | |
536 {\footnotesize | |
537 \begin{verbatim} | |
538 [L,U,P,Q,R] = umfpack (A) ; | |
539 x = Q * (U \ (L \ (P * (R \ b)))) ; | |
540 \end{verbatim} | |
541 } | |
542 | |
543 or, with no row scaling: | |
544 | |
545 {\footnotesize | |
546 \begin{verbatim} | |
547 [L,U,P,Q] = umfpack (A) ; | |
548 x = Q * (U \ (L \ (P * b))) ; | |
549 \end{verbatim} | |
550 } | |
551 | |
552 The above examples do not make use of the iterative refinement | |
553 that is built into | |
554 {\tt x = }{\tt umfpack (A,'}$\backslash${\tt ',b)} | |
555 however. | |
556 | |
557 MATLAB's {\tt [L,U,P] = lu(A)} returns a lower triangular {\tt L}, an upper | |
558 triangular {\tt U}, and a permutation matrix {\tt P} such that {\tt P*A} is | |
559 equal to {\tt L*U}. UMFPACK behaves differently. By default, it scales | |
560 the rows of {\tt A} and reorders the columns of {\tt A} prior to | |
561 factorization, so that {\tt L*U} is equal to {\tt P*(R}$\backslash${\tt A)*Q}, | |
562 where {\tt R} is a diagonal sparse matrix of scale factors for the rows | |
563 of {\tt A}. The scale factors {\tt R} are applied to {\tt A} via the MATLAB | |
564 expression {\tt R}$\backslash${\tt A} to avoid multiplying by | |
565 the reciprocal, which can be numerically inaccurate. | |
566 | |
567 There are more options; you can provide your own column pre-ordering (in which | |
568 case UMFPACK does not call COLAMD or AMD), you can modify other control settings | |
569 (similar to the {\tt spparms} in MATLAB), and you can get various statistics on | |
570 the analysis, factorization, and solution of the linear system. Type | |
571 {\tt umfpack\_details} and {\tt umfpack\_report} in MATLAB for more | |
572 information. Two demo M-files are provided. Just type {\tt umfpack\_simple} | |
573 and {\tt umfpack\_demo} to run them. | |
574 The output of these two programs should be about the same | |
575 as the files {\tt umfpack\_simple.m.out} and {\tt umfpack\_demo.m.out} | |
576 that are provided. | |
577 | |
578 Factorizing {\tt A'} (or {\tt A.'}) and using the transposed factors can | |
579 sometimes be faster than factorizing {\tt A}. It can also be preferable to | |
580 factorize {\tt A'} if {\tt A} is rectangular. UMFPACK pre-orders the columns | |
581 to maintain sparsity; the row ordering is not determined until the matrix | |
582 is factorized. Thus, if {\tt A} is {\tt m} by {\tt n} with rank {\tt m} | |
583 and {\tt m} $<$ {\tt n}, then {\tt umfpack} might not find a factor | |
584 {\tt U} with a zero-free diagonal. Unless the matrix ill-conditioned or | |
585 poorly scaled, factorizing {\tt A'} in this case will guarantee that both | |
586 factors will have zero-free diagonals. Here's how you can factorize {\tt A'} | |
587 and get the factors of {\tt A} instead: | |
588 | |
589 \begin{verbatim} | |
590 [l,u,p,q] = umfpack (A') ; | |
591 L = u' ; | |
592 U = l' ; | |
593 P = q ; | |
594 Q = p ; | |
595 clear l u p q | |
596 \end{verbatim} | |
597 | |
598 This is an alternative to {\tt [L,U,P,Q]=umfpack(A)}. | |
599 | |
600 A simple M-file ({\tt umfpack\_btf}) is provided that first permutes the matrix | |
601 to upper block triangular form, using MATLAB's {\tt dmperm} routine, and then | |
602 solves each block. The LU factors are not returned. Its usage is simple: | |
603 {\tt x = umfpack\_btf(A,b)}. Type {\tt help umfpack\_btf} for more options. | |
604 An estimate of the 1-norm of {\tt L*U-P*A*Q} can be computed in MATLAB | |
605 as {\tt lu\_normest(P*A*Q,L,U)}, using the {\tt lu\_normest.m} M-file | |
606 by Hager and Davis \cite{DavisHager99} that is included with the | |
607 UMFPACK distribution. With row scaling enabled, use | |
608 {\tt lu\_normest(P*(R}$\backslash${\tt A)*Q,L,U)} instead. | |
609 | |
610 One issue you may encounter is how UMFPACK allocates its memory when being used | |
611 in a mexFunction. One part of its working space is of variable size. The | |
612 symbolic analysis phase determines an upper bound on the size of this memory, | |
613 but not all of this memory will typically be used in the numerical | |
614 factorization. UMFPACK tries to allocate a decent amount of working space. | |
615 This is 70\% of the upper bound, by default, for the unsymmetric strategy. | |
616 For the symmetric strategy, the fraction of the upper bound is computed | |
617 automatically (assuming a best-case scenario with no numerical pivoting | |
618 required during numeric factorization). | |
619 If this initial allocation fails, it reduces its request | |
620 and uses less memory. If the space is not large enough during factorization, | |
621 it is increased via {\tt mxRealloc}. | |
622 | |
623 However, {\tt mxMalloc} and {\tt mxRealloc} abort the {\tt umfpack} mexFunction | |
624 if they fail, so this strategy does not work in MATLAB. The strategy works fine | |
625 when {\tt malloc} or the internal memory allocator {\tt utMalloc} are used | |
626 instead, since those routines return {\tt NULL} on failure, and do not terminate | |
627 the mexFunction. The {\tt umfpack} mexFunction can be compiled to use | |
628 {\tt utMalloc}, but this is an internal undocumented utility routine in MATLAB, | |
629 and thus using {\tt utMalloc} might not always be successful. | |
630 To use the documented {\tt mxMalloc} routine instead, compile the | |
631 mexFunction with the {\tt -DNUTIL} flag enabled. | |
632 | |
633 To compute the determinant with UMFPACK: | |
634 | |
635 \begin{verbatim} | |
636 d = umfpack (A, 'det') ; | |
637 [d e] = umfpack (A, 'det') ; | |
638 \end{verbatim} | |
639 | |
640 The first case is identical to MATLAB's {\tt det}. | |
641 The second case returns the determinant in the form | |
642 $d \times 10^e$, which avoids overflow if $e$ is large. | |
643 | |
644 %------------------------------------------------------------------------------- | |
645 \section{Using UMFPACK in a C program} | |
646 \label{C} | |
647 %------------------------------------------------------------------------------- | |
648 | |
649 The C-callable UMFPACK library consists of 32 user-callable routines and one | |
650 include file. All but three of the routines come in four versions, with | |
651 different sizes of integers and for real or complex floating-point numbers: | |
652 \begin{enumerate} | |
653 \item {\tt umfpack\_di\_*}: real double precision, {\tt int} integers. | |
654 \item {\tt umfpack\_dl\_*}: real double precision, {\tt long} integers. | |
655 \item {\tt umfpack\_zi\_*}: complex double precision, {\tt int} integers. | |
656 \item {\tt umfpack\_zl\_*}: complex double precision, {\tt long} integers. | |
657 \end{enumerate} | |
658 where {\tt *} denotes the specific name of one of the routines. | |
659 Routine names beginning with {\tt umf\_} are internal to the package, | |
660 and should not be called by the user. The include file {\tt umfpack.h} | |
661 must be included in any C program that uses UMFPACK. | |
662 The other three routines are the same for all four versions. | |
663 | |
664 In addition, the C-callable AMD library distributed with UMFPACK | |
665 includes 4 user-callable routines (in two versions with {\tt int} and | |
666 {\tt long} integers) and one include file. Refer to the AMD documentation | |
667 for more details. | |
668 | |
669 Use only one version for any one problem; do not attempt to use one version | |
670 to analyze the matrix and another version to factorize the matrix, for example. | |
671 | |
672 The notation {\tt umfpack\_di\_*} refers to all user-callable routines | |
673 for the real double precision and {\tt int} integer case. The notation | |
674 {\tt umfpack\_*\_numeric}, for example, refers all four versions | |
675 (real/complex, int/long) of a single operation | |
676 (in this case numeric factorization). | |
677 | |
678 %------------------------------------------------------------------------------- | |
679 \subsection{The size of an integer} | |
680 %------------------------------------------------------------------------------- | |
681 | |
682 The {\tt umfpack\_di\_*} and {\tt umfpack\_zi\_*} routines use {\tt int} integer | |
683 arguments; those starting with {\tt umfpack\_dl\_} or {\tt umfpack\_zl\_} | |
684 use {\tt long} integer arguments. If you compile UMFPACK in the standard | |
685 ILP32 mode (32-bit {\tt int}'s, {\tt long}'s, and pointers) then the versions | |
686 are essentially identical. You will be able to solve problems using up to 2GB | |
687 of memory. If you compile UMFPACK in the standard LP64 mode, the size of an | |
688 {\tt int} remains 32-bits, but the size of a {\tt long} and a pointer both get | |
689 promoted to 64-bits. In the LP64 mode, the {\tt umfpack\_dl\_*} | |
690 and {\tt umfpack\_zl\_*} routines can solve huge | |
691 problems (not limited to 2GB), limited of course by the amount of available | |
692 memory. The only drawback to the 64-bit mode is that not all BLAS libraries | |
693 support 64-bit integers. This limits the performance you will obtain. | |
694 Those that do support 64-bit integers are specific to particular | |
695 architectures, and are not portable. UMFPACK and AMD should be compiled | |
696 in the same mode. | |
697 If you compile UMFPACK and AMD in the LP64 mode, | |
698 be sure to add {\tt -DLP64} to the compilation command. See the examples in | |
699 {\tt Make.alpha}, {\tt Make.sgi}, and {\tt Make.solaris}. | |
700 | |
701 %------------------------------------------------------------------------------- | |
702 \subsection{Real and complex floating-point} | |
703 %------------------------------------------------------------------------------- | |
704 | |
705 The {\tt umfpack\_di\_*} and {\tt umfpack\_dl\_*} routines take (real) double | |
706 precision arguments, and return double precision arguments. In the | |
707 {\tt umfpack\_zi\_*} and {\tt umfpack\_zl\_*} routines, these same arguments | |
708 hold the real part of the matrices; and second double precision arrays hold | |
709 the imaginary part of the input and output matrices. Internally, complex | |
710 numbers are stored in arrays with their real and imaginary parts interleaved, | |
711 as required by the BLAS (``packed'' complex form). | |
712 | |
713 New to Version 4.4 is the option of providing input/output arguments | |
714 in packed complex form. | |
715 | |
716 %------------------------------------------------------------------------------- | |
717 \subsection{Primary routines, and a simple example} | |
718 %------------------------------------------------------------------------------- | |
719 | |
720 Five primary UMFPACK routines are required to factorize $\m{A}$ or | |
721 solve $\m{Ax}=\m{b}$. They are fully described in Section~\ref{Primary}: | |
722 | |
723 \begin{itemize} | |
724 \item {\tt umfpack\_*\_symbolic}: | |
725 | |
726 Pre-orders the columns of $\m{A}$ to reduce fill-in. | |
727 Returns an opaque {\tt Symbolic} object as a {\tt void *} | |
728 pointer. The object contains the symbolic analysis and is needed for the | |
729 numeric factorization. This routine requires only $O(|\m{A}|)$ space, | |
730 where $|\m{A}|$ is the number of nonzero entries in the matrix. It computes | |
731 upper bounds on the nonzeros in $\m{L}$ and $\m{U}$, the floating-point | |
732 operations required, and the memory usage of {\tt umfpack\_*\_numeric}. The | |
733 {\tt Symbolic} object is small; it contains just the column pre-ordering, | |
734 the supernodal column elimination tree, and information about each frontal | |
735 matrix. It is no larger than about $13n$ integers if $\m{A}$ is | |
736 $n$-by-$n$. | |
737 | |
738 \item {\tt umfpack\_*\_numeric}: | |
739 | |
740 Numerically scales and then factorizes a sparse matrix into | |
741 $\m{PAQ}$, $\m{PRAQ}$, or $\m{PR}^{-1}\m{AQ}$ into the product $\m{LU}$, | |
742 where | |
743 $\m{P}$ and $\m{Q}$ are permutation matrices, $\m{R}$ is a diagonal | |
744 matrix of scale factors, $\m{L}$ is lower triangular with unit diagonal, | |
745 and $\m{U}$ is upper triangular. Requires the | |
746 symbolic ordering and analysis computed by {\tt umfpack\_*\_symbolic} | |
747 or {\tt umfpack\_*\_qsymbolic}. | |
748 Returns an opaque {\tt Numeric} object as a | |
749 {\tt void *} pointer. The object contains the numerical factorization and | |
750 is used by {\tt umfpack\_*\_solve}. You can factorize a new matrix with a | |
751 different values (but identical pattern) as the matrix analyzed by | |
752 {\tt umfpack\_*\_symbolic} or {\tt umfpack\_*\_qsymbolic} by re-using the | |
753 {\tt Symbolic} object (this feature is available when using UMFPACK in a | |
754 C or Fortran program, but not in MATLAB). | |
755 The matrix | |
756 $\m{U}$ will have zeros on the diagonal if $\m{A}$ is singular; this | |
757 produces a warning, but the factorization is still valid. | |
758 | |
759 \item {\tt umfpack\_*\_solve}: | |
760 | |
761 Solves a sparse linear system ($\m{Ax}=\m{b}$, $\m{A}\tr\m{x}=\m{b}$, or | |
762 systems involving just $\m{L}$ or $\m{U}$), using the numeric factorization | |
763 computed by {\tt umfpack\_*\_numeric}. Iterative refinement with sparse | |
764 backward error \cite{ardd:89} is used by default. The matrix $\m{A}$ must | |
765 be square. If it is singular, then a divide-by-zero will occur, and your | |
766 solution with contain IEEE Inf's or NaN's in the appropriate places. | |
767 | |
768 \item {\tt umfpack\_*\_free\_symbolic}: | |
769 | |
770 Frees the {\tt Symbolic} object created by {\tt umfpack\_*\_symbolic} | |
771 or {\tt umfpack\_*\_qsymbolic}. | |
772 | |
773 \item {\tt umfpack\_*\_free\_numeric}: | |
774 | |
775 Frees the {\tt Numeric} object created by {\tt umfpack\_*\_numeric}. | |
776 | |
777 \end{itemize} | |
778 | |
779 Be careful not to free a {\tt Symbolic} object with | |
780 {\tt umfpack\_*\_free\_numeric}. Nor should you attempt to free a {\tt Numeric} | |
781 object with {\tt umfpack\_*\_free\_symbolic}. | |
782 Failure to free these objects will lead to memory leaks. | |
783 | |
784 The matrix $\m{A}$ is represented in compressed column form, which is | |
785 identical to the sparse matrix representation used by MATLAB. It consists | |
786 of three or four arrays, where the matrix is {\tt m}-by-{\tt n}, | |
787 with {\tt nz} entries. For the {\tt int} version of UMFPACK: | |
788 | |
789 {\footnotesize | |
790 \begin{verbatim} | |
791 int Ap [n+1] ; | |
792 int Ai [nz] ; | |
793 double Ax [nz] ; | |
794 \end{verbatim} | |
795 } | |
796 | |
797 For the {\tt long} version of UMFPACK: | |
798 | |
799 {\footnotesize | |
800 \begin{verbatim} | |
801 long Ap [n+1] ; | |
802 long Ai [nz] ; | |
803 double Ax [nz] ; | |
804 \end{verbatim} | |
805 } | |
806 | |
807 The complex versions add another array for the imaginary part: | |
808 | |
809 {\footnotesize | |
810 \begin{verbatim} | |
811 double Az [nz] ; | |
812 \end{verbatim} | |
813 } | |
814 | |
815 Alternatively, if {\tt Az} is {\tt NULL}, | |
816 the real part of the $k$th entry is located in | |
817 {\tt Ax[2*k]} and the imaginary part is located in | |
818 {\tt Ax[2*k+1]}, and the {\tt Ax} array is of size {\tt 2*nz}. | |
819 | |
820 All nonzeros are entries, but an entry may be numerically zero. The row indices | |
821 of entries in column {\tt j} are stored in | |
822 {\tt Ai[Ap[j]} \ldots {\tt Ap[j+1]-1]}. | |
823 The corresponding numerical values are stored in | |
824 {\tt Ax[Ap[j]} \ldots {\tt Ap[j+1]-1]}. | |
825 The imaginary part, for the complex versions, is stored in | |
826 {\tt Az[Ap[j]} \ldots {\tt Ap[j+1]-1]} | |
827 (see above for the packed complex case). | |
828 | |
829 No duplicate row indices may be present, and the row indices in any given | |
830 column must be sorted in ascending order. The first entry {\tt Ap[0]} must be | |
831 zero. The total number of entries in the matrix is thus {\tt nz = Ap[n]}. | |
832 Except for the fact that extra zero entries can be included, there is thus a | |
833 unique compressed column representation of any given matrix $\m{A}$. | |
834 For a more flexible method for providing an input matrix to UMFPACK, | |
835 see Section~\ref{triplet}. | |
836 | |
837 Here is a simple main program, {\tt umfpack\_simple.c}, that illustrates the | |
838 basic usage of UMFPACK. See Section~\ref{Synopsis} for a short description | |
839 of each calling sequence, including a list of options for the first | |
840 argument of {\tt umfpack\_di\_solve}. | |
841 | |
842 {\footnotesize | |
843 \begin{verbatim} | |
844 INCLUDE umfpack_simple.c via sed | |
845 \end{verbatim} | |
846 } | |
847 | |
848 The {\tt Ap}, {\tt Ai}, and {\tt Ax} arrays represent the matrix | |
849 \[ | |
850 \m{A} = \left[ | |
851 \begin{array}{rrrrr} | |
852 2 & 3 & 0 & 0 & 0 \\ | |
853 3 & 0 & 4 & 0 & 6 \\ | |
854 0 & -1 & -3 & 2 & 0 \\ | |
855 0 & 0 & 1 & 0 & 0 \\ | |
856 0 & 4 & 2 & 0 & 1 \\ | |
857 \end{array} | |
858 \right]. | |
859 \] | |
860 and the solution to $\m{Ax}=\m{b}$ is $\m{x} = [1 \, 2 \, 3 \, 4 \, 5]\tr$. | |
861 The program uses default control settings and does not return any statistics | |
862 about the ordering, factorization, or solution ({\tt Control} and {\tt Info} | |
863 are both {\tt (double *) NULL}). It also ignores the status value returned by | |
864 most user-callable UMFPACK routines. | |
865 | |
866 %------------------------------------------------------------------------------- | |
867 \subsection{A note about zero-sized arrays} | |
868 %------------------------------------------------------------------------------- | |
869 | |
870 UMFPACK uses many user-provided arrays of | |
871 size {\tt m} or {\tt n} (the order of the matrix), and of size | |
872 {\tt nz} (the number of nonzeros in a matrix). UMFPACK does not handle | |
873 zero-dimensioned arrays; | |
874 it returns an error code if {\tt m} or {\tt n} | |
875 are zero. However, {\tt nz} can be zero, since all singular matrices are | |
876 handled correctly. If you attempt to {\tt malloc} an array of size {\tt nz} | |
877 = 0, however, {\tt malloc} will return a null pointer which UMFPACK will report | |
878 as a missing argument. If you {\tt malloc} an array of | |
879 size {\tt nz} to pass to UMFPACK, make sure that you handle the {\tt nz} = 0 | |
880 case correctly (use a size equal to the maximum of {\tt nz} and 1, or use a | |
881 size of {\tt nz+1}). | |
882 | |
883 %------------------------------------------------------------------------------- | |
884 \subsection{Alternative routines} | |
885 %------------------------------------------------------------------------------- | |
886 | |
887 Three alternative routines are provided that modify UMFPACK's default | |
888 behavior. They are fully described in Section~\ref{Alternative}: | |
889 | |
890 \begin{itemize} | |
891 \item {\tt umfpack\_*\_defaults}: | |
892 | |
893 Sets the default control parameters in the {\tt Control} array. These can | |
894 then be modified as desired before passing the array to the other UMFPACK | |
895 routines. Control parameters are summarized in Section~\ref{control_param}. | |
896 Three particular parameters deserve special notice. | |
897 UMFPACK uses relaxed partial pivoting, where a candidate pivot entry is | |
898 numerically acceptable if its magnitude is greater than or equal to a | |
899 tolerance parameter times the magnitude of the largest entry in the same | |
900 column. The parameter {\tt Control [UMFPACK\_PIVOT\_TOLERANCE]} has a | |
901 default value of 0.1, and is used for the unsymmetric strategy. | |
902 For complex matrices, a cheap approximation of the absolute value is | |
903 used for the threshold pivoting test | |
904 ($|a| \approx |a_{\mbox{real}}|+|a_{\mbox{imag}}|$). | |
905 | |
906 For the symmetric strategy, a second tolerance is used for diagonal | |
907 entries: \newline {\tt Control [UMFPACK\_SYM\_PIVOT\_TOLERANCE]}, with | |
908 a default value of 0.001. The first parameter (with a default of 0.1) | |
909 is used for any off-diagonal candidate pivot entries. | |
910 | |
911 These two parameters may be too small for some matrices, particularly for | |
912 ill-conditioned or poorly scaled ones. With the default pivot tolerances | |
913 and default iterative refinement, | |
914 {\tt x = umfpack (A,'}$\backslash${\tt ',b)} | |
915 is just as accurate as (or more accurate) than | |
916 {\tt x = A}$\backslash${\tt b} | |
917 in MATLAB 6.1 for nearly all matrices. | |
918 | |
919 If {\tt Control [UMFPACK\_PIVOT\_TOLERANCE]} is zero, than any | |
920 nonzero entry is acceptable as a pivot (this is changed from Version 4.0, | |
921 which treated a value of 0.0 the same as 1.0). If the symmetric strategy is | |
922 used, and {\tt Control [UMFPACK\_SYM\_PIVOT\_TOLERANCE]} is zero, then any | |
923 nonzero entry on the diagonal is accepted as a pivot. Off-diagonal pivoting | |
924 will still occur if the diagonal entry is exactly zero. The | |
925 {\tt Control [UMFPACK\_SYM\_PIVOT\_TOLERANCE]} parameter is new to Version | |
926 4.1. It is similar in function to the pivot tolerance for left-looking | |
927 methods (the MATLAB {\tt THRESH} option in {\tt [L,U,P] = lu (A, THRESH)}, | |
928 and the pivot tolerance parameter in SuperLU). | |
929 | |
930 The parameter {\tt Control [UMFPACK\_STRATEGY]} can be used to bypass | |
931 UMFPACK's automatic strategy selection. The automatic strategy nearly | |
932 always selects the best method. When it does not, the different methods | |
933 nearly always give about the same quality of results. There may be | |
934 cases where the automatic strategy fails to pick a good strategy. Also, | |
935 you can save some computing time if you know the right strategy for your | |
936 set of matrix problems. | |
937 | |
938 \item {\tt umfpack\_*\_qsymbolic}: | |
939 | |
940 An alternative to {\tt umfpack\_*\_symbolic}. Allows the user to specify | |
941 his or her own column pre-ordering, rather than using the default COLAMD | |
942 or AMD pre-orderings. For example, a graph partitioning-based order | |
943 of $\m{A}\tr\m{A}$ would be suitable for UMFPACK's unsymmetric strategy. | |
944 A partitioning of $\m{A}+\m{A}\tr$ would be suitable for UMFPACK's | |
945 symmetric or 2-by-2 strategies. | |
946 | |
947 \item {\tt umfpack\_*\_wsolve}: | |
948 | |
949 An alternative to {\tt umfpack\_*\_solve} which does not dynamically | |
950 allocate any memory. Requires the user to pass two additional work | |
951 arrays. | |
952 | |
953 \end{itemize} | |
954 | |
955 %------------------------------------------------------------------------------- | |
956 \subsection{Matrix manipulation routines} | |
957 \label{triplet} | |
958 %------------------------------------------------------------------------------- | |
959 | |
960 The compressed column data structure is compact, and simplifies the UMFPACK | |
961 routines that operate on the sparse matrix $\m{A}$. However, it can be | |
962 inconvenient for the user to generate. Section~\ref{Manipulate} presents the | |
963 details of routines for manipulating sparse matrices in {\em triplet} form, | |
964 compressed column form, and compressed row form (the transpose of the | |
965 compressed column form). The triplet form of a matrix consists of three or | |
966 four arrays. For the {\tt int} version of UMFPACK: | |
967 | |
968 {\footnotesize | |
969 \begin{verbatim} | |
970 int Ti [nz] ; | |
971 int Tj [nz] ; | |
972 double Tx [nz] ; | |
973 \end{verbatim} | |
974 } | |
975 | |
976 For the {\tt long} version: | |
977 | |
978 {\footnotesize | |
979 \begin{verbatim} | |
980 long Ti [nz] ; | |
981 long Tj [nz] ; | |
982 double Tx [nz] ; | |
983 \end{verbatim} | |
984 } | |
985 | |
986 The complex versions use another array to hold the imaginary part: | |
987 | |
988 {\footnotesize | |
989 \begin{verbatim} | |
990 double Tz [nz] ; | |
991 \end{verbatim} | |
992 } | |
993 | |
994 The {\tt k}-th triplet is $(i,j,a_{ij})$, where $i =$ {\tt Ti[k]}, | |
995 $j =$ {\tt Tj[k]}, and $a_{ij} =$ {\tt Tx[k]}. For the complex versions, | |
996 {\tt Tx[k]} is the real part of $a_{ij}$ and | |
997 {\tt Tz[k]} is the imaginary part. | |
998 The triplets can be in any | |
999 order in the {\tt Ti}, {\tt Tj}, and {\tt Tx} arrays (and {\tt Tz} for | |
1000 the complex versions), and duplicate entries may | |
1001 exist. | |
1002 If {\tt Tz} is NULL, then the array {\tt Tx} becomes of size {\tt 2*nz}, | |
1003 and the real and imaginary parts of the | |
1004 {\tt k}-th triplet are located in {\tt Tx[2*k]} and {\tt Tx[2*k+1]}, | |
1005 respectively. | |
1006 Any duplicate entries are summed when the triplet form is converted to | |
1007 compressed column form. This is a convenient way to create a matrix arising in | |
1008 finite-element methods, for example. | |
1009 | |
1010 Four routines are provided for manipulating sparse matrices: | |
1011 | |
1012 \begin{itemize} | |
1013 \item {\tt umfpack\_*\_triplet\_to\_col}: | |
1014 | |
1015 Converts a triplet form of a matrix to compressed column form (ready for | |
1016 input to \newline | |
1017 {\tt umfpack\_*\_symbolic}, {\tt umfpack\_*\_qsymbolic}, and | |
1018 {\tt umfpack\_*\_numeric}). Identical to {\tt A = spconvert(i,j,x)} in | |
1019 MATLAB, except that zero entries are not removed, so that the pattern of | |
1020 entries in the compressed column form of $\m{A}$ are fully under user | |
1021 control. This is important if you want to factorize a new matrix with the | |
1022 {\tt Symbolic} object from a prior matrix with the same pattern as the new | |
1023 one. | |
1024 | |
1025 \item {\tt umfpack\_*\_col\_to\_triplet}: | |
1026 | |
1027 The opposite of {\tt umfpack\_*\_triplet\_to\_col}. Identical to | |
1028 {\tt [i,j,x] = find(A)} in MATLAB, except that numerically zero entries | |
1029 may be included. | |
1030 | |
1031 \item {\tt umfpack\_*\_transpose}: | |
1032 | |
1033 Transposes and optionally permutes a column form matrix \cite{Gustavson78}. | |
1034 Identical to | |
1035 {\tt R = A(P,Q)'} (linear algebraic transpose, using the complex conjugate) | |
1036 or {\tt R = A(P,Q).'} (the array transpose) | |
1037 in MATLAB, except for the presence of numerically zero entries. | |
1038 | |
1039 Factorizing $\m{A}\tr$ and then solving $\m{Ax}=\m{b}$ with the transposed | |
1040 factors can sometimes be much faster or much slower than factorizing | |
1041 $\m{A}$. It is highly dependent on your particular matrix. | |
1042 | |
1043 \item {\tt umfpack\_*\_scale}: | |
1044 | |
1045 Applies the row scale factors to a user-provided vector. This is not | |
1046 required to solve the sparse linear system $\m{Ax}=\m{b}$ or | |
1047 $\m{A}\tr\m{x}=\m{b}$, since {\tt umfpack\_*\_solve} applies the scale | |
1048 factors for those systems. | |
1049 | |
1050 \end{itemize} | |
1051 | |
1052 It is quite easy to add matrices in triplet form, subtract them, transpose | |
1053 them, permute them, construct a submatrix, and multiply a triplet-form matrix | |
1054 times a vector. UMFPACK does not provide code for these basic operations, | |
1055 however. Refer to the discussion of | |
1056 {\tt umfpack\_*\_triplet\_to\_col} in Section~\ref{Manipulate} for more details | |
1057 on how to compute these operations in your own code. | |
1058 The only primary matrix operation not provided by UMFPACK is the | |
1059 multiplication of two sparse matrices \cite{Gustavson78}. | |
1060 A future package under development (as of Jan. 2005), CHOLMOD, | |
1061 will provide many of these matrix operations, which | |
1062 can then be used in conjunction with UMFPACK. | |
1063 Watch my web page for details. | |
1064 | |
1065 %------------------------------------------------------------------------------- | |
1066 \subsection{Getting the contents of opaque objects} | |
1067 %------------------------------------------------------------------------------- | |
1068 | |
1069 There are cases where you may wish to do more with the LU factorization | |
1070 of a matrix than solve a linear system. The opaque {\tt Symbolic} and | |
1071 {\tt Numeric} objects are just that - opaque. You cannot do anything with them | |
1072 except to pass them back to subsequent calls to UMFPACK. Three routines | |
1073 are provided for copying their contents into user-provided arrays using simpler | |
1074 data structures. Four routines are provided for saving and loading the | |
1075 {\tt Numeric} and {\tt Symbolic} objects to/from binary files. | |
1076 An additional routine is provided that computes the determinant. | |
1077 They are fully described in Section~\ref{Get}: | |
1078 | |
1079 \begin{itemize} | |
1080 \item {\tt umfpack\_*\_get\_lunz}: | |
1081 | |
1082 Returns the number of nonzeros in $\m{L}$ and $\m{U}$. | |
1083 | |
1084 \item {\tt umfpack\_*\_get\_numeric}: | |
1085 | |
1086 Copies $\m{L}$, $\m{U}$, $\m{P}$, $\m{Q}$, and $\m{R}$ | |
1087 from the {\tt Numeric} object | |
1088 into arrays provided by the user. The matrix $\m{L}$ is returned in | |
1089 compressed row form (with the column indices in each row sorted in ascending | |
1090 order). The matrix $\m{U}$ is returned in compressed column form (with | |
1091 sorted columns). There are no explicit zero entries in $\m{L}$ and $\m{U}$, | |
1092 but such entries may exist in the {\tt Numeric} object. The permutations | |
1093 $\m{P}$ and $\m{Q}$ are represented as permutation vectors, where | |
1094 {\tt P[k] = i} means that row {\tt i} of the original matrix is the | |
1095 the {\tt k}-th row of $\m{PAQ}$, and where | |
1096 {\tt Q[k] = j} means that column {\tt j} of the original matrix is the | |
1097 {\tt k}-th column of $\m{PAQ}$. This is identical to how MATLAB uses | |
1098 permutation vectors (type {\tt help colamd} in MATLAB 6.1 or later). | |
1099 | |
1100 \item {\tt umfpack\_*\_get\_symbolic}: | |
1101 | |
1102 Copies the contents of the {\tt Symbolic} object (the initial row and column | |
1103 preordering, supernodal column elimination tree, and information | |
1104 about each frontal matrix) into arrays provided by the user. | |
1105 | |
1106 \item {\tt umfpack\_*\_get\_determinant}: | |
1107 | |
1108 Computes the determinant from the diagonal of $\m{U}$ and the permutations | |
1109 $\m{P}$ and $\m{Q}$. This is mostly of theoretical interest. | |
1110 It is not a good test to determine if your matrix is singular or not. | |
1111 | |
1112 \item {\tt umfpack\_*\_save\_numeric}: | |
1113 | |
1114 Saves a copy of the {\tt Numeric} object to a file, in binary format. | |
1115 | |
1116 \item {\tt umfpack\_*\_load\_numeric}: | |
1117 | |
1118 Creates a {\tt Numeric} object by loading it from a file created | |
1119 by {\tt umfpack\_*\_save\_numeric}. | |
1120 | |
1121 \item {\tt umfpack\_*\_save\_symbolic}: | |
1122 | |
1123 Saves a copy of the {\tt Symbolic} object to a file, in binary format. | |
1124 | |
1125 \item {\tt umfpack\_*\_load\_symbolic}: | |
1126 | |
1127 Creates a {\tt Symbolic} object by loading it from a file created | |
1128 by {\tt umfpack\_*\_save\_symbolic}. | |
1129 | |
1130 \end{itemize} | |
1131 | |
1132 UMFPACK itself does not make use of these routines; | |
1133 they are provided solely for returning the contents of the opaque | |
1134 {\tt Symbolic} and {\tt Numeric} objects to the user, and saving/loading | |
1135 them to/from a binary file. None of them do any computation, except for | |
1136 {\tt umfpack\_*\_get\_determinant}. | |
1137 | |
1138 %------------------------------------------------------------------------------- | |
1139 \subsection{Reporting routines} | |
1140 \label{Reporting} | |
1141 %------------------------------------------------------------------------------- | |
1142 | |
1143 None of the UMFPACK routines discussed so far prints anything, even when an | |
1144 error occurs. UMFPACK provides you with nine routines for printing the input | |
1145 and output arguments (including the {\tt Control} settings and {\tt Info} | |
1146 statistics) of UMFPACK routines discussed above. They are fully described in | |
1147 Section~\ref{Report}: | |
1148 | |
1149 \begin{itemize} | |
1150 \item {\tt umfpack\_*\_report\_status}: | |
1151 | |
1152 Prints the status (return value) of other {\tt umfpack\_*} routines. | |
1153 | |
1154 \item {\tt umfpack\_*\_report\_info}: | |
1155 | |
1156 Prints the statistics returned in the {\tt Info} array by | |
1157 {\tt umfpack\_*\_*symbolic}, | |
1158 {\tt umfpack\_*\_numeric}, and {\tt umfpack\_*\_*solve}. | |
1159 | |
1160 \item {\tt umfpack\_*\_report\_control}: | |
1161 | |
1162 Prints the {\tt Control} settings. | |
1163 | |
1164 \item {\tt umfpack\_*\_report\_matrix}: | |
1165 | |
1166 Verifies and prints a compressed column-form or compressed row-form sparse | |
1167 matrix. | |
1168 | |
1169 \item {\tt umfpack\_*\_report\_triplet}: | |
1170 | |
1171 Verifies and prints a matrix in triplet form. | |
1172 | |
1173 \item {\tt umfpack\_*\_report\_symbolic}: | |
1174 | |
1175 Verifies and prints a {\tt Symbolic} object. | |
1176 | |
1177 \item {\tt umfpack\_*\_report\_numeric}: | |
1178 | |
1179 Verifies and prints a {\tt Numeric} object. | |
1180 | |
1181 \item {\tt umfpack\_*\_report\_perm}: | |
1182 | |
1183 Verifies and prints a permutation vector. | |
1184 | |
1185 \item {\tt umfpack\_*\_report\_vector}: | |
1186 | |
1187 Verifies and prints a real or complex vector. | |
1188 | |
1189 \end{itemize} | |
1190 | |
1191 The {\tt umfpack\_*\_report\_*} routines behave slightly differently when | |
1192 compiled | |
1193 into the C-callable UMFPACK library than when used in the MATLAB mexFunction. | |
1194 MATLAB stores its sparse matrices using the same compressed column data | |
1195 structure discussed above, where row and column indices of an $m$-by-$n$ | |
1196 matrix are in the range 0 to $m-1$ or $n-1$, respectively\footnote{Complex | |
1197 matrices in MATLAB use the split array form, with one {\tt double} array | |
1198 for the real part and another array for the imaginary part. UMFPACK | |
1199 supports that format, as well as the packed complex format (new to Version 4.4).} | |
1200 It prints them as if they are in the range 1 to $m$ or $n$. | |
1201 The UMFPACK mexFunction behaves the same way. | |
1202 | |
1203 You can control how much the {\tt umfpack\_*\_report\_*} routines print by | |
1204 modifying the {\tt Control [UMFPACK\_PRL]} parameter. Its default value is 1. | |
1205 Here is a summary of how the routines use this print level parameter: | |
1206 | |
1207 \begin{itemize} | |
1208 \item {\tt umfpack\_*\_report\_status}: | |
1209 | |
1210 No output if the print level is 0 or less, even when an error occurs. | |
1211 If 1, then error messages are printed, and nothing is printed if | |
1212 the status is {\tt UMFPACK\_OK}. A warning message is printed if | |
1213 the matrix is singular. If 2 or more, then the status is always | |
1214 printed. If 4 or more, then the UMFPACK Copyright is printed. | |
1215 If 6 or more, then the UMFPACK License is printed. See also the first page | |
1216 of this User Guide for the Copyright and License. | |
1217 | |
1218 \item {\tt umfpack\_*\_report\_control}: | |
1219 | |
1220 No output if the print level is 1 or less. If 2 or more, all of | |
1221 {\tt Control} is printed. | |
1222 | |
1223 \item {\tt umfpack\_*\_report\_info}: | |
1224 | |
1225 No output if the print level is 1 or less. If 2 or more, all of | |
1226 {\tt Info} is printed. | |
1227 | |
1228 \item all other {\tt umfpack\_*\_report\_*} routines: | |
1229 | |
1230 If the print level is 2 or less, then these routines return silently without | |
1231 checking their inputs. If 3 or more, the inputs are fully verified and a | |
1232 short status summary is printed. If 4, then the first few entries of the | |
1233 input arguments are printed. If 5, then all of the input arguments are | |
1234 printed. | |
1235 | |
1236 \end{itemize} | |
1237 | |
1238 This print level parameter has an additional effect on the MATLAB mexFunction. | |
1239 If zero, then no warnings of singular or nearly singular matrices are | |
1240 printed (similar to the MATLAB commands | |
1241 {\tt warning off MATLAB:singularMatrix} and | |
1242 {\tt warning off MATLAB:nearlySingularMatrix}). | |
1243 | |
1244 %------------------------------------------------------------------------------- | |
1245 \subsection{Utility routines} | |
1246 %------------------------------------------------------------------------------- | |
1247 | |
1248 UMFPACK v4.0 included a routine that returns the time used by the process, | |
1249 {\tt umfpack\_timer}. The routine uses either {\tt getrusage} (which is | |
1250 preferred), or the ANSI C {\tt clock} routine if that is not available. | |
1251 It is fully described in Section~\ref{Utility}. It is still available in | |
1252 UMFPACK v4.1 and following, but not used internally. | |
1253 Two new timing routines are provided in UMFPACK Version 4.1 and following, | |
1254 {\tt umfpack\_tic} and {\tt umfpack\_toc}. They use POSIX-compliant | |
1255 {\tt sysconf} and {\tt times} routines to find both the CPU time | |
1256 and wallclock time. | |
1257 These three routines are the only user-callable | |
1258 routine that is identical in all four {\tt int}/{\tt long}, real/complex | |
1259 versions (there is no {\tt umfpack\_di\_timer} routine, for example). | |
1260 | |
1261 %------------------------------------------------------------------------------- | |
1262 \subsection{Control parameters} | |
1263 \label{control_param} | |
1264 %------------------------------------------------------------------------------- | |
1265 | |
1266 UMFPACK uses an optional {\tt double} array (currently of size 20) | |
1267 to modify its control parameters. If you pass {\tt (double *) NULL} instead | |
1268 of a {\tt Control} array, then defaults are used. These defaults provide | |
1269 nearly optimal performance (both speed, memory usage, and numerical accuracy) | |
1270 for a wide range of matrices from real applications. | |
1271 | |
1272 This array will almost certainly grow in size in future releases, | |
1273 so be sure to dimension your {\tt Control} array to be of size | |
1274 {\tt UMFPACK\_CONTROL}. That constant is currently defined to be 20, | |
1275 but may increase in future versions, since all 20 entries are in use. | |
1276 | |
1277 The contents of this array may be modified by the user | |
1278 (see {\tt umfpack\_*\_defaults}). Each | |
1279 user-callable routine includes a complete description of how each control | |
1280 setting modifies its behavior. Table~\ref{control} summarizes the entire | |
1281 contents of the {\tt Control} array. | |
1282 Note that ANSI C uses 0-based indexing, while MATLAB uses 1-based | |
1283 indexing. Thus, {\tt Control(1)} in MATLAB is the same as | |
1284 {\tt Control[0]} or {\tt Control[UMFPACK\_PRL]} in ANSI C. | |
1285 | |
1286 \begin{table} | |
1287 \caption{UMFPACK Control parameters} | |
1288 \label{control} | |
1289 {\footnotesize | |
1290 \begin{tabular}{llll} | |
1291 \hline | |
1292 | |
1293 MATLAB & ANSI C & default & description \\ | |
1294 \hline | |
1295 {\tt Control(1)} & {\tt Control[UMFPACK\_PRL]} & 1 & printing level \\ | |
1296 {\tt Control(2)} & {\tt Control[UMFPACK\_DENSE\_ROW]} & 0.2 & dense row parameter \\ | |
1297 {\tt Control(3)} & {\tt Control[UMFPACK\_DENSE\_COL]} & 0.2 & dense column parameter \\ | |
1298 {\tt Control(4)} & {\tt Control[UMFPACK\_PIVOT\_TOLERANCE]} & 0.1 & partial pivoting tolerance \\ | |
1299 {\tt Control(5)} & {\tt Control[UMFPACK\_BLOCK\_SIZE]} & 32 & BLAS block size \\ | |
1300 {\tt Control(6)} & {\tt Control[UMFPACK\_STRATEGY]} & 0 (auto) & select strategy \\ | |
1301 {\tt Control(7)} & {\tt Control[UMFPACK\_ALLOC\_INIT]} & 0.7 & initial memory allocation \\ | |
1302 {\tt Control(8)} & {\tt Control[UMFPACK\_IRSTEP]} & 2 & max iter. refinement steps \\ | |
1303 {\tt Control(13)} & {\tt Control[UMFPACK\_2BY2\_TOLERANCE]} & 0.01 & defines ``large'' entries \\ | |
1304 {\tt Control(14)} & {\tt Control[UMFPACK\_FIXQ]} & 0 (auto) & fix or modify Q \\ | |
1305 {\tt Control(15)} & {\tt Control[UMFPACK\_AMD\_DENSE]} & 10 & AMD dense row/column parameter \\ | |
1306 {\tt Control(16)} & {\tt Control[UMFPACK\_SYM\_PIVOT\_TOLERANCE]} & 0.001 & for diagonal entries \\ | |
1307 {\tt Control(17)} & {\tt Control[UMFPACK\_SCALE]} & 1 (sum) & row scaling (none, sum, or max) \\ | |
1308 {\tt Control(18)} & {\tt Control[UMFPACK\_FRONT\_ALLOC\_INIT]} & 0.5 & frontal matrix allocation ratio \\ | |
1309 {\tt Control(19)} & {\tt Control[UMFPACK\_DROPTOL]} & 0 & drop tolerance \\ | |
1310 {\tt Control(20)} & {\tt Control[UMFPACK\_AGGRESSIVE]} & 1 (yes) & aggressive absorption \\ | |
1311 & & & in AMD and COLAMD \\ | |
1312 % | |
1313 \hline | |
1314 \multicolumn{4}{l}{Can only be changed at compile time:} \\ | |
1315 {\tt Control(9)} & {\tt Control[UMFPACK\_COMPILED\_WITH\_BLAS]} & - & true if BLAS is used \\ | |
1316 {\tt Control(10)} & {\tt Control[UMFPACK\_COMPILED\_FOR\_MATLAB]} & - & true for mexFunction \\ | |
1317 {\tt Control(11)} & {\tt Control[UMFPACK\_COMPILED\_WITH\_GETRUSAGE]} & - & 1 if {\tt getrusage} used \\ | |
1318 {\tt Control(12)} & {\tt Control[UMFPACK\_COMPILED\_IN\_DEBUG\_MODE]} & - & true if debug mode enabled \\ | |
1319 \hline | |
1320 \end{tabular} | |
1321 } | |
1322 \end{table} | |
1323 | |
1324 Let $\alpha_r = ${\tt Control [UMFPACK\_DENSE\_ROW]}, | |
1325 $\alpha_c = ${\tt Control [UMFPACK\_DENSE\_COL]}, and | |
1326 $\alpha = ${\tt Control [UMFPACK\_AMD\_DENSE]}. | |
1327 Suppose the submatrix $\m{S}$, obtained after eliminating pivots with | |
1328 zero Markowitz cost, is $m$-by-$n$. | |
1329 Then a row is considered ``dense'' if it has more than | |
1330 $\max (16, 16 \alpha_r \sqrt{n})$ entries. | |
1331 A column is considered ``dense'' if it has more than | |
1332 $\max (16, 16 \alpha_c \sqrt{m})$ entries. | |
1333 These rows and columns are treated different in COLAMD and during numerical | |
1334 factorization. In COLAMD, dense columns are placed last in their natural | |
1335 order, and dense rows are ignored. During numerical factorization, dense | |
1336 rows are stored differently. | |
1337 In AMD, a row/column of the square matrix $\m{S}+\m{S}\tr$ is | |
1338 considered ``dense'' if it has more than $\max (16, \alpha \sqrt{n})$ entries. | |
1339 These rows/columns are placed last in AMD's output ordering. | |
1340 For more details on the control parameters, refer to the documentation of | |
1341 {\tt umfpack\_*\_qsymbolic}, {\tt umfpack\_*\_numeric}, {\tt umfpack\_*\_solve}, | |
1342 and the {\tt umfpack\_*\_report\_*} routines, | |
1343 in Sections~\ref{Primary}~through~\ref{Report}, below. | |
1344 | |
1345 %------------------------------------------------------------------------------- | |
1346 \subsection{Error codes} | |
1347 \label{error_codes} | |
1348 %------------------------------------------------------------------------------- | |
1349 | |
1350 Many of the routines return a {\tt status} value. | |
1351 This is also returned as the first entry in the {\tt Info} array, for | |
1352 those routines with that argument. The following list summarizes | |
1353 all of the error codes in UMFPACK. Each error code is given a | |
1354 specific name in the {\tt umfpack.h} include file, so you can use | |
1355 those constants instead of hard-coded values in your program. | |
1356 Future versions may report additional error codes. | |
1357 | |
1358 A value of zero means everything was successful, and the matrix is | |
1359 non-singular. A value greater than zero means the routine was successful, | |
1360 but a warning occurred. | |
1361 A negative value means the routine was not successful. | |
1362 In this case, no {\tt Symbolic} or {\tt Numeric} object was created. | |
1363 | |
1364 \begin{itemize} | |
1365 \item {\tt UMFPACK\_OK}, (0): UMFPACK was successful. | |
1366 | |
1367 \item {\tt UMFPACK\_WARNING\_singular\_matrix}, (1): Matrix is singular. | |
1368 There are exact zeros on the diagonal of $\m{U}$. | |
1369 | |
1370 \item {\tt UMFPACK\_WARNING\_determinant\_underflow}, (2): | |
1371 The determinant is nonzero, but smaller in magnitude than | |
1372 the smallest positive floating-point number. | |
1373 | |
1374 \item {\tt UMFPACK\_WARNING\_determinant\_overflow}, (3): | |
1375 The determinant is larger in magnitude than | |
1376 the largest positive floating-point number (IEEE Inf). | |
1377 | |
1378 \item {\tt UMFPACK\_ERROR\_out\_of\_memory}, (-1): Not enough memory. | |
1379 The ANSI C {\tt malloc} or {\tt realloc} routine failed. | |
1380 | |
1381 \item {\tt UMFPACK\_ERROR\_invalid\_Numeric\_object}, (-3): | |
1382 Routines that take a {\tt Numeric} object as input (or load it | |
1383 from a file) check this object and return this error code if it is | |
1384 invalid. This can be caused by a memory leak or overrun in your | |
1385 program, which can overwrite part of the Numeric object. It can also | |
1386 be caused by passing a Symbolic object by mistake, or some other pointer. | |
1387 If you try to factorize a matrix using one version of UMFPACK and | |
1388 then use the factors in another version, this error code will trigger as | |
1389 well. You cannot factor your matrix using | |
1390 version 4.0 and then solve with version 4.1, for example.\footnote{ | |
1391 Exception: v4.3, v4.3.1, and v4.4 use identical data structures | |
1392 for the {\tt Numeric} and {\tt Symbolic} objects}. | |
1393 You cannot use different precisions of the same version | |
1394 (real and complex, for example). | |
1395 It is possible for the {\tt Numeric} object to be corrupted by your | |
1396 program in subtle ways that are not detectable by this quick check. | |
1397 In this case, you may see an | |
1398 {\tt UMFPACK\_ERROR\_different\_pattern} error code, or even an | |
1399 {\tt UMFPACK\_ERROR\_internal\_error}. | |
1400 | |
1401 \item {\tt UMFPACK\_ERROR\_invalid\_Symbolic\_object}, (-4): | |
1402 Routines that take a {\tt Symbolic} object as input (or load it | |
1403 from a file) check this object and return this error code if it is | |
1404 invalid. The causes of this error are analogous to the | |
1405 {\tt UMFPACK\_ERROR\_invalid\_Numeric\_object} error described above. | |
1406 | |
1407 \item {\tt UMFPACK\_ERROR\_argument\_missing}, (-5): | |
1408 Some arguments of some are optional (you can pass a {\tt NULL} pointer | |
1409 instead of an array). This error code occurs if you pass a {\tt NULL} | |
1410 pointer when that argument is required to be present. | |
1411 | |
1412 \item {\tt UMFPACK\_ERROR\_n\_nonpositive} (-6): | |
1413 The number of rows or columns of the matrix must be greater than zero. | |
1414 | |
1415 \item {\tt UMFPACK\_ERROR\_invalid\_matrix} (-8): | |
1416 The matrix is invalid. For the column-oriented input, this error | |
1417 code will occur if the contents of {\tt Ap} and/or {\tt Ai} are invalid. | |
1418 | |
1419 {\tt Ap} is an integer array of size {\tt n\_col+1}. | |
1420 On input, it holds the | |
1421 ``pointers'' for the column form of the sparse matrix $\m{A}$. | |
1422 Column {\tt j} of | |
1423 the matrix A is held in {\tt Ai [(Ap [j])} \ldots {\tt (Ap [j+1]-1)]}. | |
1424 The first entry, {\tt Ap [0]}, must be zero, | |
1425 and {\tt Ap [j]} $\le$ {\tt Ap [j+1]} must hold for all | |
1426 {\tt j} in the range 0 to {\tt n\_col-1}. | |
1427 The value {\tt nz = Ap [n\_col]} is thus the | |
1428 total number of entries in the pattern of the matrix A. | |
1429 {\tt nz} must be greater than or equal to zero. | |
1430 | |
1431 The nonzero pattern (row indices) for column {\tt j} is stored in | |
1432 {\tt Ai [(Ap [j])} \ldots {\tt (Ap [j+1]-1)]}. The row indices in a given | |
1433 column {\tt j} | |
1434 must be in ascending order, and no duplicate row indices may be present. | |
1435 Row indices must be in the range 0 to {\tt n\_row-1} | |
1436 (the matrix is 0-based). | |
1437 | |
1438 Some routines take a triplet-form input, with arguments | |
1439 {\tt nz}, {\tt Ti}, and {\tt Tj}. This error code is returned | |
1440 if {\tt nz} is less than zero, | |
1441 if any row index in {\tt Ti} is outside the range 0 to {\tt n\_col-1}, or | |
1442 if any column index in {\tt Tj} is outside the range 0 to {\tt n\_row-1}. | |
1443 | |
1444 \item {\tt UMFPACK\_ERROR\_different\_pattern}, (-11): | |
1445 The most common cause of this error is that the pattern of the | |
1446 matrix has changed between the symbolic and numeric factorization. | |
1447 It can also occur if the {\tt Numeric} or {\tt Symbolic} object has | |
1448 been subtly corrupted by your program. | |
1449 | |
1450 \item {\tt UMFPACK\_ERROR\_invalid\_system}, (-13): | |
1451 The {\tt sys} argument provided to one of the solve routines is invalid. | |
1452 | |
1453 \item {\tt UMFPACK\_ERROR\_invalid\_permutation}, (-15): | |
1454 The permutation vector provided as input is invalid. | |
1455 | |
1456 \item {\tt UMFPACK\_ERROR\_file\_IO}, (-17): | |
1457 This error code is returned by the routines that save and load | |
1458 the {\tt Numeric} or {\tt Symbolic} objects to/from a file, if a | |
1459 file I/O error has occurred. The file may not exist or may not be readable, | |
1460 you may be trying to create a file that you don't have permission to create, | |
1461 or you may be out of disk space. The file you are trying to read might | |
1462 be the wrong one, and an earlier end-of-file condition would then result | |
1463 in this error. | |
1464 | |
1465 \item {\tt UMFPACK\_ERROR\_internal\_error}, (-911): | |
1466 An internal error has occurred, of unknown cause. This is either a bug | |
1467 in UMFPACK, or the result of a memory overrun from your program. | |
1468 Try modifying the file {\tt AMD/Source/amd\_internal.h} and adding | |
1469 the statement {\tt \#undef NDEBUG}, to enable the debugging mode. | |
1470 Recompile UMFPACK and rerun your program. | |
1471 A failed assertion might occur which | |
1472 can give you a better indication as to what is going wrong. Be aware that | |
1473 UMFPACK will be extraordinarily slow when running in debug mode. | |
1474 If all else fails, contact the developer (davis@cise.ufl.edu) with | |
1475 as many details as possible. | |
1476 | |
1477 \end{itemize} | |
1478 | |
1479 %------------------------------------------------------------------------------- | |
1480 \subsection{Larger examples} | |
1481 %------------------------------------------------------------------------------- | |
1482 | |
1483 Full examples of all user-callable UMFPACK routines | |
1484 are available in four stand-alone C main programs, {\tt umfpack\_*\_demo.c}. | |
1485 Another example is | |
1486 the UMFPACK mexFunction, {\tt umfpackmex.c}. The mexFunction accesses only the | |
1487 user-callable C interface to UMFPACK. The only features that it does not use | |
1488 are the support for the triplet form (MATLAB's sparse arrays are already in the | |
1489 compressed column form) and the ability to reuse the {\tt Symbolic} object to | |
1490 numerically factorize a matrix whose pattern is the same as a prior matrix | |
1491 analyzed by {\tt umfpack\_*\_symbolic} or {\tt umfpack\_*\_qsymbolic}. The | |
1492 latter is an important feature, but the mexFunction does not return its opaque | |
1493 {\tt Symbolic} and {\tt Numeric} objects to MATLAB. Instead, it gets the | |
1494 contents of these objects after extracting them via the {\tt umfpack\_*\_get\_*} | |
1495 routines, and returns them as MATLAB sparse matrices. | |
1496 | |
1497 The {\tt umf4.c} program for reading matrices in Harwell/Boeing format | |
1498 \cite{DuffGrimesLewis87b} is provided. It requires three Fortran 77 programs | |
1499 ({\tt readhb.f}, {\tt readhb\_nozeros.f}, and {\tt readhb\_size.f}) | |
1500 for reading in the sample Harwell/Boeing files in the {\tt UMFPACK/Demo/HB} | |
1501 directory. More matrices are available at | |
1502 http://www.cise.ufl.edu/research/sparse/matrices. | |
1503 Type {\tt make hb} in the {\tt UMFPACK/Demo/HB} directory | |
1504 to compile and run this demo. This program was used for the experimental | |
1505 results in \cite{Davis03}. | |
1506 | |
1507 %------------------------------------------------------------------------------- | |
1508 \section{Synopsis of C-callable routines} | |
1509 \label{Synopsis} | |
1510 %------------------------------------------------------------------------------- | |
1511 | |
1512 Each subsection, below, summarizes the input variables, output variables, return | |
1513 values, and calling sequences of the routines in one category. Variables with | |
1514 the same name as those already listed in a prior category have the same size | |
1515 and type. | |
1516 | |
1517 The real, {\tt long} integer {\tt umfpack\_dl\_*} routines are | |
1518 identical to the real, {\tt int} routines, except that {\tt \_di\_} is replaced | |
1519 with {\tt \_dl\_} in the name, and all {\tt int} arguments become {\tt long}. | |
1520 Similarly, the complex, {\tt long} integer {\tt umfpack\_zl\_*} routines are | |
1521 identical to the complex, {\tt int} routines, except that {\tt \_zi\_} is | |
1522 replaced | |
1523 with {\tt \_zl\_} in the name, and all {\tt int} arguments become {\tt long}. | |
1524 Only the real and complex {\tt int} versions are listed in the synopsis below. | |
1525 | |
1526 The matrix $\m{A}$ is {\tt m}-by-{\tt n} with {\tt nz} entries. | |
1527 | |
1528 The {\tt sys} argument of {\tt umfpack\_*\_solve} | |
1529 is an integer in the range 0 to 14 which defines which linear system is | |
1530 to be solved. | |
1531 \footnote{Integer values for {\tt sys} are used instead of strings (as in LINPACK | |
1532 and LAPACK) to avoid C-to-Fortran portability issues.} | |
1533 Valid values are listed in Table~\ref{sys}. | |
1534 The notation $\m{A}\he$ refers to the matrix transpose, which is the | |
1535 complex conjugate transpose for complex matrices ({\tt A'} in MATLAB). | |
1536 The array transpose is $\m{A}\tr$, which is {\tt A.'} in MATLAB. | |
1537 | |
1538 \begin{table} | |
1539 \begin{center} | |
1540 \caption{UMFPACK {\tt sys} parameter} | |
1541 \label{sys} | |
1542 {\footnotesize | |
1543 \begin{tabular}{ll|l} | |
1544 \hline | |
1545 Value & & system \\ | |
1546 \hline | |
1547 & & \\ | |
1548 {\tt UMFPACK\_A} & (0) & $\m{Ax}=\m{b}$ \\ | |
1549 {\tt UMFPACK\_At} & (1) & $\m{A}\he\m{x}=\m{b}$ \\ | |
1550 {\tt UMFPACK\_Aat} & (2) & $\m{A}\tr\m{x}=\m{b}$ \\ | |
1551 & & \\ | |
1552 \hline | |
1553 & & \\ | |
1554 {\tt UMFPACK\_Pt\_L} & (3) & $\m{P}\tr\m{Lx}=\m{b}$ \\ | |
1555 {\tt UMFPACK\_L} & (4) & $\m{Lx}=\m{b}$ \\ | |
1556 {\tt UMFPACK\_Lt\_P} & (5) & $\m{L}\he\m{Px}=\m{b}$ \\ | |
1557 {\tt UMFPACK\_Lat\_P} & (6) & $\m{L}\tr\m{Px}=\m{b}$ \\ | |
1558 {\tt UMFPACK\_Lt} & (7) & $\m{L}\he\m{x}=\m{b}$ \\ | |
1559 {\tt UMFPACK\_Lat} & (8) & $\m{L}\tr\m{x}=\m{b}$ \\ | |
1560 & & \\ | |
1561 \hline | |
1562 & & \\ | |
1563 {\tt UMFPACK\_U\_Qt} & (9) & $\m{UQ}\tr\m{x}=\m{b}$ \\ | |
1564 {\tt UMFPACK\_U} & (10) & $\m{Ux}=\m{b}$ \\ | |
1565 {\tt UMFPACK\_Q\_Ut} & (11) & $\m{QU}\he\m{x}=\m{b}$ \\ | |
1566 {\tt UMFPACK\_Q\_Uat} & (12) & $\m{QU}\tr\m{x}=\m{b}$ \\ | |
1567 {\tt UMFPACK\_Ut} & (13) & $\m{U}\he\m{x}=\m{b}$ \\ | |
1568 {\tt UMFPACK\_Uat} & (14) & $\m{U}\tr\m{x}=\m{b}$ \\ | |
1569 & & \\ | |
1570 \hline | |
1571 \end{tabular} | |
1572 } | |
1573 \end{center} | |
1574 \end{table} | |
1575 | |
1576 %------------------------------------------------------------------------------- | |
1577 \subsection{Primary routines: real/{\tt int}} | |
1578 %------------------------------------------------------------------------------- | |
1579 | |
1580 {\footnotesize | |
1581 \begin{verbatim} | |
1582 #include "umfpack.h" | |
1583 int status, sys, n, m, nz, Ap [n+1], Ai [nz] ; | |
1584 double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO], Ax [nz], X [n], B [n] ; | |
1585 void *Symbolic, *Numeric ; | |
1586 | |
1587 status = umfpack_di_symbolic (m, n, Ap, Ai, Ax, &Symbolic, Control, Info) ; | |
1588 status = umfpack_di_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ; | |
1589 status = umfpack_di_solve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info) ; | |
1590 umfpack_di_free_symbolic (&Symbolic) ; | |
1591 umfpack_di_free_numeric (&Numeric) ; | |
1592 \end{verbatim} | |
1593 } | |
1594 | |
1595 %------------------------------------------------------------------------------- | |
1596 \subsection{Alternative routines: real/{\tt int}} | |
1597 %------------------------------------------------------------------------------- | |
1598 | |
1599 {\footnotesize | |
1600 \begin{verbatim} | |
1601 int Qinit [n], Wi [n] ; | |
1602 double W [5*n] ; | |
1603 | |
1604 umfpack_di_defaults (Control) ; | |
1605 status = umfpack_di_qsymbolic (m, n, Ap, Ai, Ax, Qinit, &Symbolic, Control, Info) ; | |
1606 status = umfpack_di_wsolve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info, Wi, W) ; | |
1607 \end{verbatim} | |
1608 } | |
1609 | |
1610 %------------------------------------------------------------------------------- | |
1611 \subsection{Matrix manipulation routines: real/{\tt int}} | |
1612 %------------------------------------------------------------------------------- | |
1613 | |
1614 {\footnotesize | |
1615 \begin{verbatim} | |
1616 int Ti [nz], Tj [nz], P [m], Q [n], Rp [m+1], Ri [nz], Map [nz] ; | |
1617 double Tx [nz], Rx [nz], Y [m], Z [m] ; | |
1618 | |
1619 status = umfpack_di_col_to_triplet (n, Ap, Tj) ; | |
1620 status = umfpack_di_triplet_to_col (m, n, nz, Ti, Tj, Tx, Ap, Ai, Ax, Map) ; | |
1621 status = umfpack_di_transpose (m, n, Ap, Ai, Ax, P, Q, Rp, Ri, Rx) ; | |
1622 status = umfpack_di_scale (Y, Z, Numeric) ; | |
1623 \end{verbatim} | |
1624 } | |
1625 | |
1626 %------------------------------------------------------------------------------- | |
1627 \subsection{Getting the contents of opaque objects: real/{\tt int}} | |
1628 %------------------------------------------------------------------------------- | |
1629 | |
1630 The {\tt filename} string should be large enough to hold the name of a file. | |
1631 | |
1632 {\footnotesize | |
1633 \begin{verbatim} | |
1634 int lnz, unz, Lp [m+1], Lj [lnz], Up [n+1], Ui [unz], do_recip ; | |
1635 double Lx [lnz], Ux [unz], D [min (m,n)], Rs [m], Mx [1], Ex [1] ; | |
1636 int nfr, nchains, P1 [m], Q1 [n], Front_npivcol [n+1], Front_parent [n+1], Front_1strow [n+1], | |
1637 Front_leftmostdesc [n+1], Chain_start [n+1], Chain_maxrows [n+1], Chain_maxcols [n+1] ; | |
1638 char filename [100] ; | |
1639 | |
1640 status = umfpack_di_get_lunz (&lnz, &unz, &m, &n, &nz_udiag, Numeric) ; | |
1641 status = umfpack_di_get_numeric (Lp, Lj, Lx, Up, Ui, Ux, P, Q, D, | |
1642 &do_recip, Rs, Numeric) ; | |
1643 status = umfpack_di_get_symbolic (&m, &n, &n1, &nz, &nfr, &nchains, P1, Q1, | |
1644 Front_npivcol, Front_parent, Front_1strow, Front_leftmostdesc, | |
1645 Chain_start, Chain_maxrows, Chain_maxcols, Symbolic) ; | |
1646 status = umfpack_di_load_numeric (&Numeric, filename) ; | |
1647 status = umfpack_di_save_numeric (Numeric, filename) ; | |
1648 status = umfpack_di_load_symbolic (&Symbolic, filename) ; | |
1649 status = umfpack_di_save_symbolic (Symbolic, filename) ; | |
1650 status = umfapck_di_get_determinant (Mx, Ex, Numeric, Info) ; | |
1651 \end{verbatim} | |
1652 } | |
1653 | |
1654 %------------------------------------------------------------------------------- | |
1655 \subsection{Reporting routines: real/{\tt int}} | |
1656 %------------------------------------------------------------------------------- | |
1657 | |
1658 {\footnotesize | |
1659 \begin{verbatim} | |
1660 | |
1661 umfpack_di_report_status (Control, status) ; | |
1662 umfpack_di_report_control (Control) ; | |
1663 umfpack_di_report_info (Control, Info) ; | |
1664 status = umfpack_di_report_matrix (m, n, Ap, Ai, Ax, 1, Control) ; | |
1665 status = umfpack_di_report_matrix (m, n, Rp, Ri, Rx, 0, Control) ; | |
1666 status = umfpack_di_report_numeric (Numeric, Control) ; | |
1667 status = umfpack_di_report_perm (m, P, Control) ; | |
1668 status = umfpack_di_report_perm (n, Q, Control) ; | |
1669 status = umfpack_di_report_symbolic (Symbolic, Control) ; | |
1670 status = umfpack_di_report_triplet (m, n, nz, Ti, Tj, Tx, Control) ; | |
1671 status = umfpack_di_report_vector (n, X, Control) ; | |
1672 \end{verbatim} | |
1673 } | |
1674 | |
1675 | |
1676 | |
1677 | |
1678 | |
1679 | |
1680 %------------------------------------------------------------------------------- | |
1681 \subsection{Primary routines: complex/{\tt int}} | |
1682 %------------------------------------------------------------------------------- | |
1683 | |
1684 {\footnotesize | |
1685 \begin{verbatim} | |
1686 double Az [nz], Xx [n], Xz [n], Bx [n], Bz [n] ; | |
1687 | |
1688 status = umfpack_zi_symbolic (m, n, Ap, Ai, Ax, Az, &Symbolic, Control, Info) ; | |
1689 status = umfpack_zi_numeric (Ap, Ai, Ax, Az, Symbolic, &Numeric, Control, Info) ; | |
1690 status = umfpack_zi_solve (sys, Ap, Ai, Ax, Az, Xx, Xz, Bx, Bz, Numeric, Control, Info) ; | |
1691 umfpack_zi_free_symbolic (&Symbolic) ; | |
1692 umfpack_zi_free_numeric (&Numeric) ; | |
1693 \end{verbatim} | |
1694 } | |
1695 | |
1696 The arrays {\tt Ax}, {\tt Bx}, and {\tt Xx} double in size if | |
1697 any imaginary argument ({\tt Az}, {\tt Xz}, or {\tt Bz}) is {\tt NULL}. | |
1698 | |
1699 %------------------------------------------------------------------------------- | |
1700 \subsection{Alternative routines: complex/{\tt int}} | |
1701 %------------------------------------------------------------------------------- | |
1702 | |
1703 {\footnotesize | |
1704 \begin{verbatim} | |
1705 double Wz [10*n] ; | |
1706 | |
1707 umfpack_zi_defaults (Control) ; | |
1708 status = umfpack_zi_qsymbolic (m, n, Ap, Ai, Ax, Az, Qinit, &Symbolic, Control, Info) ; | |
1709 status = umfpack_zi_wsolve (sys, Ap, Ai, Ax, Az, Xx, Xz, Bx, Bz, Numeric, Control, Info, Wi, Wz) ; | |
1710 \end{verbatim} | |
1711 } | |
1712 | |
1713 %------------------------------------------------------------------------------- | |
1714 \subsection{Matrix manipulation routines: complex/{\tt int}} | |
1715 %------------------------------------------------------------------------------- | |
1716 | |
1717 {\footnotesize | |
1718 \begin{verbatim} | |
1719 double Tz [nz], Rz [nz], Yx [m], Yz [m], Zx [m], Zz [m] ; | |
1720 | |
1721 status = umfpack_zi_col_to_triplet (n, Ap, Tj) ; | |
1722 status = umfpack_zi_triplet_to_col (m, n, nz, Ti, Tj, Tx, Tz, Ap, Ai, Ax, Az, Map) ; | |
1723 status = umfpack_zi_transpose (m, n, Ap, Ai, Ax, Az, P, Q, Rp, Ri, Rx, Rz, 1) ; | |
1724 status = umfpack_zi_transpose (m, n, Ap, Ai, Ax, Az, P, Q, Rp, Ri, Rx, Rz, 0) ; | |
1725 status = umfpack_zi_scale (Yx, Yz, Zx, Zz, Numeric) ; | |
1726 \end{verbatim} | |
1727 } | |
1728 | |
1729 The arrays {\tt Tx}, {\tt Rx}, {\tt Yx}, and {\tt Zx} double in size if | |
1730 any imaginary argument ({\tt Tz}, {\tt Rz}, {\tt Yz}, or {\tt Zz}) is {\tt NULL}. | |
1731 | |
1732 %------------------------------------------------------------------------------- | |
1733 \subsection{Getting the contents of opaque objects: complex/{\tt int}} | |
1734 %------------------------------------------------------------------------------- | |
1735 | |
1736 {\footnotesize | |
1737 \begin{verbatim} | |
1738 double Lz [lnz], Uz [unz], Dx [min (m,n)], Dz [min (m,n)], Mz [1] ; | |
1739 | |
1740 status = umfpack_zi_get_lunz (&lnz, &unz, &m, &n, &nz_udiag, Numeric) ; | |
1741 status = umfpack_zi_get_numeric (Lp, Lj, Lx, Lz, Up, Ui, Ux, Uz, P, Q, Dx, Dz, | |
1742 &do_recip, Rs, Numeric) ; | |
1743 status = umfpack_zi_get_symbolic (&m, &n, &n1, &nz, &nfr, &nchains, P1, Q1, | |
1744 Front_npivcol, Front_parent, Front_1strow, Front_leftmostdesc, | |
1745 Chain_start, Chain_maxrows, Chain_maxcols, Symbolic) ; | |
1746 status = umfpack_zi_load_numeric (&Numeric, filename) ; | |
1747 status = umfpack_zi_save_numeric (Numeric, filename) ; | |
1748 status = umfpack_zi_load_symbolic (&Symbolic, filename) ; | |
1749 status = umfpack_zi_save_symbolic (Symbolic, filename) ; | |
1750 status = umfapck_zi_get_determinant (Mx, Mz, Ex, Numeric, Info) ; | |
1751 \end{verbatim} | |
1752 } | |
1753 | |
1754 The arrays {\tt Lx}, {\tt Ux}, {\tt Dx}, and {\tt Mx} double in size if | |
1755 any imaginary argument ({\tt Lz}, {\tt Uz}, {\tt Dz}, or {\tt Mz}) is {\tt NULL}. | |
1756 | |
1757 %------------------------------------------------------------------------------- | |
1758 \subsection{Reporting routines: complex/{\tt int}} | |
1759 %------------------------------------------------------------------------------- | |
1760 | |
1761 {\footnotesize | |
1762 \begin{verbatim} | |
1763 | |
1764 umfpack_zi_report_status (Control, status) ; | |
1765 umfpack_zi_report_control (Control) ; | |
1766 umfpack_zi_report_info (Control, Info) ; | |
1767 status = umfpack_zi_report_matrix (m, n, Ap, Ai, Ax, Az, 1, Control) ; | |
1768 status = umfpack_zi_report_matrix (m, n, Rp, Ri, Rx, Rz, 0, Control) ; | |
1769 status = umfpack_zi_report_numeric (Numeric, Control) ; | |
1770 status = umfpack_zi_report_perm (m, P, Control) ; | |
1771 status = umfpack_zi_report_perm (n, Q, Control) ; | |
1772 status = umfpack_zi_report_symbolic (Symbolic, Control) ; | |
1773 status = umfpack_zi_report_triplet (m, n, nz, Ti, Tj, Tx, Tz, Control) ; | |
1774 status = umfpack_zi_report_vector (n, Xx, Xz, Control) ; | |
1775 \end{verbatim} | |
1776 } | |
1777 | |
1778 The arrays {\tt Ax}, {\tt Rx}, {\tt Tx}, and {\tt Xx} double in size if | |
1779 any imaginary argument ({\tt Az}, {\tt Rz}, {\tt Tz}, or {\tt Xz}) is {\tt NULL}. | |
1780 | |
1781 | |
1782 | |
1783 | |
1784 %------------------------------------------------------------------------------- | |
1785 \subsection{Utility routines} | |
1786 %------------------------------------------------------------------------------- | |
1787 | |
1788 These routines are the same in all four versions of UMFPACK. | |
1789 | |
1790 {\footnotesize | |
1791 \begin{verbatim} | |
1792 double t, s [2] ; | |
1793 | |
1794 t = umfpack_timer ( ) ; | |
1795 umfpack_tic (s) ; | |
1796 umfpack_toc (s) ; | |
1797 | |
1798 \end{verbatim} | |
1799 } | |
1800 | |
1801 %------------------------------------------------------------------------------- | |
1802 \subsection{AMD ordering routines} | |
1803 %------------------------------------------------------------------------------- | |
1804 | |
1805 UMFPACK makes use of the AMD ordering package for its symmetric ordering | |
1806 strategy. You may also use these four user-callable routines in your own C | |
1807 programs. You need to include the {\tt amd.h} file only if you make direct | |
1808 calls to the AMD routines themselves. The {\tt int} versions are summarized | |
1809 below; {\tt long} versions are also available. Refer to the AMD User Guide | |
1810 for more information, or to the file {\tt amd.h} which documents these routines. | |
1811 | |
1812 {\footnotesize | |
1813 \begin{verbatim} | |
1814 #include "amd.h" | |
1815 double amd_control [AMD_CONTROL], amd_info [AMD_INFO] ; | |
1816 | |
1817 amd_defaults (amd_control) ; | |
1818 status = amd_order (n, Ap, Ai, P, amd_control, amd_info) ; | |
1819 amd_control (amd_control) ; | |
1820 amd_info (amd_info) ; | |
1821 | |
1822 \end{verbatim} | |
1823 } | |
1824 | |
1825 %------------------------------------------------------------------------------- | |
1826 \section{Using UMFPACK in a Fortran program} | |
1827 %------------------------------------------------------------------------------- | |
1828 | |
1829 UMFPACK includes a basic Fortran 77 interface to some of the C-callable | |
1830 UMFPACK routines. | |
1831 Since interfacing C and Fortran programs is not portable, this interface might | |
1832 not work with all C and Fortran compilers. Refer to Section~\ref{Install} for | |
1833 more details. The following Fortran routines are provided. | |
1834 The list includes the C-callable routines that the Fortran interface | |
1835 routine calls. Refer to the corresponding C routines in Section~\ref{C} for | |
1836 more details on what the Fortran routine does. | |
1837 | |
1838 \begin{itemize} | |
1839 \item {\tt umf4def}: sets the default control parameters | |
1840 ({\tt umfpack\_di\_defaults}). | |
1841 | |
1842 \item {\tt umf4sym}: pre-ordering and symbolic factorization | |
1843 ({\tt umfpack\_di\_symbolic}). | |
1844 | |
1845 \item {\tt umf4num}: numeric factorization | |
1846 ({\tt umfpack\_di\_numeric}). | |
1847 | |
1848 \item {\tt umf4solr}: solve a linear system with iterative refinement | |
1849 ({\tt umfpack\_di\_solve}). | |
1850 | |
1851 \item {\tt umf4sol}: solve a linear system without iterative refinement | |
1852 ({\tt umfpack\_di\_solve}). Sets {\tt Control [UMFPACK\_IRSTEP]} | |
1853 to zero, and does not require the matrix $\m{A}$. | |
1854 | |
1855 \item {\tt umf4scal}: scales a vector using UMFPACK's scale factors | |
1856 ({\tt umfpack\_di\_scale}). | |
1857 | |
1858 \item {\tt umf4fnum}: free the {\tt Numeric} object | |
1859 ({\tt umfpack\_di\_free\_numeric}). | |
1860 | |
1861 \item {\tt umf4fsym}: free the {\tt Symbolic} object | |
1862 ({\tt umfpack\_di\_free\_symbolic}). | |
1863 | |
1864 \item {\tt umf4pcon}: prints the control parameters | |
1865 ({\tt umfpack\_di\_report\_control}). | |
1866 | |
1867 \item {\tt umf4pinf}: print statistics | |
1868 ({\tt umfpack\_di\_report\_info}). | |
1869 | |
1870 \item {\tt umf4snum}: save the {\tt Numeric} object to a file | |
1871 ({\tt umfpack\_di\_save\_numeric}). | |
1872 | |
1873 \item {\tt umf4ssym}: save the {\tt Symbolic} object to a file | |
1874 ({\tt umfpack\_di\_save\_symbolic}). | |
1875 | |
1876 \item {\tt umf4lnum}: load the {\tt Numeric} object from a file | |
1877 ({\tt umfpack\_di\_load\_numeric}). | |
1878 | |
1879 \item {\tt umf4lsym}: load the {\tt Symbolic} object from a file | |
1880 ({\tt umfpack\_di\_load\_symbolic}). | |
1881 \end{itemize} | |
1882 | |
1883 The matrix $\m{A}$ is passed to UMFPACK in compressed column form, with 0-based | |
1884 indices. In Fortran, for an {\tt m}-by-{\tt n} matrix $\m{A}$ with {\tt nz} | |
1885 entries, the row indices of the first column (column 1) are in | |
1886 {\tt Ai (Ap(1)+1} \ldots {\tt Ap(2))}, with values in | |
1887 {\tt Ax (Ap(1)+1} \ldots {\tt Ap(2))}. The last column (column {\tt n}) is in | |
1888 {\tt Ai (Ap(n)+1} \ldots {\tt Ap(n+1))} and | |
1889 {\tt Ax (Ap(n)+1} \ldots {\tt Ap(n+1))}. | |
1890 The number of entries in the matrix is thus {\tt nz = Ap (n+1)}. | |
1891 The row indices in {\tt Ai} are in the range 0 to {\tt m}-1. They must be | |
1892 sorted, with no duplicate entries allowed. None of the UMFPACK routines | |
1893 modify the input matrix $\m{A}$. | |
1894 The following definitions apply for the Fortran routines: | |
1895 | |
1896 {\footnotesize | |
1897 \begin{verbatim} | |
1898 integer m, n, Ap (n+1), Ai (nz), symbolic, numeric, filenum, status | |
1899 double precision Ax (nz), control (20), info (90), x (n), b (n) | |
1900 \end{verbatim} | |
1901 } | |
1902 | |
1903 UMFPACK's status is returned in either a {\tt status} argument, or in | |
1904 {\tt info (1)}. | |
1905 It is zero if UMFPACK was successful, 1 if the matrix is singular (this is a | |
1906 warning, not an error), and negative if an error occurred. | |
1907 Section~\ref{error_codes} summarizes the possible values of {\tt status} | |
1908 and {\tt info (1)}. | |
1909 See Table~\ref{sys} for a list of the values of the {\tt sys} argument. | |
1910 See Table~\ref{control} for a list of the control parameters (the | |
1911 Fortran usage is the same as the MATLAB usage for this array). | |
1912 | |
1913 For the {\tt Numeric} and {\tt Symbolic} handles, it is probably safe to | |
1914 assume that a Fortran {\tt integer} is sufficient to store a C pointer. If | |
1915 that does not work, try defining {\tt numeric} and {\tt symbolic} in your | |
1916 Fortran program as integer arrays of size 2. You will need to define them | |
1917 as {\tt integer*8} if you compile UMFPACK in the 64-bit mode. | |
1918 | |
1919 To avoid passing strings between C and Fortran in the load/save routines, | |
1920 a file number is passed instead, and the C interface constructs a file name | |
1921 (if {\tt filenum} is 42, the {\tt Numeric} file name is {\tt n42.umf}, and | |
1922 the {\tt Symbolic} file name is {\tt s42.umf}). | |
1923 | |
1924 The following is a summary of the calling sequence of each Fortran | |
1925 interface routine. An example of their use is in the {\tt Demo/umf4hb.f} | |
1926 file. That routine also includes an example of how to convert a 1-based | |
1927 sparse matrix into 0-based form. For more details on the arguments of each | |
1928 routine, refer to the arguments of the same name in the corresponding | |
1929 C-callable routine, in Sections~\ref{Primary}~through~\ref{Utility}. | |
1930 The only exception is the {\tt control} argument of {\tt umf4sol}, | |
1931 which sets {\tt control (8)} to zero to disable iterative refinement. | |
1932 Note that the solve routines do not overwrite {\tt b} with the solution, | |
1933 but return their solution in a different array, {\tt x}. | |
1934 | |
1935 {\footnotesize | |
1936 \begin{verbatim} | |
1937 call umf4def (control) | |
1938 call umf4sym (m, n, Ap, Ai, Ax, symbolic, control, info) | |
1939 call umf4num (Ap, Ai, Ax, symbolic, numeric, control, info) | |
1940 call umf4solr (sys, Ap, Ai, Ax, x, b, numeric, control, info) | |
1941 call umf4sol (sys, x, b, numeric, control, info) | |
1942 call umf4scal (x, b, numeric, status) | |
1943 call umf4fnum (numeric) | |
1944 call umf4fsym (symbolic) | |
1945 call umf4pcon (control) | |
1946 call umf4pinf (control) | |
1947 call umf4snum (numeric, filenum, status) | |
1948 call umf4ssym (symbolic, filenum, status) | |
1949 call umf4lnum (numeric, filenum, status) | |
1950 call umf4lsym (symbolic, filenum, status) | |
1951 \end{verbatim} | |
1952 } | |
1953 | |
1954 Access to the complex routines in UMFPACK is provided by the interface | |
1955 routines in {\tt umf4\_f77zwrapper.c}. The following is a synopsis | |
1956 of each routine. All the arguments are the same as the real versions, | |
1957 except {\tt Az}, {\tt xz}, and {\tt bz} are the imaginary parts of | |
1958 the matrix, solution, and right-hand-side, respectively. The | |
1959 {\tt Ax}, {\tt x}, and {\tt b} are the real parts. | |
1960 | |
1961 {\footnotesize | |
1962 \begin{verbatim} | |
1963 call umf4zdef (control) | |
1964 call umf4zsym (m, n, Ap, Ai, Ax, Az, symbolic, control, info) | |
1965 call umf4znum (Ap, Ai, Ax, Az, symbolic, numeric, control, info) | |
1966 call umf4zsolr (sys, Ap, Ai, Ax, Az, x, xz, b, bz, numeric, control, info) | |
1967 call umf4zsol (sys, x, xz, b, bz, numeric, control, info) | |
1968 call umf4zscal (x, xz, b, bz, numeric, status) | |
1969 call umf4zfnum (numeric) | |
1970 call umf4zfsym (symbolic) | |
1971 call umf4zpcon (control) | |
1972 call umf4zpinf (control) | |
1973 call umf4zsnum (numeric, filenum, status) | |
1974 call umf4zssym (symbolic, filenum, status) | |
1975 call umf4zlnum (numeric, filenum, status) | |
1976 call umf4zlsym (symbolic, filenum, status) | |
1977 \end{verbatim} | |
1978 } | |
1979 | |
1980 The Fortran interface does not support the packed complex case. | |
1981 | |
1982 %------------------------------------------------------------------------------- | |
1983 \section{Installation} | |
1984 \label{Install} | |
1985 %------------------------------------------------------------------------------- | |
1986 | |
1987 %------------------------------------------------------------------------------- | |
1988 \subsection{Installing the C library} | |
1989 %------------------------------------------------------------------------------- | |
1990 | |
1991 The following discussion assumes you have the {\tt make} program, either in | |
1992 Unix, or in Windows with Cygwin\footnote{www.cygwin.com}. | |
1993 You can skip this section and go to next one if all you want to use is | |
1994 the UMFPACK and AMD mexFunctions in MATLAB. | |
1995 | |
1996 You will need to install both UMFPACK v4.4 and AMD v1.1 (or AMD v1.0) to use UMFPACK. | |
1997 The {\tt UMFPACK} and {\tt AMD} subdirectories must be placed side-by-side | |
1998 within the same directory. AMD is a stand-alone package that | |
1999 is required by UMFPACK. UMFPACK can be compiled without the | |
2000 BLAS \cite{DaydeDuff99,ACM679a,ATLAS,GotoVandeGeijn02}, | |
2001 but your performance will be much less than what it should be. | |
2002 | |
2003 System-dependent configurations are in the {\tt AMD/Make} | |
2004 and {\tt UMFPACK/Make} directories (the \newline | |
2005 {\tt UMFPACK/Make} directory is actually | |
2006 just a symbolic link to {\tt AMD/Make}\footnote{Windows might not extract | |
2007 the symbolic link {\tt UMFPACK/Make} correctly. If it doesn't, simply | |
2008 create the {\tt UMFPACK/Make} folder by copying it from {\tt AMD/Make}.}). | |
2009 You can edit the {\tt Make.include} | |
2010 files in either of those directories to customize the compilation. The default | |
2011 settings will work on most systems, except that UMFPACK will be compiled so | |
2012 that it does not use the BLAS. Sample configuration files are provided | |
2013 for Linux, Sun Solaris, SGI IRIX, IBM AIX, and the DEC/Compaq Alpha. | |
2014 | |
2015 To compile and install both packages, | |
2016 go to the {\tt UMFPACK} directory and type {\tt make}. This will compile the | |
2017 libraries ({\tt AMD/Lib/libamd.a} and {\tt UMFPACK/Lib/libumfpack.a}). | |
2018 A demo of the AMD ordering routine will be compiled and tested in | |
2019 the {\tt AMD/Demo} directory, and five demo programs will then be | |
2020 compiled and tested in the {\tt UMFPACK/Demo} directory. | |
2021 The outputs of these demo programs will then be compared with output | |
2022 files in the distribution. Expect to see a few differences, such as | |
2023 residual norms, compile-time control settings, and perhaps memory usage | |
2024 differences. The AMD and UMFPACK mexFunctions for | |
2025 use in MATLAB will also be compiled. If you do not have MATLAB 6.0 or | |
2026 later, type {\tt make lib} instead. | |
2027 | |
2028 If you have the GNU version of {\tt make}, the {\tt Source/GNUmakefile} and | |
2029 {\tt MATLAB/GNUmakefile} files are used. These are much more concise than | |
2030 what the ``old'' version of {\tt make} can handle. If you do not have | |
2031 GNU {\tt make}, the {\tt Source/Makefile} and {\tt MATLAB/Makefile} files | |
2032 are used instead. Each UMFPACK source file is compiled into four | |
2033 versions ({\tt double} / complex, and {\tt int} / {\tt long}). A proper | |
2034 old-style {\tt Makefile} is cumbersome in this case, so these two | |
2035 {\tt Makefile}'s have been constructed by brute force. They ignore | |
2036 dependencies, and simply compile everything. I highly recommend using GNU | |
2037 {\tt make} if you wish to modify UMFPACK. | |
2038 | |
2039 If you compile UMFPACK and AMD and then later change the {\tt Make.include} | |
2040 file or your system-specific configuration file such as {\tt Make.linux}, | |
2041 then you should type {\tt make purge} and then {\tt make} to recompile. | |
2042 | |
2043 Here are the various parameters that you can control in your | |
2044 {\tt Make.include} file: | |
2045 | |
2046 \begin{itemize} | |
2047 \item {\tt CC = } your C compiler, such as {\tt cc}. | |
2048 \item {\tt RANLIB = } your system's {\tt ranlib} program, if needed. | |
2049 \item {\tt CFLAGS = } optimization flags, such as {\tt -O}. | |
2050 Add {\tt -DLP64} if you are compiling in 64-bit mode | |
2051 (32 bit {\tt int}'s, 64 bit {\tt long}'s, and 64 bit pointers). | |
2052 \item {\tt CONFIG = } configuration settings for the BLAS, memory allocation | |
2053 routines, and timing routines. | |
2054 \item {\tt LIB = } your libraries, such as {\tt -lm} or {\tt -lblas}. | |
2055 \item {\tt RM =} the command to delete a file. | |
2056 \item {\tt MV =} the command to rename a file. | |
2057 \item {\tt MEX =} the command to compile a MATLAB mexFunction. | |
2058 If you are using MATLAB 5, you need to add {\tt -DNBLAS} and | |
2059 {\tt -DNUTIL} to this command. An example is provided in | |
2060 the {\tt Make/Make.include} file. | |
2061 \item {\tt F77 =} the command to compile a Fortran program (optional). | |
2062 \item {\tt F77FLAGS =} the Fortran compiler flags (optional). | |
2063 \item {\tt F77LIB =} the Fortran libraries (optional). | |
2064 \end{itemize} | |
2065 | |
2066 The {\tt CONFIG} string can include combinations of the following; | |
2067 most deal with how the BLAS are called: | |
2068 \begin{itemize} | |
2069 \item {\tt -DNBLAS} if you do not have any BLAS at all. | |
2070 \item {\tt -DCBLAS} if you have the C-BLAS \cite{ATLAS}. | |
2071 \item {\tt -DNSUNPERF} if you are on Solaris but do not have the Sun | |
2072 Performance Library (for the BLAS). | |
2073 \item {\tt -DNSCSL} if you on SGI IRIX but do not have the SCSL BLAS library. | |
2074 \item {\tt -DLONGBLAS} if your BLAS can take {\tt long} integer input | |
2075 arguments. If not defined, then the {\tt umfpack\_*l\_*} versions of | |
2076 UMFPACK that use {\tt long} integers do not call the BLAS. | |
2077 This flag is set internally when using the Sun Performance BLAS | |
2078 or SGI's SCSL BLAS (both have 64-bit versions of the BLAS). | |
2079 \item Options for controlling how C calls the Fortran BLAS: | |
2080 {\tt -DBLAS\_BY\_VALUE}, {\tt -DBLAS\_NO\_UNDERSCORE}, | |
2081 and {\tt -DBLAS\_CHAR\_ARG}. These are set automatically for Windows, | |
2082 Sun Solaris, SGI Irix, Red Hat Linux, Compaq Alpha, and | |
2083 AIX (the IBM RS 6000). They are ignored if you are using | |
2084 the C-BLAS interface to the BLAS. | |
2085 \item {\tt -DGETRUSAGE} if you have the {\tt getrusage} function. | |
2086 \item {\tt -DNUTIL} if you wish to compile the MATLAB-callable | |
2087 UMFPACK mexFunction with the {\tt mxMalloc}, {\tt mxRealloc} | |
2088 and {\tt mxFree} routines, instead of the undocumented (but | |
2089 superior) {\tt utMalloc}, {\tt utRealloc}, and {\tt utFree} | |
2090 routines. The default is to use the {\tt ut*} routines on | |
2091 Unix, and the {\tt mx*} routines on Windows. | |
2092 \item {\tt -DNPOSIX} if you do not have the POSIX-compliant | |
2093 {\tt sysconf} and {\tt times} routines used by | |
2094 {\tt umfpack\_tic} and {\tt umfpack\_toc}. | |
2095 \item {\tt -DNRECIPROCAL} controls a trade-off between speed and accuracy. | |
2096 If defined (or if the pivot value itself is less than $10^{-12}$), | |
2097 then the pivot column is divided by the pivot value during numeric | |
2098 factorization. Otherwise, it is multiplied by the reciprocal of the | |
2099 pivot, which is faster but can be less accurate. The default is | |
2100 to multiply by the reciprocal unless the pivot value is small. | |
2101 This option also modifies how the rows of the matrix $\m{A}$ are | |
2102 scaled. If {\tt -DNRECIPROCAL} is defined (or if any scale factor is | |
2103 less than $10^{-12}$), entries in the rows of $\m{A}$ are divided | |
2104 by the scale factors. Otherwise, they are multiplied by the reciprocal. | |
2105 When compiling the complex routines with the GNU {\tt gcc} compiler, the | |
2106 pivot column is always divided by the pivot entry, because of a | |
2107 numerical accuracy issue encountered with {\tt gcc} version 3.2 with a | |
2108 few complex matrices on a Pentium 4M (running Linux). You can still | |
2109 use {\tt -DNRECIPROCAL} to control how the scale factors | |
2110 for the rows of $\m{A}$ are applied. | |
2111 \item {\tt -DNO\_DIVIDE\_BY\_ZERO} controls how UMFPACK treats zeros | |
2112 on the diagonal of $\m{U}$, for a singular matrix $\m{A}$. | |
2113 If defined, then no division by | |
2114 zero is performed (a zero entry on the diagonal of $\m{U}$ is | |
2115 treated as if it were equal to one). By default, | |
2116 UMFPACK will divide by zero. | |
2117 \item {\tt -DNO\_TIMER} controls whether or not timing routines | |
2118 are to be called. If defined, no timers are used. | |
2119 Timers are included by default. | |
2120 \end{itemize} | |
2121 | |
2122 If a Fortran BLAS package is used you may see compiler warnings. The BLAS | |
2123 routines | |
2124 {\tt dgemm}, {\tt dgemv}, {\tt dger}, {\tt dtrsm}, {\tt dtrsv}, {\tt dscal} | |
2125 and their corresponding complex versions are used. | |
2126 Header files are not provided for the Fortran | |
2127 BLAS. You may safely ignore all of these warnings. | |
2128 | |
2129 I highly recommend the recent BLAS by Goto and van de Geijn | |
2130 \cite{GotoVandeGeijn02}. Using this BLAS increased the performance | |
2131 of UMFPACK by up to 50\% on a Dell Latitude C840 laptop (2GHz Pentium 4M, | |
2132 512K L2 cache, 1GB main memory). The peak performance of | |
2133 {\tt umfpack\_di\_numeric} with Goto and van de Geijn's BLAS is 1.6 Gflops | |
2134 on this computer. In MATLAB, the peak performance of UMFPACK on | |
2135 a dense matrix (stored in sparse format) is 900 Mflops, as compared to | |
2136 1 Gflop for {\tt x = A}$\backslash${\tt b} | |
2137 when {\tt A} is stored as a regular full matrix. | |
2138 | |
2139 When you compile your program that uses the C-callable UMFPACK library, | |
2140 you need to link your program with both libraries | |
2141 ({\tt UMFPACK/Lib/libumfpack.a} and {\tt AMD/Lib/libamd.a}) | |
2142 and you need to tell your compiler to look in the | |
2143 directories {\tt UMFPACK/Include} and {\tt AMD/Include} for include | |
2144 files. See {\tt UMFPACK/Demo/Makefile} for an example. | |
2145 You do not need to directly include any AMD include files in your | |
2146 program, unless you directly call AMD routines. You only need the | |
2147 \begin{verbatim} | |
2148 #include "umfpack.h" | |
2149 \end{verbatim} | |
2150 statement, as described in Section~\ref{Synopsis}. | |
2151 | |
2152 If you would like to compile both 32-bit and 64-bit versions of the libraries, | |
2153 you will need to do it in two steps. Modify your {\tt Make/Make.<arch>} | |
2154 file, and select the 32-bit option. Type {\tt make} in the {\tt UMFPACK} | |
2155 directory, which creates the {\tt UMFPACK/Lib/libumfpack.a} and | |
2156 {\tt AMD/Lib/libamd.a} libraries. Rename those two files. Edit your | |
2157 {\tt Make/Make.<arch>} and select the 64-bit option. Type {\tt make purge}, | |
2158 and then {\tt make}, and you will create the 64-bit libraries. | |
2159 You can use the same {\tt umfpack.h} include file for both 32-bit and | |
2160 64-bit versions. Simply link your program with the appropriate 32-bit | |
2161 or 64-bit compiled version of the UMFPACK and AMD libraries. | |
2162 | |
2163 Type {\tt make hb} in the {\tt UMFPACK/Demo/HB} directory | |
2164 to compile and run a C program that reads in and factorizes | |
2165 Harwell/Boeing matrices. Note that this uses a stand-alone Fortran | |
2166 program to read in the Fortran-formatted Harwell/Boeing matrices and | |
2167 write them to a file which can be read by a C program. | |
2168 | |
2169 The {\tt umf\_multicompile.c} file has been added to assist in the | |
2170 compilation of UMFPACK in Microsoft Visual Studio, for Windows. | |
2171 | |
2172 %------------------------------------------------------------------------------- | |
2173 \subsection{Installing the MATLAB interface} | |
2174 %------------------------------------------------------------------------------- | |
2175 | |
2176 If all you want to do is use the UMFPACK mexFunction in MATLAB, you can skip | |
2177 the use of the {\tt make} command described above. Simply type | |
2178 {\tt umfpack\_make} in MATLAB while in the {\tt UMFPACK/MATLAB} directory. | |
2179 You can also type {\tt amd\_make} in the {\tt AMD/MATLAB} directory | |
2180 to compile the stand-alone AMD mexFunction (this is not required to | |
2181 compile the UMFPACK mexFunction). This works on any computer with MATLAB, | |
2182 including Windows. | |
2183 | |
2184 You will be prompted to select several configuration options, including | |
2185 whether or not to use the BLAS. | |
2186 MATLAB 5.3 (or earlier) does not include the BLAS, so you either have to | |
2187 compile UMFPACK without the BLAS (UMFPACK will be slow), or modify your | |
2188 {\tt <matlab>/bin/mexopts.sh} by adding your BLAS library | |
2189 to the {\tt CLIBS} string, | |
2190 where {\tt <matlab>} is the directory in which MATLAB is installed. | |
2191 | |
2192 If you are using Windows and the {\tt lcc} compiler bundled with | |
2193 MATLAB 6.1, then you may need to copy the | |
2194 {\tt UMFPACK}$\backslash${\tt MATLAB}$\backslash${\tt lcc\_lib}$\backslash${\tt libmwlapack.lib} | |
2195 file into the | |
2196 {\tt <matlab>}$\backslash${\tt extern}$\backslash${\tt lib}$\backslash${\tt win32}$\backslash${\tt lcc}$\backslash$ | |
2197 directory. | |
2198 Next, type {\tt mex -setup} | |
2199 at the MATLAB prompt, and ask MATLAB to select the {\tt lcc} compiler. | |
2200 MATLAB 6.1 has built-in BLAS, but in that version of MATLAB the BLAS | |
2201 cannot be accessed by a mexFunction compiled by {\tt lcc} without first copying | |
2202 this file to the location listed above. | |
2203 If you have MATLAB 6.5 or later, you can probably skip this step. | |
2204 | |
2205 %------------------------------------------------------------------------------- | |
2206 \subsection{Installing the Fortran interface} | |
2207 %------------------------------------------------------------------------------- | |
2208 | |
2209 Once the 32-bit C-callable UMFPACK library is compiled, you can also compile | |
2210 the Fortran interface, by typing {\tt make fortran}. This will create | |
2211 the {\tt umf4hb} program, test it, and compare the output with the | |
2212 file {\tt umf4hb.out} in the distribution. | |
2213 If you compiled UMFPACK in 64-bit mode, you need to use {\tt make fortran64} | |
2214 instead, which compiles the {\tt umf4hb64} program and compares its output | |
2215 with the file {\tt umf4hb64.out}. | |
2216 Refer to the comments in the {\tt Demo/umf4\_f77wrapper.c} file | |
2217 for more details. | |
2218 | |
2219 This interface is {\bf highly} non-portable, since it depends | |
2220 on how C and Fortran are interfaced. | |
2221 Because of this issue, the interface is included in the {\tt Demo} directory, | |
2222 and not as a primary part of the UMFPACK library. The interface routines are | |
2223 not included in the compiled {\tt UMFPACK/Lib/libumfpack.a} library, but left | |
2224 as stand-alone compiled files ({\tt umf4\_f77wrapper.o} and | |
2225 {\tt umf4\_f77wrapper64.o} in the {\tt Demo} directory). | |
2226 You may need to modify the interface routines in the file | |
2227 {\tt umf4\_f77wrapper.c} if you are using compilers for which this interface | |
2228 has not been tested. | |
2229 | |
2230 %------------------------------------------------------------------------------- | |
2231 \subsection{Known Issues} | |
2232 %------------------------------------------------------------------------------- | |
2233 | |
2234 The Microsoft C or C++ compilers on a Pentium badly break the IEEE 754 standard, | |
2235 and do not treat NaN's properly. According to IEEE 754, the expression | |
2236 {\tt (x != x)} is supposed to be true if and only if {\tt x} is NaN. For | |
2237 non-compliant compilers in Windows that expression is always false, and another | |
2238 test must be used: {\tt (x < x)} is true if and only if {\tt x} | |
2239 is NaN. For compliant compilers, {\tt (x < x)} is always false, for any | |
2240 value of {\tt x} (including NaN). | |
2241 To cover both cases, UMFPACK when running under Microsoft Windows | |
2242 defines the following macro, which is true if and only if {\tt x} is NaN, | |
2243 regardless of whether your compiler is compliant or not: | |
2244 | |
2245 \begin{verbatim} | |
2246 #define SCALAR_IS_NAN(x) (((x) != (x)) || ((x) < (x))) | |
2247 \end{verbatim} | |
2248 | |
2249 If your compiler breaks this test, then UMFPACK will fail catastrophically | |
2250 if it encounters a NaN. You will not just see NaN's in your output; UMFPACK | |
2251 will probably crash with a segmentation fault. In that case, you might try to | |
2252 see if the common (but non-ANSI C) routine {\tt isnan} is available, and modify | |
2253 the macro {\tt SCALAR\_IS\_NAN} in {\tt umf\_version.h} accordingly. The | |
2254 simpler (and IEEE 754-compliant) test {\tt (x != x)} is always true with Linux | |
2255 on a PC, and on every Unix compiler I have tested. | |
2256 | |
2257 Some compilers will complain about the Fortran BLAS being defined implicitly. | |
2258 C prototypes for the BLAS are not used, except the C-BLAS. Some compilers | |
2259 will complain about unrecognized {\tt \#pragma}'s. You may safely ignore | |
2260 all of these warnings. | |
2261 | |
2262 %------------------------------------------------------------------------------- | |
2263 \section{Future work} | |
2264 \label{Future} | |
2265 %------------------------------------------------------------------------------- | |
2266 | |
2267 Here are a few features that are not in UMFPACK Version 4.4, in no particular | |
2268 order. They may appear in a future release of UMFPACK. If you are interested, | |
2269 let me know and I could consider including them: | |
2270 | |
2271 \begin{enumerate} | |
2272 | |
2273 \item Future versions may have different default {\tt Control} parameters. | |
2274 Future versions may return more statistics in the {\tt Info} array, and | |
2275 they may use more entries in the {\tt Control} array. | |
2276 These two arrays will probably become larger, since there are very few | |
2277 unused entries. If they change in size, the constants | |
2278 {\tt UMFPACK\_CONTROL} and {\tt UMFPACK\_INFO} defined in {\tt umfpack.h} | |
2279 will be changed to reflect their new size. Your C program should use | |
2280 these constants when declaring the size of these two arrays. Do not | |
2281 define them as {\tt Control [20]} and {\tt Info [90]}. | |
2282 | |
2283 \item Forward/back solvers for the conventional row or column-form data | |
2284 structure for $\m{L}$ and $\m{U}$ (the output of | |
2285 {\tt umfpack\_*\_di\_get\_numeric}). This would enable a separate | |
2286 solver that could be used to write a MATLAB mexFunction | |
2287 {\tt x = lu\_refine (A, b, L, U, P, Q, R)} that gives MATLAB access | |
2288 to the iterative refinement algorithm with sparse backward error | |
2289 analysis. It would also be easier to handle sparse right-hand-sides | |
2290 in this data structure, and end up with good asymptotic run-time | |
2291 in this case | |
2292 (particularly for $\m{Lx}=\m{b}$; see \cite{GilbertPeierls88}). | |
2293 | |
2294 \item Complex absolute value computations could be | |
2295 based on FDLIBM (see \newline | |
2296 http://www.netlib.org/fdlibm), | |
2297 using the {\tt hypot(x,y)} routine. | |
2298 | |
2299 \item When using iterative refinement, the residual $\m{Ax}-\m{b}$ could be | |
2300 returned by {\tt umfpack\_solve}. | |
2301 | |
2302 \item The solve routines could handle multiple right-hand sides, and sparse | |
2303 right-hand sides. See {\tt umfpack\_solve} for the MATLAB version | |
2304 of this feature. | |
2305 | |
2306 \item An option to redirect the error and diagnostic output. | |
2307 | |
2308 \item Permutation to block-triangular-form \cite{Duff78a} for the C-callable | |
2309 interface. There are two routines in the ACM Collected | |
2310 Algorithms (529 and 575) \cite{Duff81b,Duff78b} | |
2311 that could be translated from Fortran | |
2312 to C and included in UMFPACK. This would result in better performance | |
2313 for matrices from circuit simulation and | |
2314 chemical process engineering. See {\tt umfpack\_btf.m} for the MATLAB | |
2315 version of this feature. An upcoming package (KLU) will include | |
2316 this feature. | |
2317 | |
2318 \item The ability to use user-provided {\tt malloc}, {\tt free}, and | |
2319 {\tt realloc} memory allocation routines. Note that UMFPACK makes very | |
2320 few calls to these routines. You can do this at compile-time by | |
2321 modifying the definitions of {\tt ALLOCATE}, {\tt FREE}, and | |
2322 {\tt REALLOCATE} in the file {\tt umf\_internal.h}. Be sure to document | |
2323 your changes carefully when you change UMFPACK source code. | |
2324 | |
2325 \item The ability to use user-provided work arrays, so that {\tt malloc}, | |
2326 {\tt free}, and {\tt realloc} realloc are not called. The | |
2327 {\tt umfpack\_*\_wsolve} routine is one example. | |
2328 | |
2329 \item A method that takes time proportional to the number of nonzeros in | |
2330 $\m{A}$ to compute the symbolic factorization \cite{GilbertNgPeyton94}. | |
2331 This would improve the performance of the symmetric and 2-by-2 strategies, | |
2332 and the unsymmetric strategy when dense rows are present. | |
2333 The current method takes | |
2334 time proportional to the number of nonzeros in the upper bound of $\m{U}$. | |
2335 The method used in UMFPACK exploits super-columns, however, so this | |
2336 bound is rarely reached. | |
2337 | |
2338 \item Other basic sparse matrix operations, such as sparse matrix | |
2339 multiplication, could be included. | |
2340 | |
2341 \item A more complete Fortran interface. | |
2342 | |
2343 \item A C++ interface. | |
2344 | |
2345 \item A parallel version using MPI. This would require a large amount | |
2346 of effort. | |
2347 | |
2348 \end{enumerate} | |
2349 | |
2350 | |
2351 %------------------------------------------------------------------------------- | |
2352 \newpage | |
2353 \section{The primary UMFPACK routines} | |
2354 \label{Primary} | |
2355 %------------------------------------------------------------------------------- | |
2356 | |
2357 The include files are the same for all four versions of | |
2358 UMFPACK. The generic integer type is {\tt Int}, which is an {\tt int} or | |
2359 {\tt long}, depending on which version of UMFPACK you are using. | |
2360 | |
2361 \subsection{umfpack\_*\_symbolic} | |
2362 | |
2363 {\footnotesize | |
2364 \begin{verbatim} | |
2365 INCLUDE umfpack_symbolic.h via sed | |
2366 \end{verbatim} | |
2367 } | |
2368 | |
2369 \newpage | |
2370 \subsection{umfpack\_*\_numeric} | |
2371 | |
2372 {\footnotesize | |
2373 \begin{verbatim} | |
2374 INCLUDE umfpack_numeric.h via sed | |
2375 \end{verbatim} | |
2376 } | |
2377 | |
2378 \newpage | |
2379 \subsection{umfpack\_*\_solve} | |
2380 | |
2381 {\footnotesize | |
2382 \begin{verbatim} | |
2383 INCLUDE umfpack_solve.h via sed | |
2384 \end{verbatim} | |
2385 } | |
2386 | |
2387 \newpage | |
2388 \subsection{umfpack\_*\_free\_symbolic} | |
2389 | |
2390 {\footnotesize | |
2391 \begin{verbatim} | |
2392 INCLUDE umfpack_free_symbolic.h via sed | |
2393 \end{verbatim} | |
2394 } | |
2395 | |
2396 \newpage | |
2397 \subsection{umfpack\_*\_free\_numeric} | |
2398 | |
2399 {\footnotesize | |
2400 \begin{verbatim} | |
2401 INCLUDE umfpack_free_numeric.h via sed | |
2402 \end{verbatim} | |
2403 } | |
2404 | |
2405 %------------------------------------------------------------------------------- | |
2406 \newpage | |
2407 \section{Alternative routines} | |
2408 \label{Alternative} | |
2409 %------------------------------------------------------------------------------- | |
2410 | |
2411 \subsection{umfpack\_*\_defaults} | |
2412 | |
2413 {\footnotesize | |
2414 \begin{verbatim} | |
2415 INCLUDE umfpack_defaults.h via sed | |
2416 \end{verbatim} | |
2417 } | |
2418 | |
2419 \newpage | |
2420 \subsection{umfpack\_*\_qsymbolic} | |
2421 | |
2422 {\footnotesize | |
2423 \begin{verbatim} | |
2424 INCLUDE umfpack_qsymbolic.h via sed | |
2425 \end{verbatim} | |
2426 } | |
2427 | |
2428 \newpage | |
2429 \subsection{umfpack\_*\_wsolve} | |
2430 | |
2431 {\footnotesize | |
2432 \begin{verbatim} | |
2433 INCLUDE umfpack_wsolve.h via sed | |
2434 \end{verbatim} | |
2435 } | |
2436 | |
2437 %------------------------------------------------------------------------------- | |
2438 \newpage | |
2439 \section{Matrix manipulation routines} | |
2440 \label{Manipulate} | |
2441 %------------------------------------------------------------------------------- | |
2442 | |
2443 \subsection{umfpack\_*\_col\_to\_triplet} | |
2444 | |
2445 {\footnotesize | |
2446 \begin{verbatim} | |
2447 INCLUDE umfpack_col_to_triplet.h via sed | |
2448 \end{verbatim} | |
2449 } | |
2450 | |
2451 \newpage | |
2452 \subsection{umfpack\_*\_triplet\_to\_col} | |
2453 | |
2454 {\footnotesize | |
2455 \begin{verbatim} | |
2456 INCLUDE umfpack_triplet_to_col.h via sed | |
2457 \end{verbatim} | |
2458 } | |
2459 | |
2460 \newpage | |
2461 \subsection{umfpack\_*\_transpose} | |
2462 | |
2463 {\footnotesize | |
2464 \begin{verbatim} | |
2465 INCLUDE umfpack_transpose.h via sed | |
2466 \end{verbatim} | |
2467 } | |
2468 | |
2469 \newpage | |
2470 \subsection{umfpack\_*\_scale} | |
2471 | |
2472 {\footnotesize | |
2473 \begin{verbatim} | |
2474 INCLUDE umfpack_scale.h via sed | |
2475 \end{verbatim} | |
2476 } | |
2477 | |
2478 %------------------------------------------------------------------------------- | |
2479 \newpage | |
2480 \section{Getting the contents of opaque objects} | |
2481 \label{Get} | |
2482 %------------------------------------------------------------------------------- | |
2483 | |
2484 \subsection{umfpack\_*\_get\_lunz} | |
2485 | |
2486 {\footnotesize | |
2487 \begin{verbatim} | |
2488 INCLUDE umfpack_get_lunz.h via sed | |
2489 \end{verbatim} | |
2490 } | |
2491 | |
2492 \newpage | |
2493 \subsection{umfpack\_*\_get\_numeric} | |
2494 | |
2495 {\footnotesize | |
2496 \begin{verbatim} | |
2497 INCLUDE umfpack_get_numeric.h via sed | |
2498 \end{verbatim} | |
2499 } | |
2500 | |
2501 \newpage | |
2502 \subsection{umfpack\_*\_get\_symbolic} | |
2503 | |
2504 {\footnotesize | |
2505 \begin{verbatim} | |
2506 INCLUDE umfpack_get_symbolic.h via sed | |
2507 \end{verbatim} | |
2508 } | |
2509 | |
2510 \newpage | |
2511 \subsection{umfpack\_*\_save\_numeric} | |
2512 | |
2513 {\footnotesize | |
2514 \begin{verbatim} | |
2515 INCLUDE umfpack_save_numeric.h via sed | |
2516 \end{verbatim} | |
2517 } | |
2518 | |
2519 \newpage | |
2520 \subsection{umfpack\_*\_load\_numeric} | |
2521 | |
2522 {\footnotesize | |
2523 \begin{verbatim} | |
2524 INCLUDE umfpack_load_numeric.h via sed | |
2525 \end{verbatim} | |
2526 } | |
2527 | |
2528 \newpage | |
2529 \subsection{umfpack\_*\_save\_symbolic} | |
2530 | |
2531 {\footnotesize | |
2532 \begin{verbatim} | |
2533 INCLUDE umfpack_save_symbolic.h via sed | |
2534 \end{verbatim} | |
2535 } | |
2536 | |
2537 \newpage | |
2538 \subsection{umfpack\_*\_load\_symbolic} | |
2539 | |
2540 {\footnotesize | |
2541 \begin{verbatim} | |
2542 INCLUDE umfpack_load_symbolic.h via sed | |
2543 \end{verbatim} | |
2544 } | |
2545 | |
2546 \newpage | |
2547 \subsection{umfpack\_*\_get\_determinant} | |
2548 | |
2549 {\footnotesize | |
2550 \begin{verbatim} | |
2551 INCLUDE umfpack_get_determinant.h via sed | |
2552 \end{verbatim} | |
2553 } | |
2554 | |
2555 %------------------------------------------------------------------------------- | |
2556 \newpage | |
2557 \section{Reporting routines} | |
2558 \label{Report} | |
2559 %------------------------------------------------------------------------------- | |
2560 | |
2561 \subsection{umfpack\_*\_report\_status} | |
2562 | |
2563 {\footnotesize | |
2564 \begin{verbatim} | |
2565 INCLUDE umfpack_report_status.h via sed | |
2566 \end{verbatim} | |
2567 } | |
2568 | |
2569 \newpage | |
2570 \subsection{umfpack\_*\_report\_control} | |
2571 | |
2572 {\footnotesize | |
2573 \begin{verbatim} | |
2574 INCLUDE umfpack_report_control.h via sed | |
2575 \end{verbatim} | |
2576 } | |
2577 | |
2578 \newpage | |
2579 \subsection{umfpack\_*\_report\_info} | |
2580 | |
2581 {\footnotesize | |
2582 \begin{verbatim} | |
2583 INCLUDE umfpack_report_info.h via sed | |
2584 \end{verbatim} | |
2585 } | |
2586 | |
2587 \newpage | |
2588 \subsection{umfpack\_*\_report\_matrix} | |
2589 | |
2590 {\footnotesize | |
2591 \begin{verbatim} | |
2592 INCLUDE umfpack_report_matrix.h via sed | |
2593 \end{verbatim} | |
2594 } | |
2595 | |
2596 \newpage | |
2597 \subsection{umfpack\_*\_report\_numeric} | |
2598 | |
2599 {\footnotesize | |
2600 \begin{verbatim} | |
2601 INCLUDE umfpack_report_numeric.h via sed | |
2602 \end{verbatim} | |
2603 } | |
2604 | |
2605 \newpage | |
2606 \subsection{umfpack\_*\_report\_perm} | |
2607 | |
2608 {\footnotesize | |
2609 \begin{verbatim} | |
2610 INCLUDE umfpack_report_perm.h via sed | |
2611 \end{verbatim} | |
2612 } | |
2613 | |
2614 \newpage | |
2615 \subsection{umfpack\_*\_report\_symbolic} | |
2616 | |
2617 {\footnotesize | |
2618 \begin{verbatim} | |
2619 INCLUDE umfpack_report_symbolic.h via sed | |
2620 \end{verbatim} | |
2621 } | |
2622 | |
2623 \newpage | |
2624 \subsection{umfpack\_*\_report\_triplet} | |
2625 | |
2626 {\footnotesize | |
2627 \begin{verbatim} | |
2628 INCLUDE umfpack_report_triplet.h via sed | |
2629 \end{verbatim} | |
2630 } | |
2631 | |
2632 \newpage | |
2633 \subsection{umfpack\_*\_report\_vector} | |
2634 | |
2635 {\footnotesize | |
2636 \begin{verbatim} | |
2637 INCLUDE umfpack_report_vector.h via sed | |
2638 \end{verbatim} | |
2639 } | |
2640 | |
2641 %------------------------------------------------------------------------------- | |
2642 \newpage | |
2643 \section{Utility routines} | |
2644 \label{Utility} | |
2645 %------------------------------------------------------------------------------- | |
2646 | |
2647 \subsection{umfpack\_timer} | |
2648 | |
2649 {\footnotesize | |
2650 \begin{verbatim} | |
2651 INCLUDE umfpack_timer.h via sed | |
2652 \end{verbatim} | |
2653 } | |
2654 | |
2655 \newpage | |
2656 \subsection{umfpack\_tic and umfpack\_toc} | |
2657 | |
2658 {\footnotesize | |
2659 \begin{verbatim} | |
2660 INCLUDE umfpack_tictoc.h via sed | |
2661 \end{verbatim} | |
2662 } | |
2663 | |
2664 | |
2665 %------------------------------------------------------------------------------- | |
2666 \newpage | |
2667 % References | |
2668 %------------------------------------------------------------------------------- | |
2669 | |
2670 \bibliographystyle{plain} | |
2671 \bibliography{UserGuide} | |
2672 | |
2673 \end{document} |