scs 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +84 -0
  5. data/ext/scs/Rakefile +11 -0
  6. data/lib/scs/ffi.rb +117 -0
  7. data/lib/scs/solver.rb +178 -0
  8. data/lib/scs/version.rb +3 -0
  9. data/lib/scs.rb +17 -0
  10. data/vendor/scs/LICENSE.txt +21 -0
  11. data/vendor/scs/Makefile +164 -0
  12. data/vendor/scs/README.md +220 -0
  13. data/vendor/scs/include/aa.h +56 -0
  14. data/vendor/scs/include/cones.h +46 -0
  15. data/vendor/scs/include/ctrlc.h +33 -0
  16. data/vendor/scs/include/glbopts.h +177 -0
  17. data/vendor/scs/include/linalg.h +26 -0
  18. data/vendor/scs/include/linsys.h +64 -0
  19. data/vendor/scs/include/normalize.h +18 -0
  20. data/vendor/scs/include/rw.h +17 -0
  21. data/vendor/scs/include/scs.h +161 -0
  22. data/vendor/scs/include/scs_blas.h +51 -0
  23. data/vendor/scs/include/util.h +65 -0
  24. data/vendor/scs/linsys/amatrix.c +305 -0
  25. data/vendor/scs/linsys/amatrix.h +36 -0
  26. data/vendor/scs/linsys/amatrix.o +0 -0
  27. data/vendor/scs/linsys/cpu/direct/private.c +366 -0
  28. data/vendor/scs/linsys/cpu/direct/private.h +26 -0
  29. data/vendor/scs/linsys/cpu/direct/private.o +0 -0
  30. data/vendor/scs/linsys/cpu/indirect/private.c +256 -0
  31. data/vendor/scs/linsys/cpu/indirect/private.h +31 -0
  32. data/vendor/scs/linsys/cpu/indirect/private.o +0 -0
  33. data/vendor/scs/linsys/external/amd/LICENSE.txt +934 -0
  34. data/vendor/scs/linsys/external/amd/SuiteSparse_config.c +469 -0
  35. data/vendor/scs/linsys/external/amd/SuiteSparse_config.h +254 -0
  36. data/vendor/scs/linsys/external/amd/SuiteSparse_config.o +0 -0
  37. data/vendor/scs/linsys/external/amd/amd.h +400 -0
  38. data/vendor/scs/linsys/external/amd/amd_1.c +180 -0
  39. data/vendor/scs/linsys/external/amd/amd_1.o +0 -0
  40. data/vendor/scs/linsys/external/amd/amd_2.c +1842 -0
  41. data/vendor/scs/linsys/external/amd/amd_2.o +0 -0
  42. data/vendor/scs/linsys/external/amd/amd_aat.c +184 -0
  43. data/vendor/scs/linsys/external/amd/amd_aat.o +0 -0
  44. data/vendor/scs/linsys/external/amd/amd_control.c +64 -0
  45. data/vendor/scs/linsys/external/amd/amd_control.o +0 -0
  46. data/vendor/scs/linsys/external/amd/amd_defaults.c +37 -0
  47. data/vendor/scs/linsys/external/amd/amd_defaults.o +0 -0
  48. data/vendor/scs/linsys/external/amd/amd_dump.c +179 -0
  49. data/vendor/scs/linsys/external/amd/amd_dump.o +0 -0
  50. data/vendor/scs/linsys/external/amd/amd_global.c +16 -0
  51. data/vendor/scs/linsys/external/amd/amd_global.o +0 -0
  52. data/vendor/scs/linsys/external/amd/amd_info.c +119 -0
  53. data/vendor/scs/linsys/external/amd/amd_info.o +0 -0
  54. data/vendor/scs/linsys/external/amd/amd_internal.h +304 -0
  55. data/vendor/scs/linsys/external/amd/amd_order.c +199 -0
  56. data/vendor/scs/linsys/external/amd/amd_order.o +0 -0
  57. data/vendor/scs/linsys/external/amd/amd_post_tree.c +120 -0
  58. data/vendor/scs/linsys/external/amd/amd_post_tree.o +0 -0
  59. data/vendor/scs/linsys/external/amd/amd_postorder.c +206 -0
  60. data/vendor/scs/linsys/external/amd/amd_postorder.o +0 -0
  61. data/vendor/scs/linsys/external/amd/amd_preprocess.c +118 -0
  62. data/vendor/scs/linsys/external/amd/amd_preprocess.o +0 -0
  63. data/vendor/scs/linsys/external/amd/amd_valid.c +92 -0
  64. data/vendor/scs/linsys/external/amd/amd_valid.o +0 -0
  65. data/vendor/scs/linsys/external/amd/changes +11 -0
  66. data/vendor/scs/linsys/external/qdldl/LICENSE +201 -0
  67. data/vendor/scs/linsys/external/qdldl/README.md +120 -0
  68. data/vendor/scs/linsys/external/qdldl/changes +4 -0
  69. data/vendor/scs/linsys/external/qdldl/qdldl.c +298 -0
  70. data/vendor/scs/linsys/external/qdldl/qdldl.h +177 -0
  71. data/vendor/scs/linsys/external/qdldl/qdldl.o +0 -0
  72. data/vendor/scs/linsys/external/qdldl/qdldl_types.h +21 -0
  73. data/vendor/scs/linsys/gpu/gpu.c +41 -0
  74. data/vendor/scs/linsys/gpu/gpu.h +85 -0
  75. data/vendor/scs/linsys/gpu/indirect/private.c +304 -0
  76. data/vendor/scs/linsys/gpu/indirect/private.h +36 -0
  77. data/vendor/scs/scs.mk +181 -0
  78. data/vendor/scs/src/aa.c +224 -0
  79. data/vendor/scs/src/aa.o +0 -0
  80. data/vendor/scs/src/cones.c +802 -0
  81. data/vendor/scs/src/cones.o +0 -0
  82. data/vendor/scs/src/ctrlc.c +77 -0
  83. data/vendor/scs/src/ctrlc.o +0 -0
  84. data/vendor/scs/src/linalg.c +84 -0
  85. data/vendor/scs/src/linalg.o +0 -0
  86. data/vendor/scs/src/normalize.c +93 -0
  87. data/vendor/scs/src/normalize.o +0 -0
  88. data/vendor/scs/src/rw.c +167 -0
  89. data/vendor/scs/src/rw.o +0 -0
  90. data/vendor/scs/src/scs.c +975 -0
  91. data/vendor/scs/src/scs.o +0 -0
  92. data/vendor/scs/src/scs_version.c +5 -0
  93. data/vendor/scs/src/scs_version.o +0 -0
  94. data/vendor/scs/src/util.c +196 -0
  95. data/vendor/scs/src/util.o +0 -0
  96. data/vendor/scs/test/data/small_random_socp +0 -0
  97. data/vendor/scs/test/minunit.h +13 -0
  98. data/vendor/scs/test/problem_utils.h +93 -0
  99. data/vendor/scs/test/problems/rob_gauss_cov_est.h +85 -0
  100. data/vendor/scs/test/problems/small_lp.h +50 -0
  101. data/vendor/scs/test/problems/small_random_socp.h +33 -0
  102. data/vendor/scs/test/random_socp_prob.c +171 -0
  103. data/vendor/scs/test/run_from_file.c +69 -0
  104. data/vendor/scs/test/run_tests +2 -0
  105. data/vendor/scs/test/run_tests.c +32 -0
  106. metadata +203 -0
@@ -0,0 +1,184 @@
1
+ /* ========================================================================= */
2
+ /* === AMD_aat ============================================================= */
3
+ /* ========================================================================= */
4
+
5
+ /* ------------------------------------------------------------------------- */
6
+ /* AMD, Copyright (c) Timothy A. Davis, */
7
+ /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8
+ /* email: DrTimothyAldenDavis@gmail.com */
9
+ /* ------------------------------------------------------------------------- */
10
+
11
+ /* AMD_aat: compute the symmetry of the pattern of A, and count the number of
12
+ * nonzeros each column of A+A' (excluding the diagonal). Assumes the input
13
+ * matrix has no errors, with sorted columns and no duplicates
14
+ * (AMD_valid (n, n, Ap, Ai) must be AMD_OK, but this condition is not
15
+ * checked).
16
+ */
17
+
18
+ #include "amd_internal.h"
19
+
20
+ GLOBAL size_t AMD_aat /* returns nz in A+A' */
21
+ (
22
+ Int n,
23
+ const Int Ap [ ],
24
+ const Int Ai [ ],
25
+ Int Len [ ], /* Len [j]: length of column j of A+A', excl diagonal*/
26
+ Int Tp [ ], /* workspace of size n */
27
+ scs_float Info [ ]
28
+ )
29
+ {
30
+ Int p1, p2, p, i, j, pj, pj2, k, nzdiag, nzboth, nz ;
31
+ scs_float sym ;
32
+ size_t nzaat ;
33
+
34
+ #ifndef NDEBUG
35
+ AMD_debug_init ("AMD AAT") ;
36
+ for (k = 0 ; k < n ; k++) Tp [k] = EMPTY ;
37
+ ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ;
38
+ #endif
39
+
40
+ if (Info != (scs_float *) NULL)
41
+ {
42
+ /* clear the Info array, if it exists */
43
+ for (i = 0 ; i < AMD_INFO ; i++)
44
+ {
45
+ Info [i] = EMPTY ;
46
+ }
47
+ Info [AMD_STATUS] = AMD_OK ;
48
+ }
49
+
50
+ for (k = 0 ; k < n ; k++)
51
+ {
52
+ Len [k] = 0 ;
53
+ }
54
+
55
+ nzdiag = 0 ;
56
+ nzboth = 0 ;
57
+ nz = Ap [n] ;
58
+
59
+ for (k = 0 ; k < n ; k++)
60
+ {
61
+ p1 = Ap [k] ;
62
+ p2 = Ap [k+1] ;
63
+ AMD_DEBUG2 (("\nAAT Column: "ID" p1: "ID" p2: "ID"\n", k, p1, p2)) ;
64
+
65
+ /* construct A+A' */
66
+ for (p = p1 ; p < p2 ; )
67
+ {
68
+ /* scan the upper triangular part of A */
69
+ j = Ai [p] ;
70
+ if (j < k)
71
+ {
72
+ /* entry A (j,k) is in the strictly upper triangular part,
73
+ * add both A (j,k) and A (k,j) to the matrix A+A' */
74
+ Len [j]++ ;
75
+ Len [k]++ ;
76
+ AMD_DEBUG3 ((" upper ("ID","ID") ("ID","ID")\n", j,k, k,j));
77
+ p++ ;
78
+ }
79
+ else if (j == k)
80
+ {
81
+ /* skip the diagonal */
82
+ p++ ;
83
+ nzdiag++ ;
84
+ break ;
85
+ }
86
+ else /* j > k */
87
+ {
88
+ /* first entry below the diagonal */
89
+ break ;
90
+ }
91
+ /* scan lower triangular part of A, in column j until reaching
92
+ * row k. Start where last scan left off. */
93
+ ASSERT (Tp [j] != EMPTY) ;
94
+ ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ;
95
+ pj2 = Ap [j+1] ;
96
+ for (pj = Tp [j] ; pj < pj2 ; )
97
+ {
98
+ i = Ai [pj] ;
99
+ if (i < k)
100
+ {
101
+ /* A (i,j) is only in the lower part, not in upper.
102
+ * add both A (i,j) and A (j,i) to the matrix A+A' */
103
+ Len [i]++ ;
104
+ Len [j]++ ;
105
+ AMD_DEBUG3 ((" lower ("ID","ID") ("ID","ID")\n",
106
+ i,j, j,i)) ;
107
+ pj++ ;
108
+ }
109
+ else if (i == k)
110
+ {
111
+ /* entry A (k,j) in lower part and A (j,k) in upper */
112
+ pj++ ;
113
+ nzboth++ ;
114
+ break ;
115
+ }
116
+ else /* i > k */
117
+ {
118
+ /* consider this entry later, when k advances to i */
119
+ break ;
120
+ }
121
+ }
122
+ Tp [j] = pj ;
123
+ }
124
+ /* Tp [k] points to the entry just below the diagonal in column k */
125
+ Tp [k] = p ;
126
+ }
127
+
128
+ /* clean up, for remaining mismatched entries */
129
+ for (j = 0 ; j < n ; j++)
130
+ {
131
+ for (pj = Tp [j] ; pj < Ap [j+1] ; pj++)
132
+ {
133
+ i = Ai [pj] ;
134
+ /* A (i,j) is only in the lower part, not in upper.
135
+ * add both A (i,j) and A (j,i) to the matrix A+A' */
136
+ Len [i]++ ;
137
+ Len [j]++ ;
138
+ AMD_DEBUG3 ((" lower cleanup ("ID","ID") ("ID","ID")\n",
139
+ i,j, j,i)) ;
140
+ }
141
+ }
142
+
143
+ /* --------------------------------------------------------------------- */
144
+ /* compute the symmetry of the nonzero pattern of A */
145
+ /* --------------------------------------------------------------------- */
146
+
147
+ /* Given a matrix A, the symmetry of A is:
148
+ * B = tril (spones (A), -1) + triu (spones (A), 1) ;
149
+ * sym = nnz (B & B') / nnz (B) ;
150
+ * or 1 if nnz (B) is zero.
151
+ */
152
+
153
+ if (nz == nzdiag)
154
+ {
155
+ sym = 1 ;
156
+ }
157
+ else
158
+ {
159
+ sym = (2 * (scs_float) nzboth) / ((scs_float) (nz - nzdiag)) ;
160
+ }
161
+
162
+ nzaat = 0 ;
163
+ for (k = 0 ; k < n ; k++)
164
+ {
165
+ nzaat += Len [k] ;
166
+ }
167
+
168
+ AMD_DEBUG1 (("AMD nz in A+A', excluding diagonal (nzaat) = %g\n",
169
+ (scs_float) nzaat)) ;
170
+ AMD_DEBUG1 ((" nzboth: "ID" nz: "ID" nzdiag: "ID" symmetry: %g\n",
171
+ nzboth, nz, nzdiag, sym)) ;
172
+
173
+ if (Info != (scs_float *) NULL)
174
+ {
175
+ Info [AMD_STATUS] = AMD_OK ;
176
+ Info [AMD_N] = n ;
177
+ Info [AMD_NZ] = nz ;
178
+ Info [AMD_SYMMETRY] = sym ; /* symmetry of pattern of A */
179
+ Info [AMD_NZDIAG] = nzdiag ; /* nonzeros on diagonal of A */
180
+ Info [AMD_NZ_A_PLUS_AT] = nzaat ; /* nonzeros in A+A' */
181
+ }
182
+
183
+ return (nzaat) ;
184
+ }
@@ -0,0 +1,64 @@
1
+ /* ========================================================================= */
2
+ /* === AMD_control ========================================================= */
3
+ /* ========================================================================= */
4
+
5
+ /* ------------------------------------------------------------------------- */
6
+ /* AMD, Copyright (c) Timothy A. Davis, */
7
+ /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8
+ /* email: DrTimothyAldenDavis@gmail.com */
9
+ /* ------------------------------------------------------------------------- */
10
+
11
+ /* User-callable. Prints the control parameters for AMD. See amd.h
12
+ * for details. If the Control array is not present, the defaults are
13
+ * printed instead.
14
+ */
15
+
16
+ #include "amd_internal.h"
17
+
18
+ GLOBAL void AMD_control
19
+ (
20
+ scs_float Control [ ]
21
+ )
22
+ {
23
+ scs_float alpha ;
24
+ Int aggressive ;
25
+
26
+ if (Control != (scs_float *) NULL)
27
+ {
28
+ alpha = Control [AMD_DENSE] ;
29
+ aggressive = Control [AMD_AGGRESSIVE] != 0 ;
30
+ }
31
+ else
32
+ {
33
+ alpha = AMD_DEFAULT_DENSE ;
34
+ aggressive = AMD_DEFAULT_AGGRESSIVE ;
35
+ }
36
+
37
+ SUITESPARSE_PRINTF ((
38
+ "\nAMD version %d.%d.%d, %s: approximate minimum degree ordering\n"
39
+ " dense row parameter: %g\n", AMD_MAIN_VERSION, AMD_SUB_VERSION,
40
+ AMD_SUBSUB_VERSION, AMD_DATE, alpha)) ;
41
+
42
+ if (alpha < 0)
43
+ {
44
+ SUITESPARSE_PRINTF ((" no rows treated as dense\n")) ;
45
+ }
46
+ else
47
+ {
48
+ SUITESPARSE_PRINTF ((
49
+ " (rows with more than max (%g * sqrt (n), 16) entries are\n"
50
+ " considered \"dense\", and placed last in output permutation)\n",
51
+ alpha)) ;
52
+ }
53
+
54
+ if (aggressive)
55
+ {
56
+ SUITESPARSE_PRINTF ((" aggressive absorption: yes\n")) ;
57
+ }
58
+ else
59
+ {
60
+ SUITESPARSE_PRINTF ((" aggressive absorption: no\n")) ;
61
+ }
62
+
63
+ SUITESPARSE_PRINTF ((" size of AMD integer: %d\n\n", sizeof (Int))) ;
64
+ }
@@ -0,0 +1,37 @@
1
+ /* ========================================================================= */
2
+ /* === AMD_defaults ======================================================== */
3
+ /* ========================================================================= */
4
+
5
+ /* ------------------------------------------------------------------------- */
6
+ /* AMD, Copyright (c) Timothy A. Davis, */
7
+ /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8
+ /* email: DrTimothyAldenDavis@gmail.com */
9
+ /* ------------------------------------------------------------------------- */
10
+
11
+ /* User-callable. Sets default control parameters for AMD. See amd.h
12
+ * for details.
13
+ */
14
+
15
+ #include "amd_internal.h"
16
+
17
+ /* ========================================================================= */
18
+ /* === AMD defaults ======================================================== */
19
+ /* ========================================================================= */
20
+
21
+ GLOBAL void AMD_defaults
22
+ (
23
+ scs_float Control [ ]
24
+ )
25
+ {
26
+ Int i ;
27
+
28
+ if (Control != (scs_float *) NULL)
29
+ {
30
+ for (i = 0 ; i < AMD_CONTROL ; i++)
31
+ {
32
+ Control [i] = 0 ;
33
+ }
34
+ Control [AMD_DENSE] = AMD_DEFAULT_DENSE ;
35
+ Control [AMD_AGGRESSIVE] = AMD_DEFAULT_AGGRESSIVE ;
36
+ }
37
+ }
@@ -0,0 +1,179 @@
1
+ /* ========================================================================= */
2
+ /* === AMD_dump ============================================================ */
3
+ /* ========================================================================= */
4
+
5
+ /* ------------------------------------------------------------------------- */
6
+ /* AMD, Copyright (c) Timothy A. Davis, */
7
+ /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8
+ /* email: DrTimothyAldenDavis@gmail.com */
9
+ /* ------------------------------------------------------------------------- */
10
+
11
+ /* Debugging routines for AMD. Not used if NDEBUG is not defined at compile-
12
+ * time (the default). See comments in amd_internal.h on how to enable
13
+ * debugging. Not user-callable.
14
+ */
15
+
16
+ #include "amd_internal.h"
17
+
18
+ #ifndef NDEBUG
19
+
20
+ /* This global variable is present only when debugging */
21
+ GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */
22
+
23
+ /* ========================================================================= */
24
+ /* === AMD_debug_init ====================================================== */
25
+ /* ========================================================================= */
26
+
27
+ /* Sets the debug print level, by reading the file debug.amd (if it exists) */
28
+
29
+ GLOBAL void AMD_debug_init ( char *s )
30
+ {
31
+ FILE *f ;
32
+ f = fopen ("debug.amd", "r") ;
33
+ if (f == (FILE *) NULL)
34
+ {
35
+ AMD_debug = -999 ;
36
+ }
37
+ else
38
+ {
39
+ fscanf (f, ID, &AMD_debug) ;
40
+ fclose (f) ;
41
+ }
42
+ if (AMD_debug >= 0)
43
+ {
44
+ printf ("%s: AMD_debug_init, D= "ID"\n", s, AMD_debug) ;
45
+ }
46
+ }
47
+
48
+ /* ========================================================================= */
49
+ /* === AMD_dump ============================================================ */
50
+ /* ========================================================================= */
51
+
52
+ /* Dump AMD's data structure, except for the hash buckets. This routine
53
+ * cannot be called when the hash buckets are non-empty.
54
+ */
55
+
56
+ GLOBAL void AMD_dump (
57
+ Int n, /* A is n-by-n */
58
+ Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */
59
+ Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1]
60
+ * holds the matrix on input */
61
+ Int Len [ ], /* len [0..n-1]: length for row i */
62
+ Int iwlen, /* length of iw */
63
+ Int pfree, /* iw [pfree ... iwlen-1] is empty on input */
64
+ Int Nv [ ], /* nv [0..n-1] */
65
+ Int Next [ ], /* next [0..n-1] */
66
+ Int Last [ ], /* last [0..n-1] */
67
+ Int Head [ ], /* head [0..n-1] */
68
+ Int Elen [ ], /* size n */
69
+ Int Degree [ ], /* size n */
70
+ Int W [ ], /* size n */
71
+ Int nel
72
+ )
73
+ {
74
+ Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ;
75
+
76
+ if (AMD_debug < 0) return ;
77
+ ASSERT (pfree <= iwlen) ;
78
+ AMD_DEBUG3 (("\nAMD dump, pfree: "ID"\n", pfree)) ;
79
+ for (i = 0 ; i < n ; i++)
80
+ {
81
+ pe = Pe [i] ;
82
+ elen = Elen [i] ;
83
+ nv = Nv [i] ;
84
+ len = Len [i] ;
85
+ w = W [i] ;
86
+
87
+ if (elen >= EMPTY)
88
+ {
89
+ if (nv == 0)
90
+ {
91
+ AMD_DEBUG3 (("\nI "ID": nonprincipal: ", i)) ;
92
+ ASSERT (elen == EMPTY) ;
93
+ if (pe == EMPTY)
94
+ {
95
+ AMD_DEBUG3 ((" dense node\n")) ;
96
+ ASSERT (w == 1) ;
97
+ }
98
+ else
99
+ {
100
+ ASSERT (pe < EMPTY) ;
101
+ AMD_DEBUG3 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i])));
102
+ }
103
+ }
104
+ else
105
+ {
106
+ AMD_DEBUG3 (("\nI "ID": active principal supervariable:\n",i));
107
+ AMD_DEBUG3 ((" nv(i): "ID" Flag: %d\n", nv, (nv < 0))) ;
108
+ ASSERT (elen >= 0) ;
109
+ ASSERT (nv > 0 && pe >= 0) ;
110
+ p = pe ;
111
+ AMD_DEBUG3 ((" e/s: ")) ;
112
+ if (elen == 0) AMD_DEBUG3 ((" : ")) ;
113
+ ASSERT (pe + len <= pfree) ;
114
+ for (k = 0 ; k < len ; k++)
115
+ {
116
+ j = Iw [p] ;
117
+ AMD_DEBUG3 ((" "ID"", j)) ;
118
+ ASSERT (j >= 0 && j < n) ;
119
+ if (k == elen-1) AMD_DEBUG3 ((" : ")) ;
120
+ p++ ;
121
+ }
122
+ AMD_DEBUG3 (("\n")) ;
123
+ }
124
+ }
125
+ else
126
+ {
127
+ e = i ;
128
+ if (w == 0)
129
+ {
130
+ AMD_DEBUG3 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ;
131
+ ASSERT (nv > 0 && pe < 0) ;
132
+ AMD_DEBUG3 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ;
133
+ }
134
+ else
135
+ {
136
+ AMD_DEBUG3 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ;
137
+ ASSERT (nv > 0 && pe >= 0) ;
138
+ p = pe ;
139
+ AMD_DEBUG3 ((" : ")) ;
140
+ ASSERT (pe + len <= pfree) ;
141
+ for (k = 0 ; k < len ; k++)
142
+ {
143
+ j = Iw [p] ;
144
+ AMD_DEBUG3 ((" "ID"", j)) ;
145
+ ASSERT (j >= 0 && j < n) ;
146
+ p++ ;
147
+ }
148
+ AMD_DEBUG3 (("\n")) ;
149
+ }
150
+ }
151
+ }
152
+
153
+ /* this routine cannot be called when the hash buckets are non-empty */
154
+ AMD_DEBUG3 (("\nDegree lists:\n")) ;
155
+ if (nel >= 0)
156
+ {
157
+ cnt = 0 ;
158
+ for (deg = 0 ; deg < n ; deg++)
159
+ {
160
+ if (Head [deg] == EMPTY) continue ;
161
+ ilast = EMPTY ;
162
+ AMD_DEBUG3 ((ID": \n", deg)) ;
163
+ for (i = Head [deg] ; i != EMPTY ; i = Next [i])
164
+ {
165
+ AMD_DEBUG3 ((" "ID" : next "ID" last "ID" deg "ID"\n",
166
+ i, Next [i], Last [i], Degree [i])) ;
167
+ ASSERT (i >= 0 && i < n && ilast == Last [i] &&
168
+ deg == Degree [i]) ;
169
+ cnt += Nv [i] ;
170
+ ilast = i ;
171
+ }
172
+ AMD_DEBUG3 (("\n")) ;
173
+ }
174
+ ASSERT (cnt == n - nel) ;
175
+ }
176
+
177
+ }
178
+
179
+ #endif
@@ -0,0 +1,16 @@
1
+ /* ========================================================================= */
2
+ /* === amd_global ========================================================== */
3
+ /* ========================================================================= */
4
+
5
+ /* ------------------------------------------------------------------------- */
6
+ /* AMD, Copyright (c) Timothy A. Davis, */
7
+ /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8
+ /* email: DrTimothyAldenDavis@gmail.com */
9
+ /* ------------------------------------------------------------------------- */
10
+
11
+ /* In prior versions of AMD, this file declared the amd_malloc, amd_free,
12
+ amd_realloc, amd_calloc, and amd_printf functions. They are now replaced
13
+ by functions defined in SuiteSparse_config/SuiteSparse_config.c.
14
+ */
15
+ /* Simply to suppress empty translation unit warnings. */
16
+ typedef int scs_amd_make_iso_compilers_happy;
@@ -0,0 +1,119 @@
1
+ /* ========================================================================= */
2
+ /* === AMD_info ============================================================ */
3
+ /* ========================================================================= */
4
+
5
+ /* ------------------------------------------------------------------------- */
6
+ /* AMD, Copyright (c) Timothy A. Davis, */
7
+ /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8
+ /* email: DrTimothyAldenDavis@gmail.com */
9
+ /* ------------------------------------------------------------------------- */
10
+
11
+ /* User-callable. Prints the output statistics for AMD. See amd.h
12
+ * for details. If the Info array is not present, nothing is printed.
13
+ */
14
+
15
+ #include "amd_internal.h"
16
+
17
+ #define PRI(format,x) { if (x >= 0) { SUITESPARSE_PRINTF ((format, x)) ; }}
18
+
19
+ GLOBAL void AMD_info
20
+ (
21
+ scs_float Info [ ]
22
+ )
23
+ {
24
+ scs_float n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;
25
+
26
+ SUITESPARSE_PRINTF (("\nAMD version %d.%d.%d, %s, results:\n",
27
+ AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ;
28
+
29
+ if (!Info)
30
+ {
31
+ return ;
32
+ }
33
+
34
+ n = Info [AMD_N] ;
35
+ ndiv = Info [AMD_NDIV] ;
36
+ nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ;
37
+ nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ;
38
+ lnz = Info [AMD_LNZ] ;
39
+ lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;
40
+
41
+ /* AMD return status */
42
+ SUITESPARSE_PRINTF ((" status: ")) ;
43
+ if (Info [AMD_STATUS] == AMD_OK)
44
+ {
45
+ SUITESPARSE_PRINTF (("OK\n")) ;
46
+ }
47
+ else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY)
48
+ {
49
+ SUITESPARSE_PRINTF (("out of memory\n")) ;
50
+ }
51
+ else if (Info [AMD_STATUS] == AMD_INVALID)
52
+ {
53
+ SUITESPARSE_PRINTF (("invalid matrix\n")) ;
54
+ }
55
+ else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED)
56
+ {
57
+ SUITESPARSE_PRINTF (("OK, but jumbled\n")) ;
58
+ }
59
+ else
60
+ {
61
+ SUITESPARSE_PRINTF (("unknown\n")) ;
62
+ }
63
+
64
+ /* statistics about the input matrix */
65
+ PRI (" n, dimension of A: %.20g\n", n);
66
+ PRI (" nz, number of nonzeros in A: %.20g\n",
67
+ Info [AMD_NZ]) ;
68
+ PRI (" symmetry of A: %.4f\n",
69
+ Info [AMD_SYMMETRY]) ;
70
+ PRI (" number of nonzeros on diagonal: %.20g\n",
71
+ Info [AMD_NZDIAG]) ;
72
+ PRI (" nonzeros in pattern of A+A' (excl. diagonal): %.20g\n",
73
+ Info [AMD_NZ_A_PLUS_AT]) ;
74
+ PRI (" # dense rows/columns of A+A': %.20g\n",
75
+ Info [AMD_NDENSE]) ;
76
+
77
+ /* statistics about AMD's behavior */
78
+ PRI (" memory used, in bytes: %.20g\n",
79
+ Info [AMD_MEMORY]) ;
80
+ PRI (" # of memory compactions: %.20g\n",
81
+ Info [AMD_NCMPA]) ;
82
+
83
+ /* statistics about the ordering quality */
84
+ SUITESPARSE_PRINTF (("\n"
85
+ " The following approximate statistics are for a subsequent\n"
86
+ " factorization of A(P,P) + A(P,P)'. They are slight upper\n"
87
+ " bounds if there are no dense rows/columns in A+A', and become\n"
88
+ " looser if dense rows/columns exist.\n\n")) ;
89
+
90
+ PRI (" nonzeros in L (excluding diagonal): %.20g\n",
91
+ lnz) ;
92
+ PRI (" nonzeros in L (including diagonal): %.20g\n",
93
+ lnzd) ;
94
+ PRI (" # divide operations for LDL' or LU: %.20g\n",
95
+ ndiv) ;
96
+ PRI (" # multiply-subtract operations for LDL': %.20g\n",
97
+ nmultsubs_ldl) ;
98
+ PRI (" # multiply-subtract operations for LU: %.20g\n",
99
+ nmultsubs_lu) ;
100
+ PRI (" max nz. in any column of L (incl. diagonal): %.20g\n",
101
+ Info [AMD_DMAX]) ;
102
+
103
+ /* total flop counts for various factorizations */
104
+
105
+ if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
106
+ {
107
+ SUITESPARSE_PRINTF (("\n"
108
+ " chol flop count for real A, sqrt counted as 1 flop: %.20g\n"
109
+ " LDL' flop count for real A: %.20g\n"
110
+ " LDL' flop count for complex A: %.20g\n"
111
+ " LU flop count for real A (with no pivoting): %.20g\n"
112
+ " LU flop count for complex A (with no pivoting): %.20g\n\n",
113
+ n + ndiv + 2*nmultsubs_ldl,
114
+ ndiv + 2*nmultsubs_ldl,
115
+ 9*ndiv + 8*nmultsubs_ldl,
116
+ ndiv + 2*nmultsubs_lu,
117
+ 9*ndiv + 8*nmultsubs_lu)) ;
118
+ }
119
+ }