Skip to content
Snippets Groups Projects
Commit 52029c51 authored by Johannes Michael Magnus Leonhard Faust's avatar Johannes Michael Magnus Leonhard Faust
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 2068 additions and 0 deletions
add_library(amd SHARED Source//amd_1.c Source//amd_2.c Source//amd_aat.c Source//amd_order.c Source//amd_post_tree.c Source//amd_postorder.c Source//amd_preprocess.c Source//amd_valid.c Include//amd.h Include//amd_internal.h)
include_directories(AMD//Include)
install(TARGETS amd DESTINATION lib)
\ No newline at end of file
#-----------------------------------------------------------------------------
# compile the AMD demo (for both GNU make or original make)
#-----------------------------------------------------------------------------
default: amd_simple amd_demo amd_demo2 amd_l_demo
include ../../SuiteSparse_config/SuiteSparse_config.mk
C = $(CC) $(CF) -I../Include -I../../SuiteSparse_config
INC = ../Include/amd.h ../../SuiteSparse_config/SuiteSparse_config.h
LIB2 = ../../SuiteSparse_config/libsuitesparseconfig.a $(LIB)
library:
( cd ../../SuiteSparse_config ; $(MAKE) )
( cd ../Lib ; $(MAKE) )
f77lib:
( cd ../Lib ; $(MAKE) fortran )
#------------------------------------------------------------------------------
# Create the demo program, run it, and compare the output
#------------------------------------------------------------------------------
dist:
amd_demo: amd_demo.c library $(INC)
$(C) -o amd_demo amd_demo.c ../Lib/libamd.a $(LIB2)
./amd_demo > my_amd_demo.out
- diff amd_demo.out my_amd_demo.out
amd_l_demo: amd_l_demo.c library $(INC)
$(C) -o amd_l_demo amd_l_demo.c ../Lib/libamd.a $(LIB2)
./amd_l_demo > my_amd_l_demo.out
- diff amd_l_demo.out my_amd_l_demo.out
amd_demo2: amd_demo2.c library $(INC)
$(C) -o amd_demo2 amd_demo2.c ../Lib/libamd.a $(LIB2)
./amd_demo2 > my_amd_demo2.out
- diff amd_demo2.out my_amd_demo2.out
amd_simple: amd_simple.c library $(INC)
$(C) -o amd_simple amd_simple.c ../Lib/libamd.a $(LIB2)
./amd_simple > my_amd_simple.out
- diff amd_simple.out my_amd_simple.out
#------------------------------------------------------------------------------
# compile the Fortran demo
#------------------------------------------------------------------------------
fortran: amd_f77demo amd_f77simple
cross: amd_f77cross
amd_f77demo: amd_f77demo.f f77lib
$(F77) $(F77FLAGS) -o amd_f77demo amd_f77demo.f ../Lib/libamdf77.a \
$(F77LIB)
./amd_f77demo > my_amd_f77demo.out
- diff amd_f77demo.out my_amd_f77demo.out
amd_f77simple: amd_f77simple.f f77lib
$(F77) $(F77FLAGS) -o amd_f77simple amd_f77simple.f \
../Lib/libamdf77.a $(F77LIB)
./amd_f77simple > my_amd_f77simple.out
- diff amd_f77simple.out my_amd_f77simple.out
amd_f77wrapper.o: amd_f77wrapper.c
$(C) -DDINT -c amd_f77wrapper.c
amd_f77cross: amd_f77cross.f amd_f77wrapper.o ../Lib/libamd.a
$(F77) $(F77FLAGS) -o amd_f77cross amd_f77cross.f amd_f77wrapper.o \
../Lib/libamd.a $(F77LIB)
./amd_f77cross > my_amd_f77cross.out
- diff amd_f77cross.out my_amd_f77cross.out
#------------------------------------------------------------------------------
# Remove all but the files in the original distribution
#------------------------------------------------------------------------------
clean:
- $(RM) $(CLEAN)
purge: distclean
distclean: clean
- $(RM) amd_demo my_amd_demo.out
- $(RM) amd_l_demo my_amd_l_demo.out
- $(RM) amd_demo2 my_amd_demo2.out
- $(RM) amd_simple my_amd_simple.out
- $(RM) amd_f77demo my_amd_f77demo.out
- $(RM) amd_f77simple my_amd_f77simple.out
- $(RM) amd_f77cross my_amd_f77cross.out
- $(RM) -r *.dSYM
/* ========================================================================= */
/* === AMD demo main program =============================================== */
/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/* AMD Copyright (c) by Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* DrTimothyAldenDavis@gmail.com, http://www.suitesparse.com */
/* ------------------------------------------------------------------------- */
/* A simple C main program that illustrates the use of the ANSI C interface
* to AMD.
*/
#include "amd.h"
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
/* The symmetric can_24 Harwell/Boeing matrix, including upper and lower
* triangular parts, and the diagonal entries. Note that this matrix is
* 0-based, with row and column indices in the range 0 to n-1. */
int n = 24, nz,
Ap [ ] = { 0, 9, 15, 21, 27, 33, 39, 48, 57, 61, 70, 76, 82, 88, 94, 100,
106, 110, 119, 128, 137, 143, 152, 156, 160 },
Ai [ ] = {
/* column 0: */ 0, 5, 6, 12, 13, 17, 18, 19, 21,
/* column 1: */ 1, 8, 9, 13, 14, 17,
/* column 2: */ 2, 6, 11, 20, 21, 22,
/* column 3: */ 3, 7, 10, 15, 18, 19,
/* column 4: */ 4, 7, 9, 14, 15, 16,
/* column 5: */ 0, 5, 6, 12, 13, 17,
/* column 6: */ 0, 2, 5, 6, 11, 12, 19, 21, 23,
/* column 7: */ 3, 4, 7, 9, 14, 15, 16, 17, 18,
/* column 8: */ 1, 8, 9, 14,
/* column 9: */ 1, 4, 7, 8, 9, 13, 14, 17, 18,
/* column 10: */ 3, 10, 18, 19, 20, 21,
/* column 11: */ 2, 6, 11, 12, 21, 23,
/* column 12: */ 0, 5, 6, 11, 12, 23,
/* column 13: */ 0, 1, 5, 9, 13, 17,
/* column 14: */ 1, 4, 7, 8, 9, 14,
/* column 15: */ 3, 4, 7, 15, 16, 18,
/* column 16: */ 4, 7, 15, 16,
/* column 17: */ 0, 1, 5, 7, 9, 13, 17, 18, 19,
/* column 18: */ 0, 3, 7, 9, 10, 15, 17, 18, 19,
/* column 19: */ 0, 3, 6, 10, 17, 18, 19, 20, 21,
/* column 20: */ 2, 10, 19, 20, 21, 22,
/* column 21: */ 0, 2, 6, 10, 11, 19, 20, 21, 22,
/* column 22: */ 2, 20, 21, 22,
/* column 23: */ 6, 11, 12, 23 } ;
int P [24], Pinv [24], i, j, k, jnew, p, inew, result ;
double Control [AMD_CONTROL], Info [AMD_INFO] ;
char A [24][24] ;
/* here is an example of how to use AMD_VERSION. This code will work in
* any version of AMD. */
#if defined(AMD_VERSION) && (AMD_VERSION >= AMD_VERSION_CODE(1,2))
printf ("AMD version %d.%d.%d, date: %s\n",
AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE) ;
#else
printf ("AMD version: 1.1 or earlier\n") ;
#endif
printf ("AMD demo, with the 24-by-24 Harwell/Boeing matrix, can_24:\n") ;
/* get the default parameters, and print them */
amd_defaults (Control) ;
amd_control (Control) ;
/* print the input matrix */
nz = Ap [n] ;
printf ("\nInput matrix: %d-by-%d, with %d entries.\n"
" Note that for a symmetric matrix such as this one, only the\n"
" strictly lower or upper triangular parts would need to be\n"
" passed to AMD, since AMD computes the ordering of A+A'. The\n"
" diagonal entries are also not needed, since AMD ignores them.\n"
, n, n, nz) ;
for (j = 0 ; j < n ; j++)
{
printf ("\nColumn: %d, number of entries: %d, with row indices in"
" Ai [%d ... %d]:\n row indices:",
j, Ap [j+1] - Ap [j], Ap [j], Ap [j+1]-1) ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
printf (" %d", i) ;
}
printf ("\n") ;
}
/* print a character plot of the input matrix. This is only reasonable
* because the matrix is small. */
printf ("\nPlot of input matrix pattern:\n") ;
for (j = 0 ; j < n ; j++)
{
for (i = 0 ; i < n ; i++) A [i][j] = '.' ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
A [i][j] = 'X' ;
}
}
printf (" ") ;
for (j = 0 ; j < n ; j++) printf (" %1d", j % 10) ;
printf ("\n") ;
for (i = 0 ; i < n ; i++)
{
printf ("%2d: ", i) ;
for (j = 0 ; j < n ; j++)
{
printf (" %c", A [i][j]) ;
}
printf ("\n") ;
}
/* order the matrix */
result = amd_order (n, Ap, Ai, P, Control, Info) ;
printf ("return value from amd_order: %d (should be %d)\n",
result, AMD_OK) ;
/* print the statistics */
amd_info (Info) ;
if (result != AMD_OK)
{
printf ("AMD failed\n") ;
exit (1) ;
}
/* print the permutation vector, P, and compute the inverse permutation */
printf ("Permutation vector:\n") ;
for (k = 0 ; k < n ; k++)
{
/* row/column j is the kth row/column in the permuted matrix */
j = P [k] ;
Pinv [j] = k ;
printf (" %2d", j) ;
}
printf ("\n\n") ;
printf ("Inverse permutation vector:\n") ;
for (j = 0 ; j < n ; j++)
{
k = Pinv [j] ;
printf (" %2d", k) ;
}
printf ("\n\n") ;
/* print a character plot of the permuted matrix. */
printf ("\nPlot of permuted matrix pattern:\n") ;
for (jnew = 0 ; jnew < n ; jnew++)
{
j = P [jnew] ;
for (inew = 0 ; inew < n ; inew++) A [inew][jnew] = '.' ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
inew = Pinv [Ai [p]] ;
A [inew][jnew] = 'X' ;
}
}
printf (" ") ;
for (j = 0 ; j < n ; j++) printf (" %1d", j % 10) ;
printf ("\n") ;
for (i = 0 ; i < n ; i++)
{
printf ("%2d: ", i) ;
for (j = 0 ; j < n ; j++)
{
printf (" %c", A [i][j]) ;
}
printf ("\n") ;
}
return (0) ;
}
AMD version 2.4.1, date: Oct 10, 2014
AMD demo, with the 24-by-24 Harwell/Boeing matrix, can_24:
AMD version 2.4.1, Oct 10, 2014: approximate minimum degree ordering
dense row parameter: 10
(rows with more than max (10 * sqrt (n), 16) entries are
considered "dense", and placed last in output permutation)
aggressive absorption: yes
size of AMD integer: 4
Input matrix: 24-by-24, with 160 entries.
Note that for a symmetric matrix such as this one, only the
strictly lower or upper triangular parts would need to be
passed to AMD, since AMD computes the ordering of A+A'. The
diagonal entries are also not needed, since AMD ignores them.
Column: 0, number of entries: 9, with row indices in Ai [0 ... 8]:
row indices: 0 5 6 12 13 17 18 19 21
Column: 1, number of entries: 6, with row indices in Ai [9 ... 14]:
row indices: 1 8 9 13 14 17
Column: 2, number of entries: 6, with row indices in Ai [15 ... 20]:
row indices: 2 6 11 20 21 22
Column: 3, number of entries: 6, with row indices in Ai [21 ... 26]:
row indices: 3 7 10 15 18 19
Column: 4, number of entries: 6, with row indices in Ai [27 ... 32]:
row indices: 4 7 9 14 15 16
Column: 5, number of entries: 6, with row indices in Ai [33 ... 38]:
row indices: 0 5 6 12 13 17
Column: 6, number of entries: 9, with row indices in Ai [39 ... 47]:
row indices: 0 2 5 6 11 12 19 21 23
Column: 7, number of entries: 9, with row indices in Ai [48 ... 56]:
row indices: 3 4 7 9 14 15 16 17 18
Column: 8, number of entries: 4, with row indices in Ai [57 ... 60]:
row indices: 1 8 9 14
Column: 9, number of entries: 9, with row indices in Ai [61 ... 69]:
row indices: 1 4 7 8 9 13 14 17 18
Column: 10, number of entries: 6, with row indices in Ai [70 ... 75]:
row indices: 3 10 18 19 20 21
Column: 11, number of entries: 6, with row indices in Ai [76 ... 81]:
row indices: 2 6 11 12 21 23
Column: 12, number of entries: 6, with row indices in Ai [82 ... 87]:
row indices: 0 5 6 11 12 23
Column: 13, number of entries: 6, with row indices in Ai [88 ... 93]:
row indices: 0 1 5 9 13 17
Column: 14, number of entries: 6, with row indices in Ai [94 ... 99]:
row indices: 1 4 7 8 9 14
Column: 15, number of entries: 6, with row indices in Ai [100 ... 105]:
row indices: 3 4 7 15 16 18
Column: 16, number of entries: 4, with row indices in Ai [106 ... 109]:
row indices: 4 7 15 16
Column: 17, number of entries: 9, with row indices in Ai [110 ... 118]:
row indices: 0 1 5 7 9 13 17 18 19
Column: 18, number of entries: 9, with row indices in Ai [119 ... 127]:
row indices: 0 3 7 9 10 15 17 18 19
Column: 19, number of entries: 9, with row indices in Ai [128 ... 136]:
row indices: 0 3 6 10 17 18 19 20 21
Column: 20, number of entries: 6, with row indices in Ai [137 ... 142]:
row indices: 2 10 19 20 21 22
Column: 21, number of entries: 9, with row indices in Ai [143 ... 151]:
row indices: 0 2 6 10 11 19 20 21 22
Column: 22, number of entries: 4, with row indices in Ai [152 ... 155]:
row indices: 2 20 21 22
Column: 23, number of entries: 4, with row indices in Ai [156 ... 159]:
row indices: 6 11 12 23
Plot of input matrix pattern:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
0: X . . . . X X . . . . . X X . . . X X X . X . .
1: . X . . . . . . X X . . . X X . . X . . . . . .
2: . . X . . . X . . . . X . . . . . . . . X X X .
3: . . . X . . . X . . X . . . . X . . X X . . . .
4: . . . . X . . X . X . . . . X X X . . . . . . .
5: X . . . . X X . . . . . X X . . . X . . . . . .
6: X . X . . X X . . . . X X . . . . . . X . X . X
7: . . . X X . . X . X . . . . X X X X X . . . . .
8: . X . . . . . . X X . . . . X . . . . . . . . .
9: . X . . X . . X X X . . . X X . . X X . . . . .
10: . . . X . . . . . . X . . . . . . . X X X X . .
11: . . X . . . X . . . . X X . . . . . . . . X . X
12: X . . . . X X . . . . X X . . . . . . . . . . X
13: X X . . . X . . . X . . . X . . . X . . . . . .
14: . X . . X . . X X X . . . . X . . . . . . . . .
15: . . . X X . . X . . . . . . . X X . X . . . . .
16: . . . . X . . X . . . . . . . X X . . . . . . .
17: X X . . . X . X . X . . . X . . . X X X . . . .
18: X . . X . . . X . X X . . . . X . X X X . . . .
19: X . . X . . X . . . X . . . . . . X X X X X . .
20: . . X . . . . . . . X . . . . . . . . X X X X .
21: X . X . . . X . . . X X . . . . . . . X X X X .
22: . . X . . . . . . . . . . . . . . . . . X X X .
23: . . . . . . X . . . . X X . . . . . . . . . . X
return value from amd_order: 0 (should be 0)
AMD version 2.4.1, Oct 10, 2014, results:
status: OK
n, dimension of A: 24
nz, number of nonzeros in A: 160
symmetry of A: 1.0000
number of nonzeros on diagonal: 24
nonzeros in pattern of A+A' (excl. diagonal): 136
# dense rows/columns of A+A': 0
memory used, in bytes: 1516
# of memory compactions: 0
The following approximate statistics are for a subsequent
factorization of A(P,P) + A(P,P)'. They are slight upper
bounds if there are no dense rows/columns in A+A', and become
looser if dense rows/columns exist.
nonzeros in L (excluding diagonal): 97
nonzeros in L (including diagonal): 121
# divide operations for LDL' or LU: 97
# multiply-subtract operations for LDL': 275
# multiply-subtract operations for LU: 453
max nz. in any column of L (incl. diagonal): 8
chol flop count for real A, sqrt counted as 1 flop: 671
LDL' flop count for real A: 647
LDL' flop count for complex A: 3073
LU flop count for real A (with no pivoting): 1003
LU flop count for complex A (with no pivoting): 4497
Permutation vector:
22 20 10 23 12 5 16 8 14 4 15 7 1 9 13 17 0 2 3 6 11 18 21 19
Inverse permutation vector:
16 12 17 18 9 5 19 11 7 13 2 20 4 14 8 10 6 15 21 23 1 22 0 3
Plot of permuted matrix pattern:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
0: X X . . . . . . . . . . . . . . . X . . . . X .
1: X X X . . . . . . . . . . . . . . X . . . . X X
2: . X X . . . . . . . . . . . . . . . X . . X X X
3: . . . X X . . . . . . . . . . . . . . X X . . .
4: . . . X X X . . . . . . . . . . X . . X X . . .
5: . . . . X X . . . . . . . . X X X . . X . . . .
6: . . . . . . X . . X X X . . . . . . . . . . . .
7: . . . . . . . X X . . . X X . . . . . . . . . .
8: . . . . . . . X X X . X X X . . . . . . . . . .
9: . . . . . . X . X X X X . X . . . . . . . . . .
10: . . . . . . X . . X X X . . . . . . X . . X . .
11: . . . . . . X . X X X X . X . X . . X . . X . .
12: . . . . . . . X X . . . X X X X . . . . . . . .
13: . . . . . . . X X X . X X X X X . . . . . X . .
14: . . . . . X . . . . . . X X X X X . . . . . . .
15: . . . . . X . . . . . X X X X X X . . . . X . X
16: . . . . X X . . . . . . . . X X X . . X . X X X
17: X X . . . . . . . . . . . . . . . X . X X . X .
18: . . X . . . . . . . X X . . . . . . X . . X . X
19: . . . X X X . . . . . . . . . . X X . X X . X X
20: . . . X X . . . . . . . . . . . . X . X X . X .
21: . . X . . . . . . . X X . X . X X . X . . X . X
22: X X X . . . . . . . . . . . . . X X . X X . X X
23: . X X . . . . . . . . . . . . X X . X X . X X X
/* ========================================================================= */
/* === AMD demo main program (jumbled matrix version) ====================== */
/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/* AMD Copyright (c) by Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* DrTimothyAldenDavis@gmail.com, http://www.suitesparse.com */
/* ------------------------------------------------------------------------- */
/* A simple C main program that illustrates the use of the ANSI C interface
* to AMD.
*
* Identical to amd_demo.c, except that it operates on an input matrix that has
* unsorted columns and duplicate entries.
*/
#include "amd.h"
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
/* The symmetric can_24 Harwell/Boeing matrix (jumbled, and not symmetric).
* Since AMD operates on A+A', only A(i,j) or A(j,i) need to be specified,
* or both. The diagonal entries are optional (some are missing).
* There are many duplicate entries, which must be removed. */
int n = 24, nz,
Ap [ ] = { 0, 9, 14, 20, 28, 33, 37, 44, 53, 58, 63, 63, 66, 69, 72, 75,
78, 82, 86, 91, 97, 101, 112, 112, 116 },
Ai [ ] = {
/* column 0: */ 0, 17, 18, 21, 5, 12, 5, 0, 13,
/* column 1: */ 14, 1, 8, 13, 17,
/* column 2: */ 2, 20, 11, 6, 11, 22,
/* column 3: */ 3, 3, 10, 7, 18, 18, 15, 19,
/* column 4: */ 7, 9, 15, 14, 16,
/* column 5: */ 5, 13, 6, 17,
/* column 6: */ 5, 0, 11, 6, 12, 6, 23,
/* column 7: */ 3, 4, 9, 7, 14, 16, 15, 17, 18,
/* column 8: */ 1, 9, 14, 14, 14,
/* column 9: */ 7, 13, 8, 1, 17,
/* column 10: */
/* column 11: */ 2, 12, 23,
/* column 12: */ 5, 11, 12,
/* column 13: */ 0, 13, 17,
/* column 14: */ 1, 9, 14,
/* column 15: */ 3, 15, 16,
/* column 16: */ 16, 4, 4, 15,
/* column 17: */ 13, 17, 19, 17,
/* column 18: */ 15, 17, 19, 9, 10,
/* column 19: */ 17, 19, 20, 0, 6, 10,
/* column 20: */ 22, 10, 20, 21,
/* column 21: */ 6, 2, 10, 19, 20, 11, 21, 22, 22, 22, 22,
/* column 22: */
/* column 23: */ 12, 11, 12, 23 } ;
int P [24], Pinv [24], i, j, k, jnew, p, inew, result ;
double Control [AMD_CONTROL], Info [AMD_INFO] ;
char A [24][24] ;
printf ("AMD demo, with a jumbled version of the 24-by-24\n") ;
printf ("Harwell/Boeing matrix, can_24:\n") ;
/* get the default parameters, and print them */
amd_defaults (Control) ;
amd_control (Control) ;
/* print the input matrix */
nz = Ap [n] ;
printf ("\nJumbled input matrix: %d-by-%d, with %d entries.\n"
" Note that for a symmetric matrix such as this one, only the\n"
" strictly lower or upper triangular parts would need to be\n"
" passed to AMD, since AMD computes the ordering of A+A'. The\n"
" diagonal entries are also not needed, since AMD ignores them.\n"
" This version of the matrix has jumbled columns and duplicate\n"
" row indices.\n", n, n, nz) ;
for (j = 0 ; j < n ; j++)
{
printf ("\nColumn: %d, number of entries: %d, with row indices in"
" Ai [%d ... %d]:\n row indices:",
j, Ap [j+1] - Ap [j], Ap [j], Ap [j+1]-1) ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
printf (" %d", i) ;
}
printf ("\n") ;
}
/* print a character plot of the input matrix. This is only reasonable
* because the matrix is small. */
printf ("\nPlot of (jumbled) input matrix pattern:\n") ;
for (j = 0 ; j < n ; j++)
{
for (i = 0 ; i < n ; i++) A [i][j] = '.' ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
A [i][j] = 'X' ;
}
}
printf (" ") ;
for (j = 0 ; j < n ; j++) printf (" %1d", j % 10) ;
printf ("\n") ;
for (i = 0 ; i < n ; i++)
{
printf ("%2d: ", i) ;
for (j = 0 ; j < n ; j++)
{
printf (" %c", A [i][j]) ;
}
printf ("\n") ;
}
/* print a character plot of the matrix A+A'. */
printf ("\nPlot of symmetric matrix to be ordered by amd_order:\n") ;
for (j = 0 ; j < n ; j++)
{
for (i = 0 ; i < n ; i++) A [i][j] = '.' ;
}
for (j = 0 ; j < n ; j++)
{
A [j][j] = 'X' ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
A [i][j] = 'X' ;
A [j][i] = 'X' ;
}
}
printf (" ") ;
for (j = 0 ; j < n ; j++) printf (" %1d", j % 10) ;
printf ("\n") ;
for (i = 0 ; i < n ; i++)
{
printf ("%2d: ", i) ;
for (j = 0 ; j < n ; j++)
{
printf (" %c", A [i][j]) ;
}
printf ("\n") ;
}
/* order the matrix */
result = amd_order (n, Ap, Ai, P, Control, Info) ;
printf ("return value from amd_order: %d (should be %d)\n",
result, AMD_OK_BUT_JUMBLED) ;
/* print the statistics */
amd_info (Info) ;
if (result != AMD_OK_BUT_JUMBLED)
{
printf ("AMD failed\n") ;
exit (1) ;
}
/* print the permutation vector, P, and compute the inverse permutation */
printf ("Permutation vector:\n") ;
for (k = 0 ; k < n ; k++)
{
/* row/column j is the kth row/column in the permuted matrix */
j = P [k] ;
Pinv [j] = k ;
printf (" %2d", j) ;
}
printf ("\n\n") ;
printf ("Inverse permutation vector:\n") ;
for (j = 0 ; j < n ; j++)
{
k = Pinv [j] ;
printf (" %2d", k) ;
}
printf ("\n\n") ;
/* print a character plot of the permuted matrix. */
printf ("\nPlot of (symmetrized) permuted matrix pattern:\n") ;
for (j = 0 ; j < n ; j++)
{
for (i = 0 ; i < n ; i++) A [i][j] = '.' ;
}
for (jnew = 0 ; jnew < n ; jnew++)
{
j = P [jnew] ;
A [jnew][jnew] = 'X' ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
inew = Pinv [Ai [p]] ;
A [inew][jnew] = 'X' ;
A [jnew][inew] = 'X' ;
}
}
printf (" ") ;
for (j = 0 ; j < n ; j++) printf (" %1d", j % 10) ;
printf ("\n") ;
for (i = 0 ; i < n ; i++)
{
printf ("%2d: ", i) ;
for (j = 0 ; j < n ; j++)
{
printf (" %c", A [i][j]) ;
}
printf ("\n") ;
}
return (0) ;
}
AMD demo, with a jumbled version of the 24-by-24
Harwell/Boeing matrix, can_24:
AMD version 2.4.1, Oct 10, 2014: approximate minimum degree ordering
dense row parameter: 10
(rows with more than max (10 * sqrt (n), 16) entries are
considered "dense", and placed last in output permutation)
aggressive absorption: yes
size of AMD integer: 4
Jumbled input matrix: 24-by-24, with 116 entries.
Note that for a symmetric matrix such as this one, only the
strictly lower or upper triangular parts would need to be
passed to AMD, since AMD computes the ordering of A+A'. The
diagonal entries are also not needed, since AMD ignores them.
This version of the matrix has jumbled columns and duplicate
row indices.
Column: 0, number of entries: 9, with row indices in Ai [0 ... 8]:
row indices: 0 17 18 21 5 12 5 0 13
Column: 1, number of entries: 5, with row indices in Ai [9 ... 13]:
row indices: 14 1 8 13 17
Column: 2, number of entries: 6, with row indices in Ai [14 ... 19]:
row indices: 2 20 11 6 11 22
Column: 3, number of entries: 8, with row indices in Ai [20 ... 27]:
row indices: 3 3 10 7 18 18 15 19
Column: 4, number of entries: 5, with row indices in Ai [28 ... 32]:
row indices: 7 9 15 14 16
Column: 5, number of entries: 4, with row indices in Ai [33 ... 36]:
row indices: 5 13 6 17
Column: 6, number of entries: 7, with row indices in Ai [37 ... 43]:
row indices: 5 0 11 6 12 6 23
Column: 7, number of entries: 9, with row indices in Ai [44 ... 52]:
row indices: 3 4 9 7 14 16 15 17 18
Column: 8, number of entries: 5, with row indices in Ai [53 ... 57]:
row indices: 1 9 14 14 14
Column: 9, number of entries: 5, with row indices in Ai [58 ... 62]:
row indices: 7 13 8 1 17
Column: 10, number of entries: 0, with row indices in Ai [63 ... 62]:
row indices:
Column: 11, number of entries: 3, with row indices in Ai [63 ... 65]:
row indices: 2 12 23
Column: 12, number of entries: 3, with row indices in Ai [66 ... 68]:
row indices: 5 11 12
Column: 13, number of entries: 3, with row indices in Ai [69 ... 71]:
row indices: 0 13 17
Column: 14, number of entries: 3, with row indices in Ai [72 ... 74]:
row indices: 1 9 14
Column: 15, number of entries: 3, with row indices in Ai [75 ... 77]:
row indices: 3 15 16
Column: 16, number of entries: 4, with row indices in Ai [78 ... 81]:
row indices: 16 4 4 15
Column: 17, number of entries: 4, with row indices in Ai [82 ... 85]:
row indices: 13 17 19 17
Column: 18, number of entries: 5, with row indices in Ai [86 ... 90]:
row indices: 15 17 19 9 10
Column: 19, number of entries: 6, with row indices in Ai [91 ... 96]:
row indices: 17 19 20 0 6 10
Column: 20, number of entries: 4, with row indices in Ai [97 ... 100]:
row indices: 22 10 20 21
Column: 21, number of entries: 11, with row indices in Ai [101 ... 111]:
row indices: 6 2 10 19 20 11 21 22 22 22 22
Column: 22, number of entries: 0, with row indices in Ai [112 ... 111]:
row indices:
Column: 23, number of entries: 4, with row indices in Ai [112 ... 115]:
row indices: 12 11 12 23
Plot of (jumbled) input matrix pattern:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
0: X . . . . . X . . . . . . X . . . . . X . . . .
1: . X . . . . . . X X . . . . X . . . . . . . . .
2: . . X . . . . . . . . X . . . . . . . . . X . .
3: . . . X . . . X . . . . . . . X . . . . . . . .
4: . . . . . . . X . . . . . . . . X . . . . . . .
5: X . . . . X X . . . . . X . . . . . . . . . . .
6: . . X . . X X . . . . . . . . . . . . X . X . .
7: . . . X X . . X . X . . . . . . . . . . . . . .
8: . X . . . . . . . X . . . . . . . . . . . . . .
9: . . . . X . . X X . . . . . X . . . X . . . . .
10: . . . X . . . . . . . . . . . . . . X X X X . .
11: . . X . . . X . . . . . X . . . . . . . . X . X
12: X . . . . . X . . . . X X . . . . . . . . . . X
13: X X . . . X . . . X . . . X . . . X . . . . . .
14: . X . . X . . X X . . . . . X . . . . . . . . .
15: . . . X X . . X . . . . . . . X X . X . . . . .
16: . . . . X . . X . . . . . . . X X . . . . . . .
17: X X . . . X . X . X . . . X . . . X X X . . . .
18: X . . X . . . X . . . . . . . . . . . . . . . .
19: . . . X . . . . . . . . . . . . . X X X . X . .
20: . . X . . . . . . . . . . . . . . . . X X X . .
21: X . . . . . . . . . . . . . . . . . . . X X . .
22: . . X . . . . . . . . . . . . . . . . . X X . .
23: . . . . . . X . . . . X . . . . . . . . . . . X
Plot of symmetric matrix to be ordered by amd_order:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
0: X . . . . X X . . . . . X X . . . X X X . X . .
1: . X . . . . . . X X . . . X X . . X . . . . . .
2: . . X . . . X . . . . X . . . . . . . . X X X .
3: . . . X . . . X . . X . . . . X . . X X . . . .
4: . . . . X . . X . X . . . . X X X . . . . . . .
5: X . . . . X X . . . . . X X . . . X . . . . . .
6: X . X . . X X . . . . X X . . . . . . X . X . X
7: . . . X X . . X . X . . . . X X X X X . . . . .
8: . X . . . . . . X X . . . . X . . . . . . . . .
9: . X . . X . . X X X . . . X X . . X X . . . . .
10: . . . X . . . . . . X . . . . . . . X X X X . .
11: . . X . . . X . . . . X X . . . . . . . . X . X
12: X . . . . X X . . . . X X . . . . . . . . . . X
13: X X . . . X . . . X . . . X . . . X . . . . . .
14: . X . . X . . X X X . . . . X . . . . . . . . .
15: . . . X X . . X . . . . . . . X X . X . . . . .
16: . . . . X . . X . . . . . . . X X . . . . . . .
17: X X . . . X . X . X . . . X . . . X X X . . . .
18: X . . X . . . X . X X . . . . X . X X X . . . .
19: X . . X . . X . . . X . . . . . . X X X X X . .
20: . . X . . . . . . . X . . . . . . . . X X X X .
21: X . X . . . X . . . X X . . . . . . . X X X X .
22: . . X . . . . . . . . . . . . . . . . . X X X .
23: . . . . . . X . . . . X X . . . . . . . . . . X
return value from amd_order: 1 (should be 1)
AMD version 2.4.1, Oct 10, 2014, results:
status: OK, but jumbled
n, dimension of A: 24
nz, number of nonzeros in A: 102
symmetry of A: 0.4000
number of nonzeros on diagonal: 17
nonzeros in pattern of A+A' (excl. diagonal): 136
# dense rows/columns of A+A': 0
memory used, in bytes: 2080
# of memory compactions: 0
The following approximate statistics are for a subsequent
factorization of A(P,P) + A(P,P)'. They are slight upper
bounds if there are no dense rows/columns in A+A', and become
looser if dense rows/columns exist.
nonzeros in L (excluding diagonal): 97
nonzeros in L (including diagonal): 121
# divide operations for LDL' or LU: 97
# multiply-subtract operations for LDL': 275
# multiply-subtract operations for LU: 453
max nz. in any column of L (incl. diagonal): 8
chol flop count for real A, sqrt counted as 1 flop: 671
LDL' flop count for real A: 647
LDL' flop count for complex A: 3073
LU flop count for real A (with no pivoting): 1003
LU flop count for complex A (with no pivoting): 4497
Permutation vector:
22 20 10 23 12 5 16 8 14 4 15 7 1 9 13 17 0 2 3 6 11 18 21 19
Inverse permutation vector:
16 12 17 18 9 5 19 11 7 13 2 20 4 14 8 10 6 15 21 23 1 22 0 3
Plot of (symmetrized) permuted matrix pattern:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
0: X X . . . . . . . . . . . . . . . X . . . . X .
1: X X X . . . . . . . . . . . . . . X . . . . X X
2: . X X . . . . . . . . . . . . . . . X . . X X X
3: . . . X X . . . . . . . . . . . . . . X X . . .
4: . . . X X X . . . . . . . . . . X . . X X . . .
5: . . . . X X . . . . . . . . X X X . . X . . . .
6: . . . . . . X . . X X X . . . . . . . . . . . .
7: . . . . . . . X X . . . X X . . . . . . . . . .
8: . . . . . . . X X X . X X X . . . . . . . . . .
9: . . . . . . X . X X X X . X . . . . . . . . . .
10: . . . . . . X . . X X X . . . . . . X . . X . .
11: . . . . . . X . X X X X . X . X . . X . . X . .
12: . . . . . . . X X . . . X X X X . . . . . . . .
13: . . . . . . . X X X . X X X X X . . . . . X . .
14: . . . . . X . . . . . . X X X X X . . . . . . .
15: . . . . . X . . . . . X X X X X X . . . . X . X
16: . . . . X X . . . . . . . . X X X . . X . X X X
17: X X . . . . . . . . . . . . . . . X . X X . X .
18: . . X . . . . . . . X X . . . . . . X . . X . X
19: . . . X X X . . . . . . . . . . X X . X X . X X
20: . . . X X . . . . . . . . . . . . X . X X . X .
21: . . X . . . . . . . X X . X . X X . X . . X . X
22: X X X . . . . . . . . . . . . . X X . X X . X X
23: . X X . . . . . . . . . . . . X X . X X . X X X
C ======================================================================
C === AMD_cross ========================================================
C ======================================================================
C ----------------------------------------------------------------------
C AMD, Copyright (c) by Timothy A. Davis, Patrick R.
C Amestoy, and Iain S. Duff. See ../README.txt for License.
C email: DrTimothyAldenDavis@gmail.com
C ----------------------------------------------------------------------
C This program provides an example of how to call the C version of AMD
C from a Fortran program. It is HIGHLY non-portable.
C The amd_order routine returns PERM (1) < 0 if an error occurs.
C (-1: out of memory, -2: invalid matrix)
C Note that the input matrix is 0-based. From Fortran, column j of the
C matrix is in AI (AP (I)+1 ... AP (I+1)). The row indices in this
C set are in the range 0 to N-1. To demonstrate this translation,
C the input matrix is printed in 1-based form. This program uses
C the same 5-by-5 test matrix as amd_simple.c.
INTEGER N, NZ, K, P
PARAMETER (N = 5, NZ = 14)
INTEGER AP (N+1), AI (NZ), PERM (N)
DATA AP / 0, 2, 6, 10, 12, 14 /
DATA AI / 0,1, 0,1,2,4, 1,2,3,4, 2,3, 1,4 /
DOUBLE PRECISION CONTROL (5), INFO (20)
C print the input matrix
PRINT 10, N, N, NZ
10 FORMAT ('Input matrix:', I2, '-by-', I2, ' with',I3,' entries')
DO 40 J = 1, N
PRINT 20, J, AP (J+1) - AP (J), AP (J)+1, AP (J+1)
20 FORMAT ( /, 'Column: ', I2, ' number of entries: ', I2,
$ ' with row indices in AI (', I3, ' ... ', I3, ')')
PRINT 30, ((AI (P) + 1), P = AP (J) + 1, AP (J+1))
30 FORMAT (' row indices: ', 24I3)
40 CONTINUE
CALL AMDDEFAULTS (CONTROL)
CALL AMDORDER (N, AP, AI, PERM, CONTROL, INFO)
CALL AMDINFO (INFO)
DO 60 K = 1, N
PRINT 50, K, PERM (K) + 1
50 FORMAT ('PERM (',I2,') = ', I2)
60 CONTINUE
END
Input matrix: 5-by- 5 with 14 entries
Column: 1 number of entries: 2 with row indices in AI ( 1 ... 2)
row indices: 1 2
Column: 2 number of entries: 4 with row indices in AI ( 3 ... 6)
row indices: 1 2 3 5
Column: 3 number of entries: 4 with row indices in AI ( 7 ... 10)
row indices: 2 3 4 5
Column: 4 number of entries: 2 with row indices in AI ( 11 ... 12)
row indices: 3 4
Column: 5 number of entries: 2 with row indices in AI ( 13 ... 14)
row indices: 2 5
amd: approximate minimum degree ordering, results:
status: OK
n, dimension of A: 5
nz, number of nonzeros in A: 14
symmetry of A: 0.8889
number of nonzeros on diagonal: 5
nonzeros in pattern of A+A' (excl. diagonal): 10
# dense rows/columns of A+A': 0
memory used, in bytes: 228
# of memory compactions: 0
The following approximate statistics are for a subsequent
factorization of A(P,P) + A(P,P)'. They are slight upper
bounds if there are no dense rows/columns in A+A', and become
looser if dense rows/columns exist.
nonzeros in L (excluding diagonal): 5
nonzeros in L (including diagonal): 10
# divide operations for LDL' or LU: 5
# multiply-subtract operations for LDL': 6
# multiply-subtract operations for LU: 7
max nz. in any column of L (incl. diagonal): 3
chol flop count for real A, sqrt counted as 1 flop: 22
LDL' flop count for real A: 17
LDL' flop count for complex A: 93
LU flop count for real A (with no pivoting): 19
LU flop count for complex A (with no pivoting): 101
PERM ( 1) = 1
PERM ( 2) = 4
PERM ( 3) = 3
PERM ( 4) = 5
PERM ( 5) = 2
C ======================================================================
C === Fortran AMD demo main program ====================================
C ======================================================================
C ----------------------------------------------------------------------
C AMD, Copyright (c) by Timothy A. Davis, Patrick R.
C Amestoy, and Iain S. Duff. See ../README.txt for License.
C email: DrTimothyAldenDavis@gmail.com
C ----------------------------------------------------------------------
C A simple Fortran 77 main program that illustrates the use of the
C Fortran version of AMD (both the AMD and AMDBAR routines). Note
C that aggressive absorption has no effect on this particular matrix.
C AP and AI contain the symmetric can_24 Harwell/Boeing matrix,
C including upper and lower triangular parts, but excluding the
C diagonal entries. Note that this matrix is 1-based, with row
C and column indices in the range 1 to N.
INTEGER N, NZ, IWLEN, PFREE, I, J, K, JNEW, P, INEW,
$ METHOD, NCMPA
PARAMETER (N = 24, NZ = 136, IWLEN = 200)
INTEGER PE (N), DEGREE (N), NV (N), NEXT (N), PERM (N), W (N),
$ HEAD (N), PINV (N), LEN (N), AP (N+1), AI (NZ), IW (IWLEN)
CHARACTER A (24,24)
DATA AP
$ / 1, 9, 14, 19, 24, 29, 34, 42, 50, 53, 61, 66, 71,
$ 76, 81, 86, 91, 94, 102, 110, 118, 123, 131, 134, 137 /
DATA AI /
$ 6, 7, 13, 14, 18, 19, 20, 22,
$ 9, 10, 14, 15, 18,
$ 7, 12, 21, 22, 23,
$ 8, 11, 16, 19, 20,
$ 8, 10, 15, 16, 17,
$ 1, 7, 13, 14, 18,
$ 1, 3, 6, 12, 13, 20, 22, 24,
$ 4, 5, 10, 15, 16, 17, 18, 19,
$ 2, 10, 15,
$ 2, 5, 8, 9, 14, 15, 18, 19,
$ 4, 19, 20, 21, 22,
$ 3, 7, 13, 22, 24,
$ 1, 6, 7, 12, 24,
$ 1, 2, 6, 10, 18,
$ 2, 5, 8, 9, 10,
$ 4, 5, 8, 17, 19,
$ 5, 8, 16,
$ 1, 2, 6, 8, 10, 14, 19, 20,
$ 1, 4, 8, 10, 11, 16, 18, 20,
$ 1, 4, 7, 11, 18, 19, 21, 22,
$ 3, 11, 20, 22, 23,
$ 1, 3, 7, 11, 12, 20, 21, 23,
$ 3, 21, 22,
$ 7, 12, 13 /
C print the input matrix
PRINT 11, N, N, NZ
11 FORMAT ('AMD Fortran 77 demo, with the 24-by-24',
$ ' Harwell/Boeing matrix, can_24:'
$ /, 'Input matrix: ', I2, '-by-', I2,' with ',I3,' entries',
$ /, 'Note that the Fortran version of AMD requires that'
$ /, 'no diagonal entries be present.')
DO 20 J = 1, N
PRINT 21, J, AP (J+1) - AP (J), AP (J), AP (J+1)-1
21 FORMAT ( /, 'Column: ', I2, ' number of entries: ', I2,
$ ' with row indices in AI (', I3, ' ... ', I3, ')')
PRINT 10, ((AI (P)), P = AP (J), AP (J+1) - 1)
10 FORMAT (' row indices: ', 24I3)
20 CONTINUE
C print a character plot of the input matrix. This is only
C reasonable because the matrix is small.
PRINT 31
31 FORMAT ('Plot of input matrix pattern:')
DO 50 J = 1,N
DO 30 I = 1,N
A (I, J) = '.'
30 CONTINUE
C add the diagonal entry to the plot
A (J, J) = 'X'
DO 40 P = AP (J), AP (J+1) - 1
I = AI (P)
A (I, J) = 'X'
40 CONTINUE
50 CONTINUE
PRINT 60, ((MOD (J, 10)), J = 1,N)
60 FORMAT (' ', 24I2)
DO 80 I = 1,N
PRINT 70, I, (A (I, J), J = 1,N)
70 FORMAT (' ', I2, ': ', 24A2)
80 CONTINUE
DO 190 METHOD = 1,2
C load the matrix into AMD's workspace
DO 90 J = 1,N
PE (J) = AP (J)
LEN (J) = AP (J+1) - AP (J)
90 CONTINUE
DO 100 P = 1,NZ
IW (P) = AI (P)
100 CONTINUE
PFREE = NZ + 1
C order the matrix using AMD or AMDBAR
IF (METHOD .EQ. 1) THEN
PRINT 101
101 FORMAT (/, '------------------------------------------',
$ /, 'ordering the matrix with AMD',
$ /, '------------------------------------------')
CALL AMD (N, PE, IW, LEN, IWLEN, PFREE, NV, NEXT,
$ PERM, HEAD, PINV, DEGREE, NCMPA, W)
ELSE
PRINT 102
102 FORMAT (/, '------------------------------------------',
$ /, 'ordering the matrix with AMDBAR',
$ /, '------------------------------------------')
CALL AMDBAR (N, PE, IW, LEN, IWLEN, PFREE, NV, NEXT,
$ PERM, HEAD, PINV, DEGREE, NCMPA, W)
ENDIF
C print the permutation vector, PERM, and its inverse, PINV.
C row/column J = PERM (K) is the Kth row/column in the
C permuted matrix.
PRINT 110, (PERM (K), K = 1,N)
110 FORMAT (/, 'Permutation vector: ', /, 24I3)
PRINT 120, (PINV (J), J = 1,N)
120 FORMAT (/, 'Inverse permutation vector: ', /, 24I3)
C print a character plot of the permuted matrix.
PRINT 121
121 FORMAT ('Plot of permuted matrix pattern:')
DO 150 JNEW = 1,N
J = PERM (JNEW)
DO 130 INEW = 1,N
A (INEW, JNEW) = '.'
130 CONTINUE
C add the diagonal entry to the plot
A (JNEW, JNEW) = 'X'
DO 140 P = AP (J), AP (J+1) - 1
INEW = PINV (AI (P))
A (INEW, JNEW) = 'X'
140 CONTINUE
150 CONTINUE
PRINT 60, ((MOD (J, 10)), J = 1,N)
DO 160 I = 1,N
PRINT 70, I, (A (I, J), J = 1,N)
160 CONTINUE
C print the permuted matrix, PERM*A*PERM'
DO 180 JNEW = 1,N
J = PERM (JNEW)
PRINT 171, JNEW, J, AP (J+1) - AP (J)
171 FORMAT (/, 'New column: ', I2, ' old column: ', I2,
$ ' number of entries: ', I2)
PRINT 170, (PINV (AI (P)), P = AP (J), AP (J+1) - 1)
170 FORMAT (' new row indices: ', 24I3)
180 CONTINUE
190 CONTINUE
END
AMD Fortran 77 demo, with the 24-by-24 Harwell/Boeing matrix, can_24:
Input matrix: 24-by-24 with 136 entries
Note that the Fortran version of AMD requires that
no diagonal entries be present.
Column: 1 number of entries: 8 with row indices in AI ( 1 ... 8)
row indices: 6 7 13 14 18 19 20 22
Column: 2 number of entries: 5 with row indices in AI ( 9 ... 13)
row indices: 9 10 14 15 18
Column: 3 number of entries: 5 with row indices in AI ( 14 ... 18)
row indices: 7 12 21 22 23
Column: 4 number of entries: 5 with row indices in AI ( 19 ... 23)
row indices: 8 11 16 19 20
Column: 5 number of entries: 5 with row indices in AI ( 24 ... 28)
row indices: 8 10 15 16 17
Column: 6 number of entries: 5 with row indices in AI ( 29 ... 33)
row indices: 1 7 13 14 18
Column: 7 number of entries: 8 with row indices in AI ( 34 ... 41)
row indices: 1 3 6 12 13 20 22 24
Column: 8 number of entries: 8 with row indices in AI ( 42 ... 49)
row indices: 4 5 10 15 16 17 18 19
Column: 9 number of entries: 3 with row indices in AI ( 50 ... 52)
row indices: 2 10 15
Column: 10 number of entries: 8 with row indices in AI ( 53 ... 60)
row indices: 2 5 8 9 14 15 18 19
Column: 11 number of entries: 5 with row indices in AI ( 61 ... 65)
row indices: 4 19 20 21 22
Column: 12 number of entries: 5 with row indices in AI ( 66 ... 70)
row indices: 3 7 13 22 24
Column: 13 number of entries: 5 with row indices in AI ( 71 ... 75)
row indices: 1 6 7 12 24
Column: 14 number of entries: 5 with row indices in AI ( 76 ... 80)
row indices: 1 2 6 10 18
Column: 15 number of entries: 5 with row indices in AI ( 81 ... 85)
row indices: 2 5 8 9 10
Column: 16 number of entries: 5 with row indices in AI ( 86 ... 90)
row indices: 4 5 8 17 19
Column: 17 number of entries: 3 with row indices in AI ( 91 ... 93)
row indices: 5 8 16
Column: 18 number of entries: 8 with row indices in AI ( 94 ... 101)
row indices: 1 2 6 8 10 14 19 20
Column: 19 number of entries: 8 with row indices in AI (102 ... 109)
row indices: 1 4 8 10 11 16 18 20
Column: 20 number of entries: 8 with row indices in AI (110 ... 117)
row indices: 1 4 7 11 18 19 21 22
Column: 21 number of entries: 5 with row indices in AI (118 ... 122)
row indices: 3 11 20 22 23
Column: 22 number of entries: 8 with row indices in AI (123 ... 130)
row indices: 1 3 7 11 12 20 21 23
Column: 23 number of entries: 3 with row indices in AI (131 ... 133)
row indices: 3 21 22
Column: 24 number of entries: 3 with row indices in AI (134 ... 136)
row indices: 7 12 13
Plot of input matrix pattern:
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
1: X . . . . X X . . . . . X X . . . X X X . X . .
2: . X . . . . . . X X . . . X X . . X . . . . . .
3: . . X . . . X . . . . X . . . . . . . . X X X .
4: . . . X . . . X . . X . . . . X . . X X . . . .
5: . . . . X . . X . X . . . . X X X . . . . . . .
6: X . . . . X X . . . . . X X . . . X . . . . . .
7: X . X . . X X . . . . X X . . . . . . X . X . X
8: . . . X X . . X . X . . . . X X X X X . . . . .
9: . X . . . . . . X X . . . . X . . . . . . . . .
10: . X . . X . . X X X . . . X X . . X X . . . . .
11: . . . X . . . . . . X . . . . . . . X X X X . .
12: . . X . . . X . . . . X X . . . . . . . . X . X
13: X . . . . X X . . . . X X . . . . . . . . . . X
14: X X . . . X . . . X . . . X . . . X . . . . . .
15: . X . . X . . X X X . . . . X . . . . . . . . .
16: . . . X X . . X . . . . . . . X X . X . . . . .
17: . . . . X . . X . . . . . . . X X . . . . . . .
18: X X . . . X . X . X . . . X . . . X X X . . . .
19: X . . X . . . X . X X . . . . X . X X X . . . .
20: X . . X . . X . . . X . . . . . . X X X X X . .
21: . . X . . . . . . . X . . . . . . . . X X X X .
22: X . X . . . X . . . X X . . . . . . . X X X X .
23: . . X . . . . . . . . . . . . . . . . . X X X .
24: . . . . . . X . . . . X X . . . . . . . . . . X
------------------------------------------
ordering the matrix with AMD
------------------------------------------
Permutation vector:
24 23 17 9 15 5 21 13 6 11 16 8 2 10 14 18 1 3 4 19 7 12 22 20
Inverse permutation vector:
17 13 18 19 6 9 21 12 4 14 10 22 8 15 5 11 3 16 20 24 7 23 2 1
Plot of permuted matrix pattern:
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
1: X . . . . . . X . . . . . . . . . . . . X X . .
2: . X . . . . X . . . . . . . . . . X . . . . X .
3: . . X . . X . . . . X X . . . . . . . . . . . .
4: . . . X X . . . . . . . X X . . . . . . . . . .
5: . . . X X X . . . . . X X X . . . . . . . . . .
6: . . X . X X . . . . X X . X . . . . . . . . . .
7: . X . . . . X . . X . . . . . . . X . . . . X X
8: X . . . . . . X X . . . . . . . X . . . X X . .
9: . . . . . . . X X . . . . . X X X . . . X . . .
10: . . . . . . X . . X . . . . . . . . X X . . X X
11: . . X . . X . . . . X X . . . . . . X X . . . .
12: . . X . X X . . . . X X . X . X . . X X . . . .
13: . . . X X . . . . . . . X X X X . . . . . . . .
14: . . . X X X . . . . . X X X X X . . . X . . . .
15: . . . . . . . . X . . . X X X X X . . . . . . .
16: . . . . . . . . X . . X X X X X X . . X . . . X
17: . . . . . . . X X . . . . . X X X . . X X . X X
18: . X . . . . X . . . . . . . . . . X . . X X X .
19: . . . . . . . . . X X X . . . . . . X X . . . X
20: . . . . . . . . . X X X . X . X X . X X . . . X
21: X . . . . . . X X . . . . . . . X X . . X X X X
22: X . . . . . . X . . . . . . . . . X . . X X X .
23: . X . . . . X . . X . . . . . . X X . . X X X X
24: . . . . . . X . . X . . . . . X X . X X X . X X
New column: 1 old column: 24 number of entries: 3
new row indices: 21 22 8
New column: 2 old column: 23 number of entries: 3
new row indices: 18 7 23
New column: 3 old column: 17 number of entries: 3
new row indices: 6 12 11
New column: 4 old column: 9 number of entries: 3
new row indices: 13 14 5
New column: 5 old column: 15 number of entries: 5
new row indices: 13 6 12 4 14
New column: 6 old column: 5 number of entries: 5
new row indices: 12 14 5 11 3
New column: 7 old column: 21 number of entries: 5
new row indices: 18 10 24 23 2
New column: 8 old column: 13 number of entries: 5
new row indices: 17 9 21 22 1
New column: 9 old column: 6 number of entries: 5
new row indices: 17 21 8 15 16
New column: 10 old column: 11 number of entries: 5
new row indices: 19 20 24 7 23
New column: 11 old column: 16 number of entries: 5
new row indices: 19 6 12 3 20
New column: 12 old column: 8 number of entries: 8
new row indices: 19 6 14 5 11 3 16 20
New column: 13 old column: 2 number of entries: 5
new row indices: 4 14 15 5 16
New column: 14 old column: 10 number of entries: 8
new row indices: 13 6 12 4 15 5 16 20
New column: 15 old column: 14 number of entries: 5
new row indices: 17 13 9 14 16
New column: 16 old column: 18 number of entries: 8
new row indices: 17 13 9 12 14 15 20 24
New column: 17 old column: 1 number of entries: 8
new row indices: 9 21 8 15 16 20 24 23
New column: 18 old column: 3 number of entries: 5
new row indices: 21 22 7 23 2
New column: 19 old column: 4 number of entries: 5
new row indices: 12 10 11 20 24
New column: 20 old column: 19 number of entries: 8
new row indices: 17 19 12 14 10 11 16 24
New column: 21 old column: 7 number of entries: 8
new row indices: 17 18 9 22 8 24 23 1
New column: 22 old column: 12 number of entries: 5
new row indices: 18 21 8 23 1
New column: 23 old column: 22 number of entries: 8
new row indices: 17 18 21 10 22 24 7 2
New column: 24 old column: 20 number of entries: 8
new row indices: 17 19 21 10 16 20 7 23
------------------------------------------
ordering the matrix with AMDBAR
------------------------------------------
Permutation vector:
24 23 17 9 15 5 21 13 6 11 16 8 2 10 14 18 1 3 4 19 7 12 22 20
Inverse permutation vector:
17 13 18 19 6 9 21 12 4 14 10 22 8 15 5 11 3 16 20 24 7 23 2 1
Plot of permuted matrix pattern:
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
1: X . . . . . . X . . . . . . . . . . . . X X . .
2: . X . . . . X . . . . . . . . . . X . . . . X .
3: . . X . . X . . . . X X . . . . . . . . . . . .
4: . . . X X . . . . . . . X X . . . . . . . . . .
5: . . . X X X . . . . . X X X . . . . . . . . . .
6: . . X . X X . . . . X X . X . . . . . . . . . .
7: . X . . . . X . . X . . . . . . . X . . . . X X
8: X . . . . . . X X . . . . . . . X . . . X X . .
9: . . . . . . . X X . . . . . X X X . . . X . . .
10: . . . . . . X . . X . . . . . . . . X X . . X X
11: . . X . . X . . . . X X . . . . . . X X . . . .
12: . . X . X X . . . . X X . X . X . . X X . . . .
13: . . . X X . . . . . . . X X X X . . . . . . . .
14: . . . X X X . . . . . X X X X X . . . X . . . .
15: . . . . . . . . X . . . X X X X X . . . . . . .
16: . . . . . . . . X . . X X X X X X . . X . . . X
17: . . . . . . . X X . . . . . X X X . . X X . X X
18: . X . . . . X . . . . . . . . . . X . . X X X .
19: . . . . . . . . . X X X . . . . . . X X . . . X
20: . . . . . . . . . X X X . X . X X . X X . . . X
21: X . . . . . . X X . . . . . . . X X . . X X X X
22: X . . . . . . X . . . . . . . . . X . . X X X .
23: . X . . . . X . . X . . . . . . X X . . X X X X
24: . . . . . . X . . X . . . . . X X . X X X . X X
New column: 1 old column: 24 number of entries: 3
new row indices: 21 22 8
New column: 2 old column: 23 number of entries: 3
new row indices: 18 7 23
New column: 3 old column: 17 number of entries: 3
new row indices: 6 12 11
New column: 4 old column: 9 number of entries: 3
new row indices: 13 14 5
New column: 5 old column: 15 number of entries: 5
new row indices: 13 6 12 4 14
New column: 6 old column: 5 number of entries: 5
new row indices: 12 14 5 11 3
New column: 7 old column: 21 number of entries: 5
new row indices: 18 10 24 23 2
New column: 8 old column: 13 number of entries: 5
new row indices: 17 9 21 22 1
New column: 9 old column: 6 number of entries: 5
new row indices: 17 21 8 15 16
New column: 10 old column: 11 number of entries: 5
new row indices: 19 20 24 7 23
New column: 11 old column: 16 number of entries: 5
new row indices: 19 6 12 3 20
New column: 12 old column: 8 number of entries: 8
new row indices: 19 6 14 5 11 3 16 20
New column: 13 old column: 2 number of entries: 5
new row indices: 4 14 15 5 16
New column: 14 old column: 10 number of entries: 8
new row indices: 13 6 12 4 15 5 16 20
New column: 15 old column: 14 number of entries: 5
new row indices: 17 13 9 14 16
New column: 16 old column: 18 number of entries: 8
new row indices: 17 13 9 12 14 15 20 24
New column: 17 old column: 1 number of entries: 8
new row indices: 9 21 8 15 16 20 24 23
New column: 18 old column: 3 number of entries: 5
new row indices: 21 22 7 23 2
New column: 19 old column: 4 number of entries: 5
new row indices: 12 10 11 20 24
New column: 20 old column: 19 number of entries: 8
new row indices: 17 19 12 14 10 11 16 24
New column: 21 old column: 7 number of entries: 8
new row indices: 17 18 9 22 8 24 23 1
New column: 22 old column: 12 number of entries: 5
new row indices: 18 21 8 23 1
New column: 23 old column: 22 number of entries: 8
new row indices: 17 18 21 10 22 24 7 2
New column: 24 old column: 20 number of entries: 8
new row indices: 17 19 21 10 16 20 7 23
C ----------------------------------------------------------------------
C AMD, Copyright (c) by Timothy A. Davis, Patrick R.
C Amestoy, and Iain S. Duff. See ../README.txt for License.
C email: DrTimothyAldenDavis@gmail.com
C ----------------------------------------------------------------------
C This program provides an example of how to call the Fortran version
C of AMD. It uses the same matrix as the amd_simple.c demo (in C).
C Note that the diagonal entries are not present, and the matrix is
C symmetric.
INTEGER N, NZ, J, K, P, IWLEN, PFREE, NCMPA
PARAMETER (N = 5, NZ = 10, IWLEN = 17)
INTEGER AP (N+1), AI (NZ), LAST (N), PE (N), LEN (N), ELEN (N),
$ IW (IWLEN), DEGREE (N), NV (N), NEXT (N), HEAD (N), W (N)
DATA AP / 1, 2, 5, 8, 9, 11/
DATA AI / 2, 1,3,5, 2,4,5, 3, 2,3 /
C load the matrix into the AMD workspace
DO 10 J = 1,N
PE (J) = AP (J)
LEN (J) = AP (J+1) - AP (J)
10 CONTINUE
DO 20 P = 1,NZ
IW (P) = AI (P)
20 CONTINUE
PFREE = NZ + 1
C order the matrix (destroys the copy of A in IW, PE, and LEN)
CALL AMD (N, PE, IW, LEN, IWLEN, PFREE, NV, NEXT, LAST, HEAD,
$ ELEN, DEGREE, NCMPA, W)
DO 60 K = 1, N
PRINT 50, K, LAST (K)
50 FORMAT ('P (',I2,') = ', I2)
60 CONTINUE
END
P ( 1) = 4
P ( 2) = 1
P ( 3) = 3
P ( 4) = 5
P ( 5) = 2
/* ========================================================================= */
/* === amd_f77wrapper ====================================================== */
/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/* AMD Copyright (c) by Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: DrTimothyAldenDavis@gmail.com */
/* ------------------------------------------------------------------------- */
/* Fortran interface for the C-callable AMD library (int version only). This
* is HIGHLY non-portable. You will need to modify this depending on how your
* Fortran and C compilers behave. Two examples are provided.
*
* To avoid using I/O, and to avoid the extra porting step of a Fortran
* function, the status code is returned as the first entry in P (P [0] in C
* and P (1) in Fortran) if an error occurs. The error codes are negative
* (-1: out of memory, -2: invalid matrix).
*
* For some C and Fortran compilers, the Fortran compiler appends a single "_"
* after each routine name. C doesn't do this, so the translation is made
* here. Some Fortran compilers don't append an underscore (xlf on IBM AIX,
* for * example).
*
* Tested with the following compilers:
* Solaris with cc and f77 from Sun WorkShop 6 update 1.
* SGI Irix with MIPSpro cc and f77 compilers version 7.4
* Linux with GNU gcc or Intel's icc, and GNU g77 Intel's ifc Fortran compiler.
* (any combination). Note that with g77, a call to amd_order in Fortran
* gets translated to a call to amd_order__, with two underscores ("_").
* Thus, the Fortran names do not include an underscore.
*/
#include "amd.h"
#include <stdio.h>
/* ------------------------------------------------------------------------- */
/* Linux, Solaris, SGI */
/* ------------------------------------------------------------------------- */
void amdorder_ (int *n, const int *Ap, const int *Ai, int *P,
double *Control, double *Info)
{
int result = amd_order (*n, Ap, Ai, P, Control, Info) ;
if (result != AMD_OK && P) P [0] = result ;
}
void amddefaults_ (double *Control)
{
amd_defaults (Control) ;
}
void amdcontrol_ (double *Control)
{
fflush (stdout) ;
amd_control (Control) ;
fflush (stdout) ;
}
void amdinfo_ (double *Info)
{
fflush (stdout) ;
amd_info (Info) ;
fflush (stdout) ;
}
/* ------------------------------------------------------------------------- */
/* IBM AIX. Probably Windows, Compaq Alpha, and HP Unix as well. */
/* ------------------------------------------------------------------------- */
void amdorder (int *n, const int *Ap, const int *Ai, int *P,
double *Control, double *Info)
{
int result = amd_order (*n, Ap, Ai, P, Control, Info) ;
if (result != AMD_OK && P) P [0] = result ;
}
void amddefaults (double *Control)
{
amd_defaults (Control) ;
}
void amdcontrol (double *Control)
{
fflush (stdout) ;
amd_control (Control) ;
fflush (stdout) ;
}
void amdinfo (double *Info)
{
fflush (stdout) ;
amd_info (Info) ;
fflush (stdout) ;
}
/* ========================================================================= */
/* === AMD demo main program (long integer version) ======================== */
/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/* AMD Copyright (c) by Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: DrTimothyAldenDavis@gmail.com */
/* ------------------------------------------------------------------------- */
/* A simple C main program that illustrates the use of the ANSI C interface
* to AMD.
*/
#include "amd.h"
#include <stdio.h>
#include <stdlib.h>
#define Long SuiteSparse_long
int main (void)
{
/* The symmetric can_24 Harwell/Boeing matrix, including upper and lower
* triangular parts, and the diagonal entries. Note that this matrix is
* 0-based, with row and column indices in the range 0 to n-1. */
Long n = 24, nz,
Ap [ ] = { 0, 9, 15, 21, 27, 33, 39, 48, 57, 61, 70, 76, 82, 88, 94, 100,
106, 110, 119, 128, 137, 143, 152, 156, 160 },
Ai [ ] = {
/* column 0: */ 0, 5, 6, 12, 13, 17, 18, 19, 21,
/* column 1: */ 1, 8, 9, 13, 14, 17,
/* column 2: */ 2, 6, 11, 20, 21, 22,
/* column 3: */ 3, 7, 10, 15, 18, 19,
/* column 4: */ 4, 7, 9, 14, 15, 16,
/* column 5: */ 0, 5, 6, 12, 13, 17,
/* column 6: */ 0, 2, 5, 6, 11, 12, 19, 21, 23,
/* column 7: */ 3, 4, 7, 9, 14, 15, 16, 17, 18,
/* column 8: */ 1, 8, 9, 14,
/* column 9: */ 1, 4, 7, 8, 9, 13, 14, 17, 18,
/* column 10: */ 3, 10, 18, 19, 20, 21,
/* column 11: */ 2, 6, 11, 12, 21, 23,
/* column 12: */ 0, 5, 6, 11, 12, 23,
/* column 13: */ 0, 1, 5, 9, 13, 17,
/* column 14: */ 1, 4, 7, 8, 9, 14,
/* column 15: */ 3, 4, 7, 15, 16, 18,
/* column 16: */ 4, 7, 15, 16,
/* column 17: */ 0, 1, 5, 7, 9, 13, 17, 18, 19,
/* column 18: */ 0, 3, 7, 9, 10, 15, 17, 18, 19,
/* column 19: */ 0, 3, 6, 10, 17, 18, 19, 20, 21,
/* column 20: */ 2, 10, 19, 20, 21, 22,
/* column 21: */ 0, 2, 6, 10, 11, 19, 20, 21, 22,
/* column 22: */ 2, 20, 21, 22,
/* column 23: */ 6, 11, 12, 23 } ;
Long P [24], Pinv [24], i, j, k, jnew, p, inew, result ;
double Control [AMD_CONTROL], Info [AMD_INFO] ;
char A [24][24] ;
/* here is an example of how to use AMD_VERSION. This code will work in
* any version of AMD. */
#if defined(AMD_VERSION) && (AMD_VERSION >= AMD_VERSION_CODE(1,2))
printf ("AMD version %d.%d.%d, date: %s\n",
AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE) ;
#else
printf ("AMD version: 1.1 or earlier\n") ;
#endif
printf ("AMD demo, with the 24-by-24 Harwell/Boeing matrix, can_24:\n") ;
/* get the default parameters, and print them */
amd_l_defaults (Control) ;
amd_l_control (Control) ;
/* print the input matrix */
nz = Ap [n] ;
printf ("\nInput matrix: %ld-by-%ld, with %ld entries.\n"
" Note that for a symmetric matrix such as this one, only the\n"
" strictly lower or upper triangular parts would need to be\n"
" passed to AMD, since AMD computes the ordering of A+A'. The\n"
" diagonal entries are also not needed, since AMD ignores them.\n"
, n, n, nz) ;
for (j = 0 ; j < n ; j++)
{
printf ("\nColumn: %ld, number of entries: %ld, with row indices in"
" Ai [%ld ... %ld]:\n row indices:",
j, Ap [j+1] - Ap [j], Ap [j], Ap [j+1]-1) ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
printf (" %ld", i) ;
}
printf ("\n") ;
}
/* print a character plot of the input matrix. This is only reasonable
* because the matrix is small. */
printf ("\nPlot of input matrix pattern:\n") ;
for (j = 0 ; j < n ; j++)
{
for (i = 0 ; i < n ; i++) A [i][j] = '.' ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
A [i][j] = 'X' ;
}
}
printf (" ") ;
for (j = 0 ; j < n ; j++) printf (" %1ld", j % 10) ;
printf ("\n") ;
for (i = 0 ; i < n ; i++)
{
printf ("%2ld: ", i) ;
for (j = 0 ; j < n ; j++)
{
printf (" %c", A [i][j]) ;
}
printf ("\n") ;
}
/* order the matrix */
result = amd_l_order (n, Ap, Ai, P, Control, Info) ;
printf ("return value from amd_l_order: %ld (should be %d)\n",
result, AMD_OK) ;
/* print the statistics */
amd_l_info (Info) ;
if (result != AMD_OK)
{
printf ("AMD failed\n") ;
exit (1) ;
}
/* print the permutation vector, P, and compute the inverse permutation */
printf ("Permutation vector:\n") ;
for (k = 0 ; k < n ; k++)
{
/* row/column j is the kth row/column in the permuted matrix */
j = P [k] ;
Pinv [j] = k ;
printf (" %2ld", j) ;
}
printf ("\n\n") ;
printf ("Inverse permutation vector:\n") ;
for (j = 0 ; j < n ; j++)
{
k = Pinv [j] ;
printf (" %2ld", k) ;
}
printf ("\n\n") ;
/* print a character plot of the permuted matrix. */
printf ("\nPlot of permuted matrix pattern:\n") ;
for (jnew = 0 ; jnew < n ; jnew++)
{
j = P [jnew] ;
for (inew = 0 ; inew < n ; inew++) A [inew][jnew] = '.' ;
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
inew = Pinv [Ai [p]] ;
A [inew][jnew] = 'X' ;
}
}
printf (" ") ;
for (j = 0 ; j < n ; j++) printf (" %1ld", j % 10) ;
printf ("\n") ;
for (i = 0 ; i < n ; i++)
{
printf ("%2ld: ", i) ;
for (j = 0 ; j < n ; j++)
{
printf (" %c", A [i][j]) ;
}
printf ("\n") ;
}
return (0) ;
}
AMD version 2.4.1, date: Oct 10, 2014
AMD demo, with the 24-by-24 Harwell/Boeing matrix, can_24:
AMD version 2.4.1, Oct 10, 2014: approximate minimum degree ordering
dense row parameter: 10
(rows with more than max (10 * sqrt (n), 16) entries are
considered "dense", and placed last in output permutation)
aggressive absorption: yes
size of AMD integer: 8
Input matrix: 24-by-24, with 160 entries.
Note that for a symmetric matrix such as this one, only the
strictly lower or upper triangular parts would need to be
passed to AMD, since AMD computes the ordering of A+A'. The
diagonal entries are also not needed, since AMD ignores them.
Column: 0, number of entries: 9, with row indices in Ai [0 ... 8]:
row indices: 0 5 6 12 13 17 18 19 21
Column: 1, number of entries: 6, with row indices in Ai [9 ... 14]:
row indices: 1 8 9 13 14 17
Column: 2, number of entries: 6, with row indices in Ai [15 ... 20]:
row indices: 2 6 11 20 21 22
Column: 3, number of entries: 6, with row indices in Ai [21 ... 26]:
row indices: 3 7 10 15 18 19
Column: 4, number of entries: 6, with row indices in Ai [27 ... 32]:
row indices: 4 7 9 14 15 16
Column: 5, number of entries: 6, with row indices in Ai [33 ... 38]:
row indices: 0 5 6 12 13 17
Column: 6, number of entries: 9, with row indices in Ai [39 ... 47]:
row indices: 0 2 5 6 11 12 19 21 23
Column: 7, number of entries: 9, with row indices in Ai [48 ... 56]:
row indices: 3 4 7 9 14 15 16 17 18
Column: 8, number of entries: 4, with row indices in Ai [57 ... 60]:
row indices: 1 8 9 14
Column: 9, number of entries: 9, with row indices in Ai [61 ... 69]:
row indices: 1 4 7 8 9 13 14 17 18
Column: 10, number of entries: 6, with row indices in Ai [70 ... 75]:
row indices: 3 10 18 19 20 21
Column: 11, number of entries: 6, with row indices in Ai [76 ... 81]:
row indices: 2 6 11 12 21 23
Column: 12, number of entries: 6, with row indices in Ai [82 ... 87]:
row indices: 0 5 6 11 12 23
Column: 13, number of entries: 6, with row indices in Ai [88 ... 93]:
row indices: 0 1 5 9 13 17
Column: 14, number of entries: 6, with row indices in Ai [94 ... 99]:
row indices: 1 4 7 8 9 14
Column: 15, number of entries: 6, with row indices in Ai [100 ... 105]:
row indices: 3 4 7 15 16 18
Column: 16, number of entries: 4, with row indices in Ai [106 ... 109]:
row indices: 4 7 15 16
Column: 17, number of entries: 9, with row indices in Ai [110 ... 118]:
row indices: 0 1 5 7 9 13 17 18 19
Column: 18, number of entries: 9, with row indices in Ai [119 ... 127]:
row indices: 0 3 7 9 10 15 17 18 19
Column: 19, number of entries: 9, with row indices in Ai [128 ... 136]:
row indices: 0 3 6 10 17 18 19 20 21
Column: 20, number of entries: 6, with row indices in Ai [137 ... 142]:
row indices: 2 10 19 20 21 22
Column: 21, number of entries: 9, with row indices in Ai [143 ... 151]:
row indices: 0 2 6 10 11 19 20 21 22
Column: 22, number of entries: 4, with row indices in Ai [152 ... 155]:
row indices: 2 20 21 22
Column: 23, number of entries: 4, with row indices in Ai [156 ... 159]:
row indices: 6 11 12 23
Plot of input matrix pattern:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
0: X . . . . X X . . . . . X X . . . X X X . X . .
1: . X . . . . . . X X . . . X X . . X . . . . . .
2: . . X . . . X . . . . X . . . . . . . . X X X .
3: . . . X . . . X . . X . . . . X . . X X . . . .
4: . . . . X . . X . X . . . . X X X . . . . . . .
5: X . . . . X X . . . . . X X . . . X . . . . . .
6: X . X . . X X . . . . X X . . . . . . X . X . X
7: . . . X X . . X . X . . . . X X X X X . . . . .
8: . X . . . . . . X X . . . . X . . . . . . . . .
9: . X . . X . . X X X . . . X X . . X X . . . . .
10: . . . X . . . . . . X . . . . . . . X X X X . .
11: . . X . . . X . . . . X X . . . . . . . . X . X
12: X . . . . X X . . . . X X . . . . . . . . . . X
13: X X . . . X . . . X . . . X . . . X . . . . . .
14: . X . . X . . X X X . . . . X . . . . . . . . .
15: . . . X X . . X . . . . . . . X X . X . . . . .
16: . . . . X . . X . . . . . . . X X . . . . . . .
17: X X . . . X . X . X . . . X . . . X X X . . . .
18: X . . X . . . X . X X . . . . X . X X X . . . .
19: X . . X . . X . . . X . . . . . . X X X X X . .
20: . . X . . . . . . . X . . . . . . . . X X X X .
21: X . X . . . X . . . X X . . . . . . . X X X X .
22: . . X . . . . . . . . . . . . . . . . . X X X .
23: . . . . . . X . . . . X X . . . . . . . . . . X
return value from amd_l_order: 0 (should be 0)
AMD version 2.4.1, Oct 10, 2014, results:
status: OK
n, dimension of A: 24
nz, number of nonzeros in A: 160
symmetry of A: 1.0000
number of nonzeros on diagonal: 24
nonzeros in pattern of A+A' (excl. diagonal): 136
# dense rows/columns of A+A': 0
memory used, in bytes: 3032
# of memory compactions: 0
The following approximate statistics are for a subsequent
factorization of A(P,P) + A(P,P)'. They are slight upper
bounds if there are no dense rows/columns in A+A', and become
looser if dense rows/columns exist.
nonzeros in L (excluding diagonal): 97
nonzeros in L (including diagonal): 121
# divide operations for LDL' or LU: 97
# multiply-subtract operations for LDL': 275
# multiply-subtract operations for LU: 453
max nz. in any column of L (incl. diagonal): 8
chol flop count for real A, sqrt counted as 1 flop: 671
LDL' flop count for real A: 647
LDL' flop count for complex A: 3073
LU flop count for real A (with no pivoting): 1003
LU flop count for complex A (with no pivoting): 4497
Permutation vector:
22 20 10 23 12 5 16 8 14 4 15 7 1 9 13 17 0 2 3 6 11 18 21 19
Inverse permutation vector:
16 12 17 18 9 5 19 11 7 13 2 20 4 14 8 10 6 15 21 23 1 22 0 3
Plot of permuted matrix pattern:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
0: X X . . . . . . . . . . . . . . . X . . . . X .
1: X X X . . . . . . . . . . . . . . X . . . . X X
2: . X X . . . . . . . . . . . . . . . X . . X X X
3: . . . X X . . . . . . . . . . . . . . X X . . .
4: . . . X X X . . . . . . . . . . X . . X X . . .
5: . . . . X X . . . . . . . . X X X . . X . . . .
6: . . . . . . X . . X X X . . . . . . . . . . . .
7: . . . . . . . X X . . . X X . . . . . . . . . .
8: . . . . . . . X X X . X X X . . . . . . . . . .
9: . . . . . . X . X X X X . X . . . . . . . . . .
10: . . . . . . X . . X X X . . . . . . X . . X . .
11: . . . . . . X . X X X X . X . X . . X . . X . .
12: . . . . . . . X X . . . X X X X . . . . . . . .
13: . . . . . . . X X X . X X X X X . . . . . X . .
14: . . . . . X . . . . . . X X X X X . . . . . . .
15: . . . . . X . . . . . X X X X X X . . . . X . X
16: . . . . X X . . . . . . . . X X X . . X . X X X
17: X X . . . . . . . . . . . . . . . X . X X . X .
18: . . X . . . . . . . X X . . . . . . X . . X . X
19: . . . X X X . . . . . . . . . . X X . X X . X X
20: . . . X X . . . . . . . . . . . . X . X X . X .
21: . . X . . . . . . . X X . X . X X . X . . X . X
22: X X X . . . . . . . . . . . . . X X . X X . X X
23: . X X . . . . . . . . . . . . X X . X X . X X X
/* ------------------------------------------------------------------------- */
/* AMD Copyright (c) by Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: DrTimothyAldenDavis@gmail.com */
/* ------------------------------------------------------------------------- */
#include <stdio.h>
#include "amd.h"
int n = 5 ;
int Ap [ ] = { 0, 2, 6, 10, 12, 14} ;
int Ai [ ] = { 0,1, 0,1,2,4, 1,2,3,4, 2,3, 1,4 } ;
int P [5] ;
int main (void)
{
int k ;
(void) amd_order (n, Ap, Ai, P, (double *) NULL, (double *) NULL) ;
for (k = 0 ; k < n ; k++) printf ("P [%d] = %d\n", k, P [k]) ;
return (0) ;
}
P [0] = 0
P [1] = 3
P [2] = 2
P [3] = 4
P [4] = 1
@string{SIREV = "{SIAM} Review"}
@string{SIMAX = "{SIAM} J. Matrix Anal. Applic."}
@string{SIAMJSC = "{SIAM} J. Sci. Comput."}
@string{TOMS = "{ACM} Trans. Math. Softw."}
@article{schu:01,
author = {J. Schulze},
title = {Towards a tighter coupling of bottom-up and top-down sparse matrix ordering methods},
journal = {BIT},
volume = {41},
number = {4},
pages = "800--841",
year = {2001}
}
@article{GeorgeLiu89,
author={George, A. and Liu, J. W. H.},
year={1989},
title={The Evolution of the Minimum Degree Ordering Algorithm},
journal=SIREV,
volume={31},
number={1},
pages={1--19}}
@article{AmestoyDavisDuff96,
author={Amestoy, P. R. and Davis, T. A. and Duff, I. S.},
title={An approximate minimum degree ordering algorithm},
journal=SIMAX,
year={1996}
,volume={17}
,number={4}
,pages={886-905}
}
@article{AmestoyDavisDuff04,
author={Amestoy, P. R. and Davis, T. A. and Duff, I. S.},
title={Algorithm 837: An approximate minimum degree ordering algorithm},
journal=TOMS,
year={2004}
,volume={30}
,number={3}
,pages={381-388}
}
@misc{hsl:2002,
author = {HSL},
title = "{HSL} 2002: {A} collection of {F}ortran codes for large
scale scientific computation",
note = {{\tt www.cse.clrc.ac.uk/nag/hsl}},
year = 2002}
@article{RothbergEisenstat98,
author={Rothberg, E. and Eisenstat, S. C.},
title={Node selection strategies for bottom-up sparse matrix orderings},
journal=SIMAX,
year={1998}
,volume={19}
,number={3}
,pages={682-695}
}
@article{KarypisKumar98e,
author={Karypis, G. and Kumar, V.},
title={A fast and high quality multilevel scheme for partitioning irregular graphs},
journal=SIAMJSC,
year={1998}
,volume={20}
,pages={359-392}
}
@article{Chaco,
author={B. Hendrickson and E. Rothberg},
title={Improving the runtime and quality of nested dissection ordering},
journal=SIAMJSC,
year={1999}
,volume={20}
,pages={468--489}
}
@article{PellegriniRomanAmestoy00,
author={Pellegrini, F. and Roman, J. and Amestoy, P.},
title={Hybridizing nested dissection and halo approximate minimum degree for efficient sparse matrix ordering},
journal={Concurrency: Practice and Experience},
year={2000}
,volume={12}
,pages={68-84}
}
@article{DavisGilbertLarimoreNg04,
author={Davis, T. A. and Gilbert, J. R. and Larimore, S. I. and Ng, E. G.},
title={A column approximate minimum degree ordering algorithm},
journal=TOMS,
year={2004}
,volume={30}
,pages={353-376}
}
File added
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment