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,180 @@
1
+ /* ========================================================================= */
2
+ /* === AMD_1 =============================================================== */
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_1: Construct A+A' for a sparse matrix A and perform the AMD ordering.
12
+ *
13
+ * The n-by-n sparse matrix A can be unsymmetric. It is stored in MATLAB-style
14
+ * compressed-column form, with sorted row indices in each column, and no
15
+ * duplicate entries. Diagonal entries may be present, but they are ignored.
16
+ * Row indices of column j of A are stored in Ai [Ap [j] ... Ap [j+1]-1].
17
+ * Ap [0] must be zero, and nz = Ap [n] is the number of entries in A. The
18
+ * size of the matrix, n, must be greater than or equal to zero.
19
+ *
20
+ * This routine must be preceded by a call to AMD_aat, which computes the
21
+ * number of entries in each row/column in A+A', excluding the diagonal.
22
+ * Len [j], on input, is the number of entries in row/column j of A+A'. This
23
+ * routine constructs the matrix A+A' and then calls AMD_2. No error checking
24
+ * is performed (this was done in AMD_valid).
25
+ */
26
+
27
+ #include "amd_internal.h"
28
+
29
+ GLOBAL void AMD_1
30
+ (
31
+ Int n, /* n > 0 */
32
+ const Int Ap [ ], /* input of size n+1, not modified */
33
+ const Int Ai [ ], /* input of size nz = Ap [n], not modified */
34
+ Int P [ ], /* size n output permutation */
35
+ Int Pinv [ ], /* size n output inverse permutation */
36
+ Int Len [ ], /* size n input, undefined on output */
37
+ Int slen, /* slen >= sum (Len [0..n-1]) + 7n,
38
+ * ideally slen = 1.2 * sum (Len) + 8n */
39
+ Int S [ ], /* size slen workspace */
40
+ scs_float Control [ ], /* input array of size AMD_CONTROL */
41
+ scs_float Info [ ] /* output array of size AMD_INFO */
42
+ )
43
+ {
44
+ Int i, j, k, p, pfree, iwlen, pj, p1, p2, pj2, *Iw, *Pe, *Nv, *Head,
45
+ *Elen, *Degree, *s, *W, *Sp, *Tp ;
46
+
47
+ /* --------------------------------------------------------------------- */
48
+ /* construct the matrix for AMD_2 */
49
+ /* --------------------------------------------------------------------- */
50
+
51
+ ASSERT (n > 0) ;
52
+
53
+ iwlen = slen - 6*n ;
54
+ s = S ;
55
+ Pe = s ; s += n ;
56
+ Nv = s ; s += n ;
57
+ Head = s ; s += n ;
58
+ Elen = s ; s += n ;
59
+ Degree = s ; s += n ;
60
+ W = s ; s += n ;
61
+ Iw = s ; s += iwlen ;
62
+
63
+ ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ;
64
+
65
+ /* construct the pointers for A+A' */
66
+ Sp = Nv ; /* use Nv and W as workspace for Sp and Tp [ */
67
+ Tp = W ;
68
+ pfree = 0 ;
69
+ for (j = 0 ; j < n ; j++)
70
+ {
71
+ Pe [j] = pfree ;
72
+ Sp [j] = pfree ;
73
+ pfree += Len [j] ;
74
+ }
75
+
76
+ /* Note that this restriction on iwlen is slightly more restrictive than
77
+ * what is strictly required in AMD_2. AMD_2 can operate with no elbow
78
+ * room at all, but it will be very slow. For better performance, at
79
+ * least size-n elbow room is enforced. */
80
+ ASSERT (iwlen >= pfree + n) ;
81
+
82
+ #ifndef NDEBUG
83
+ for (p = 0 ; p < iwlen ; p++) Iw [p] = EMPTY ;
84
+ #endif
85
+
86
+ for (k = 0 ; k < n ; k++)
87
+ {
88
+ AMD_DEBUG1 (("Construct row/column k= "ID" of A+A'\n", k)) ;
89
+ p1 = Ap [k] ;
90
+ p2 = Ap [k+1] ;
91
+
92
+ /* construct A+A' */
93
+ for (p = p1 ; p < p2 ; )
94
+ {
95
+ /* scan the upper triangular part of A */
96
+ j = Ai [p] ;
97
+ ASSERT (j >= 0 && j < n) ;
98
+ if (j < k)
99
+ {
100
+ /* entry A (j,k) in the strictly upper triangular part */
101
+ ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ;
102
+ ASSERT (Sp [k] < (k == n-1 ? pfree : Pe [k+1])) ;
103
+ Iw [Sp [j]++] = k ;
104
+ Iw [Sp [k]++] = j ;
105
+ p++ ;
106
+ }
107
+ else if (j == k)
108
+ {
109
+ /* skip the diagonal */
110
+ p++ ;
111
+ break ;
112
+ }
113
+ else /* j > k */
114
+ {
115
+ /* first entry below the diagonal */
116
+ break ;
117
+ }
118
+ /* scan lower triangular part of A, in column j until reaching
119
+ * row k. Start where last scan left off. */
120
+ ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ;
121
+ pj2 = Ap [j+1] ;
122
+ for (pj = Tp [j] ; pj < pj2 ; )
123
+ {
124
+ i = Ai [pj] ;
125
+ ASSERT (i >= 0 && i < n) ;
126
+ if (i < k)
127
+ {
128
+ /* A (i,j) is only in the lower part, not in upper */
129
+ ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ;
130
+ ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ;
131
+ Iw [Sp [i]++] = j ;
132
+ Iw [Sp [j]++] = i ;
133
+ pj++ ;
134
+ }
135
+ else if (i == k)
136
+ {
137
+ /* entry A (k,j) in lower part and A (j,k) in upper */
138
+ pj++ ;
139
+ break ;
140
+ }
141
+ else /* i > k */
142
+ {
143
+ /* consider this entry later, when k advances to i */
144
+ break ;
145
+ }
146
+ }
147
+ Tp [j] = pj ;
148
+ }
149
+ Tp [k] = p ;
150
+ }
151
+
152
+ /* clean up, for remaining mismatched entries */
153
+ for (j = 0 ; j < n ; j++)
154
+ {
155
+ for (pj = Tp [j] ; pj < Ap [j+1] ; pj++)
156
+ {
157
+ i = Ai [pj] ;
158
+ ASSERT (i >= 0 && i < n) ;
159
+ /* A (i,j) is only in the lower part, not in upper */
160
+ ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ;
161
+ ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ;
162
+ Iw [Sp [i]++] = j ;
163
+ Iw [Sp [j]++] = i ;
164
+ }
165
+ }
166
+
167
+ #ifndef NDEBUG
168
+ for (j = 0 ; j < n-1 ; j++) ASSERT (Sp [j] == Pe [j+1]) ;
169
+ ASSERT (Sp [n-1] == pfree) ;
170
+ #endif
171
+
172
+ /* Tp and Sp no longer needed ] */
173
+
174
+ /* --------------------------------------------------------------------- */
175
+ /* order the matrix */
176
+ /* --------------------------------------------------------------------- */
177
+
178
+ AMD_2 (n, Pe, Iw, Len, iwlen, pfree,
179
+ Nv, Pinv, P, Head, Elen, Degree, W, Control, Info) ;
180
+ }