31 #define SOPLEX_FACTOR_MARKER 1e-100 62 for(i = 1; i < *size; ++i)
63 for(j = 0; j < i; ++j)
64 assert(heap[i] != heap[j]);
76 e = heap[s = --(*size)];
79 for(j = 0, i = 1; i < s; i = 2 * j + 1)
112 if(i < *size && e < heap[i])
147 for(i = 1; i < *size; ++i)
148 for(j = 0; j < i; ++j)
149 assert(heap[i] != heap[j]);
161 e = heap[s = --(*size)];
164 for(j = 0, i = 1; i < s; i = 2 * j + 1)
197 if(i < *size && e > heap[i])
261 for(
int i = 0; i <
thedim; ++i)
285 <<
"LU pivot element is almost zero (< " 287 <<
") - Basis is numerically singular" 316 for(ring = list->
next; ring != list; ring = ring->
next)
320 if(l_rbeg[l_row] != n)
326 assert(l_rlen[l_row] <= l_rmax[l_row]);
328 l_rmax[l_row] = l_rlen[l_row];
329 j = i + l_rlen[l_row];
331 for(; i < j; ++i, ++n)
334 l_ridx[n] = l_ridx[i];
335 l_rval[n] = l_rval[i];
342 goto terminatePackRows;
347 l_rmax[l_row] = l_rlen[l_row];
374 for(ring = list->
next; ring != list; ring = ring->
next)
385 cmax[colno] = clen[colno];
398 goto terminatePackColumns;
403 cmax[colno] = clen[colno];
406 terminatePackColumns :
417 assert(
u.
row.
max[p_row] < len);
421 int delta = len -
u.
row.
max[p_row];
426 delta = len -
u.
row.
max[p_row];
436 &&
"ERROR: could not allocate memory for row file");
460 &&
"ERROR: could not allocate memory for row file");
477 for(; i < k; ++i, ++j)
506 for(ring = list->
next; ring != list; ring = ring->
next)
510 if(l_cbeg[l_col] != n)
517 l_cmax[l_col] = l_clen[l_col];
518 j = i + l_clen[l_col];
521 l_cidx[n++] = l_cidx[i];
527 goto terminatePackColumns;
532 l_cmax[l_col] = l_clen[l_col];
535 terminatePackColumns :
546 assert(
u.
col.
max[p_col] < len);
550 int delta = len -
u.
col.
max[p_col];
555 delta = len -
u.
col.
max[p_col];
565 &&
"ERROR: could not allocate memory for column file");
589 &&
"ERROR: could not allocate memory for column file");
615 assert(
u.
col.
max[p_col] < len);
619 int delta = len -
u.
col.
max[p_col];
624 delta = len -
u.
col.
max[p_col];
632 &&
"ERROR: could not allocate memory for column file");
655 &&
"ERROR: could not allocate memory for column file");
714 int i, j, k, h, m, n;
748 for(i += j - 1; i >= j; --i)
754 while(ridx[k] != p_col)
779 if(num > cmax[p_col])
790 for(j = 0; j < num; ++j)
802 assert(k - cbeg[p_col] < cmax[p_col]);
809 if(rmax[i] <= rlen[i])
816 h = rbeg[i] + (rlen[i])++;
828 nzCnt += (clen[p_col] = k - cbeg[p_col]);
845 for(i = 0; i < dim; ++i)
858 clen[p_col] = k - cbeg[p_col];
867 assert(k - cbeg[p_col] < cmax[p_col]);
874 if(rmax[i] <= rlen[i])
881 h = rbeg[i] + (rlen[i])++;
893 nzCnt += (clen[p_col] = k - cbeg[p_col]);
895 if(cbeg[p_col] + cmax[p_col] ==
u.
col.
used)
898 cmax[p_col] = clen[p_col];
914 memmove(&rorig[c], &rorig[c + 1], (
unsigned int)(r - c) *
sizeof(
int));
918 for(i = c; i <= r; ++i)
926 memmove(&corig[c], &corig[c + 1], (
unsigned int)(r - c) *
sizeof(
int));
930 for(i = c; i <= r; ++i)
942 if(i < verySparseFactor * (dim - c))
959 for(i += j - 1; i >= j; --i)
964 m = --(clen[k]) + cbeg[k];
966 for(h = m; cidx[h] != rowno; --h)
983 assert((num == 0) || (nonz != 0));
991 for(i = 0; i < num; ++i)
992 assert(p_work[corig[nonz[i]]] != 0.0);
1002 assert(p_work[k] != 0.0);
1006 x = p_work[k] *
diag[n];
1026 Real y = p_work[jj];
1054 diag[rowno] = 1 / x;
1061 if(rmax[rowno] < num)
1075 for(i = 0; i < num; ++i)
1099 if(clen[j] >= cmax[j])
1106 cval[cbeg[j] + clen[j]] = x;
1108 cidx[cbeg[j] + clen[j]++] = rowno;
1112 rlen[rowno] = n - rbeg[rowno];
1118 for(i += j - 1; i >= j; --i)
1121 p_work[k] = rval[i];
1122 m = --(clen[k]) + cbeg[k];
1124 for(h = m; cidx[h] != rowno; --h)
1141 for(i = c; i < r; ++i)
1145 if(p_work[k] != 0.0)
1148 x = p_work[k] *
diag[n];
1162 p_work[ridx[j]] -= x * rval[j];
1185 diag[rowno] = 1 / x;
1195 for(i = r + 1; i < dim; ++i)
1196 if(p_work[corig[i]] != 0.0)
1213 for(i = r + 1; i < dim; ++i)
1231 if(clen[j] >= cmax[j])
1238 cval[cbeg[j] + clen[j]] = x;
1240 cidx[cbeg[j] + clen[j]++] = rowno;
1244 rlen[rowno] = n - rbeg[rowno];
1254 i = rbeg[rowno] + --(rlen[rowno]);
1255 diag[rowno] = 1 / rval[i];
1257 for(j = i = --(clen[p_col]) + cbeg[p_col]; cidx[i] != rowno; --i)
1284 assert(p_work[p_col] != 0.0);
1285 rezi = 1 / p_work[p_col];
1286 p_work[p_col] = 0.0;
1293 for(i = num - 1; (j = p_idx[i]) != p_col; --i)
1296 lval[ll] = rezi * p_work[j];
1303 lval[ll] = 1 - rezi;
1306 for(--i; i >= 0; --i)
1310 lval[ll] = x = rezi * p_work[j];
1332 assert(p_work[p_col] != 0.0);
1333 rezi = 1 / p_work[p_col];
1339 for(i = num - 1; (j = p_idx[i]) != p_col; --i)
1342 lval[ll] = rezi * p_work[j];
1348 lval[ll] = 1 - rezi;
1351 for(--i; i >= 0; --i)
1355 lval[ll] = x = rezi * p_work[j];
1397 Dring* rring, *lastrring;
1398 Dring* cring, *lastcring;
1408 for(
int i = 0; i <
thedim; i++)
1413 for(
int i = 0; i < thedim; i++)
1424 for(
int j = 0; j < k; ++j)
1456 lastrring->
next = rring;
1464 lastcring->
next = cring;
1468 for(
int i = 0; i <
thedim; i++)
1474 rring->
prev = lastrring;
1475 lastrring->
next = rring;
1480 cring->
prev = lastcring;
1481 lastcring->
next = cring;
1505 for(
int i = 0; i <
thedim; i++)
1515 for(
int j = 0; j < psv->
size() && nnonzeros <= 1; j++)
1529 else if(nnonzeros == 1)
1538 assert(j < psv->size());
1571 assert(nnonzeros >= 2);
1574 for(
int j = 0; j < psv->
size(); j++)
1600 assert(nnonzeros >= 2);
1621 int p_col, p_row, newrow;
1641 for(j = 0; j < len; ++j)
1650 for(k = n;
u.
col.
idx[k] != p_row; ++k)
1668 if(rperm[newrow] >= 0)
1678 for(k = n;
u.
row.
idx[k] != p_col; --k)
1713 int p_row, p_col, len, rs, lk;
1722 for(i = 0; i <
thedim; ++i)
1724 if(rperm[i] < 0 &&
u.
row.
len[i] == 1)
1763 for(j = k;
u.
row.
idx[j] != p_col; --j)
1822 for(i = 0; i <
thedim; ++i)
1907 for(; (r = idx[i]) != prow; ++i)
1914 for(j = k;
u.
row.
idx[j] != pcol; --j)
1945 assert(i < len &&
"ERROR: pivot column does not contain pivot row");
1947 for(++i; i < len; ++i)
1955 for(j = k;
u.
row.
idx[j] != pcol; --j)
2017 for(i = j; (c =
u.
row.
idx[i]) != pcol; --i)
2021 for(k = m;
u.
col.
idx[k] != prow; ++k)
2047 for(--i; i >= j; --i)
2052 for(k = m;
u.
col.
idx[k] != prow; ++k)
2112 len =
u.
row.
len[rw] + beg - 1;
2122 for(i = len - 1; i >= beg; --i)
2129 l_maxabs *= threshold;
2135 for(i = len; i >= beg; --i)
2141 if(j < mkwtz &&
spxAbs(x) > l_maxabs)
2156 len =
u.
col.
len[cl] + beg - 1;
2164 for(i = len; i >= beg; --i)
2197 for(kk = m +
u.
row.
len[k] - 1; kk >= m; --kk)
2210 for(--kk; kk > m; --kk)
2219 l_maxabs *= threshold;
2256 if(pr->
idx == rw || pr->
mkwtz >= mkwtz)
2270 if(num >= candidates)
2303 int c, i, j, k, ll, m, n;
2312 for(j = m;
u.
row.
idx[j] != pcol; --j)
2333 for(j = m - 1; j >= n; --j)
2362 for(i = k;
u.
col.
idx[i] != r; --i)
2432 int i, j, k, m = -1;
2437 int plen = --(
u.
row.
len[prow]);
2438 int pend = pbeg + plen;
2467 for(i = pbeg; i < pend; ++i)
2475 for(k = m;
u.
col.
idx[k] != prow; ++k)
2493 updateRow(m, lv++, prow, pcol, pval, eps);
2500 for(++i; i < m; ++i)
2512 for(i =
u.
row.
start[prow], pend = i + plen; i < pend; ++i)
2527 const Real threshold)
2547 for(i = 0; i <
thedim; ++i)
2565 "ERROR: no pivot element selected");
2568 pivot = pivot->
next)
2588 "ERROR: one row must be left");
2590 "ERROR: one col must be left");
2612 for(i = 0; i <
thedim; i++)
2617 for(i = 0; i <
thedim; i++)
2628 assert((*idx >= 0) && (*idx < thedim));
2632 assert((k >= 0) && (k <
u.
col.
size));
2718 for(i =
thedim; i--; *l_rbeg++ = 0)
2720 *rorig++ = *rrorig++;
2721 *rperm++ = *rrperm++;
2726 l_rbeg =
l.
rbeg + 1;
2733 for(m = 0, i =
thedim; i--; l_rbeg++)
2742 l_rbeg =
l.
rbeg + 1;
2744 for(i = j = 0; i < vecs; ++i)
2749 for(; j < beg[i + 1]; j++)
2751 k = l_rbeg[*idx++]++;
2760 assert(
l.
rbeg[0] == 0);
2833 for(i = 0; i <
thedim; ++i)
2836 std::cout <<
"DCLUFA01 diag[" << i <<
"]: [" <<
col.
orig[
row.
perm[i]]
2837 <<
"] = " <<
diag[i] << std::endl;
2839 for(j = 0; j <
u.
row.
len[i]; ++j)
2840 std::cout <<
"DCLUFA02 u[" << i <<
"]: [" 2847 for(i = 0; i <
thedim; ++i)
2852 std::cout <<
"DCLUFA03 l[" << i <<
"]" << std::endl;
2855 std::cout <<
"DCLUFA04 l[" << k -
l.
start[j]
2856 <<
"]: [" <<
l.
idx[k]
2857 <<
"] = " <<
l.
val[k] << std::endl;
2927 int* p_lrow =
l.
row;
2932 assert(p_len > 0 &&
"ERROR: no empty columns allowed in L vectors");
2948 #ifdef ENABLE_CONSISTENCY_CHECKS 2965 assert(ring->
idx >= 0);
2990 assert(ring->
idx >= 0);
3007 for(i = 0; i <
thedim; ++i)
3016 for(i = 0; i <
thedim; ++i)
3043 for(i = 0; i <
thedim; ++i)
3065 for(i = 0; i < thedim -
temp.
stage; ++i)
3079 #endif // CONSISTENCY_CHECKS 3087 for(
int i =
thedim - 1; i >= 0; i--)
3091 Real x = wrk[c] =
diag[r] * vec[r];
3108 int* cidx, *clen, *cbeg;
3125 for(i =
thedim - 1; i >= 0; --i)
3128 x =
diag[r] * rhs[r];
3135 val = &cval[cbeg[c]];
3136 idx = &cidx[cbeg[c]];
3140 rhs[*idx++] -= x * (*val++);
3152 int* cidx, *clen, *cbeg;
3167 for(i =
thedim - 1; i >= 0; --i)
3171 p_work1[c] = x1 =
diag[r] * vec1[r];
3172 p_work2[c] = x2 =
diag[r] * vec2[r];
3173 vec1[r] = vec2[r] = 0;
3175 if(x1 != 0.0 && x2 != 0.0)
3177 val = &cval[cbeg[c]];
3178 idx = &cidx[cbeg[c]];
3183 vec1[*idx] -= x1 * (*val);
3184 vec2[*idx++] -= x2 * (*val++);
3189 val = &cval[cbeg[c]];
3190 idx = &cidx[cbeg[c]];
3194 vec1[*idx++] -= x1 * (*val++);
3198 val = &cval[cbeg[c]];
3199 idx = &cidx[cbeg[c]];
3203 vec2[*idx++] -= x2 * (*val++);
3210 int* nonz,
Real eps)
3214 int* cidx, *clen, *cbeg;
3215 bool notzero1, notzero2;
3232 for(i =
thedim - 1; i >= 0; --i)
3236 p_work1[c] = x1 =
diag[r] * vec1[r];
3237 p_work2[c] = x2 =
diag[r] * vec2[r];
3238 vec1[r] = vec2[r] = 0;
3242 if(notzero1 && notzero2)
3246 val = &cval[cbeg[c]];
3247 idx = &cidx[cbeg[c]];
3252 vec1[*idx] -= x1 * (*val);
3253 vec2[*idx++] -= x2 * (*val++);
3261 val = &cval[cbeg[c]];
3262 idx = &cidx[cbeg[c]];
3266 vec1[*idx++] -= x1 * (*val++);
3271 val = &cval[cbeg[c]];
3272 idx = &cidx[cbeg[c]];
3276 vec2[*idx++] -= x2 * (*val++);
3294 int* lrow, *lidx, *idx;
3304 for(i = 0; i < end; ++i)
3306 if((x = vec[lrow[i]]) != 0.0)
3308 MSG_DEBUG(std::cout <<
"y" << lrow[i] <<
"=" << vec[lrow[i]] << std::endl;)
3314 for(j = lbeg[i + 1]; j > k; --j)
3316 MSG_DEBUG(std::cout <<
" -> y" << *idx <<
" -= " << x <<
" * " << *val <<
3317 " = " << x * (*val) <<
" -> " << vec[*idx] - x * (*val) << std::endl;)
3318 vec[*idx++] -= x * (*val++);
3325 MSG_DEBUG(std::cout <<
"performing FT updates..." << std::endl;)
3337 for(j = lbeg[i + 1]; j > k; --j)
3338 tmp += vec[*idx++] * (*val++);
3340 vec[lrow[i]] = -tmp;
3342 MSG_DEBUG(std::cout <<
"y" << lrow[i] <<
"=" << vec[lrow[i]] << std::endl;)
3345 MSG_DEBUG(std::cout <<
"finished FT updates." << std::endl;)
3356 int* lrow, *lidx, *idx;
3366 for(i = 0; i < end; ++i)
3371 if(x1 != 0 && x2 != 0.0)
3377 for(j = lbeg[i + 1]; j > k; --j)
3379 vec1[*idx] -= x1 * (*val);
3380 vec2[*idx++] -= x2 * (*val++);
3389 for(j = lbeg[i + 1]; j > k; --j)
3390 vec1[*idx++] -= x1 * (*val++);
3398 for(j = lbeg[i + 1]; j > k; --j)
3399 vec2[*idx++] -= x2 * (*val++);
3416 for(j = lbeg[i + 1]; j > k; --j)
3418 tmp1 += vec1[*idx] * (*val);
3419 tmp2 += vec2[*idx++] * (*val++);
3422 vec1[lrow[i]] = -tmp1;
3423 vec2[lrow[i]] = -tmp2;
3434 int* lrow, *lidx, *idx;
3448 if((x = vec[lrow[i]]) != 0.0)
3454 for(j = lbeg[i + 1]; j > k; --j)
3455 vec[*idx++] -= x * (*val++);
3486 if(x1 != 0.0 && x2 != 0.0)
3492 for(j = lbeg[i + 1]; j > k; --j)
3494 vec1[*idx] -= x1 * (*val);
3495 vec2[*idx++] -= x2 * (*val++);
3504 for(j = lbeg[i + 1]; j > k; --j)
3505 vec1[*idx++] -= x1 * (*val++);
3513 for(j = lbeg[i + 1]; j > k; --j)
3514 vec2[*idx++] -= x2 * (*val++);
3520 Real* rhs,
Real* forest,
int* forestNum,
int* forestIdx)
3528 for(
int i = 0; i <
thedim; i++)
3532 n += rhs[i] != 0.0 ? 1 : 0;
3573 for(
int i = 0; i <
thedim; i++)
3576 forest[i] = rhs1[i];
3577 n += rhs1[i] != 0.0 ? 1 : 0;
3613 for(
int i = 0; i <
thedim; ++i)
3636 for(
int m =
u.
row.
start[r]; m < end; m++)
3652 int* ridx, *rlen, *rbeg, *idx;
3663 for(i = 0; i <
thedim; ++i)
3670 if((x1 != 0.0) && (x2 != 0.0))
3680 for(
int m = rlen[r]; m != 0; --m)
3682 vec1[*idx] -= x1 * (*val);
3683 vec2[*idx] -= x2 * (*val++);
3695 for(
int m = rlen[r]; m != 0; --m)
3696 vec1[*idx++] -= x1 * (*val++);
3706 for(
int m = rlen[r]; m != 0; --m)
3707 vec2[*idx++] -= x2 * (*val++);
3724 int* lidx, *idx, *lrow;
3748 for(j = lbeg[i + 1]; j > k; --j)
3750 vec1[*idx] -= x1 * (*val);
3751 vec2[*idx++] -= x2 * (*val++);
3760 for(j = lbeg[i + 1]; j > k; --j)
3761 vec1[*idx++] -= x1 * (*val++);
3770 for(j = lbeg[i + 1]; j > k; --j)
3771 vec2[*idx++] -= x2 * (*val++);
3814 for(j = lbeg[i + 1]; j > k; --j)
3816 x1 += vec1[*idx] * (*val);
3817 x2 += vec2[*idx++] * (*val++);
3820 vec1[lrow[i]] -= x1;
3822 vec2[lrow[i]] -= x2;
3835 if(x1not0 && x2not0)
3838 j = rbeg[r + 1] - k;
3845 vec1[*idx] -= x1 * *val;
3846 vec2[*idx++] -= x2 * *val++;
3852 j = rbeg[r + 1] - k;
3859 vec1[*idx++] -= x1 * *val++;
3865 j = rbeg[r + 1] - k;
3872 vec2[*idx++] -= x2 * *val++;
3885 int* idx, *lidx, *lrow, *lbeg;
3896 if((x = vec[lrow[i]]) != 0.0)
3902 for(j = lbeg[i + 1]; j > k; --j)
3903 vec[*idx++] -= x * (*val++);
3928 for(
int j = lbeg[i + 1]; j > k; --j)
3929 x += vec[*idx++] * (*val++);
3936 for(
int i =
thedim - 1; i >= 0; --i)
3943 for(
int k =
l.
rbeg[r]; k <
l.
rbeg[r + 1]; k++)
3949 vec[j] -= x *
l.
rval[k];
3954 #endif // WITH_L_ROWS 3985 for(j = lbeg[i + 1]; j > k; --j)
3986 x += vec[*idx++] * (*val++);
4003 j = rbeg[r + 1] - k;
4010 vec[*idx++] -= x * *val++;
4026 int* lrow, *lidx, *idx;
4045 for(j = lbeg[i + 1]; j > k; --j)
4046 tmp += vec[*idx++] * (*val++);
4048 vec[lrow[i]] = -tmp;
4056 int* lrow, *lidx, *idx;
4077 for(j = lbeg[i + 1]; j > k; --j)
4079 tmp1 += vec1[*idx] * (*val);
4080 tmp2 += vec2[*idx++] * (*val++);
4083 vec1[lrow[i]] = -tmp1;
4084 vec2[lrow[i]] = -tmp2;
4093 int* lrow, *lidx, *idx;
4108 assert(k >= 0 && k <
l.
size);
4117 for(j = lbeg[i + 1]; j > k; --j)
4119 assert(*idx >= 0 && *idx <
thedim);
4120 tmp += vec[*idx++] * (*val++);
4204 Real* vec,
int* vecidx,
4205 Real* rhs,
int* rhsidx,
int rhsn)
4208 int i, j, k, n, r, c;
4209 int* rorig, *corig, *cperm;
4210 int* ridx, *rlen, *rbeg, *idx;
4220 for(i = 0; i < rhsn;)
4236 assert(i >= 0 && i <
thedim);
4238 assert(c >= 0 && c <
thedim);
4245 assert(r >= 0 && r <
thedim);
4254 for(
int m = rlen[r]; m; --m)
4257 assert(j >= 0 && j <
thedim);
4284 Real* rhs,
int* rhsidx,
int rhsn)
4288 int* rorig, *corig, *cperm;
4289 int* ridx, *rlen, *rbeg, *idx;
4299 for(i = 0; i < rhsn;)
4313 assert(i >= 0 && i <
thedim);
4315 assert(c >= 0 && c <
thedim);
4322 assert(r >= 0 && r <
thedim);
4330 for(
int m = rlen[r]; m; --m)
4333 assert(j >= 0 && j <
thedim);
4362 int* idx, *lidx, *lrow, *lbeg;
4372 assert(i >= 0 && i <
l.
size);
4374 if((x = vec[lrow[i]]) != 0.0)
4377 assert(k >= 0 && k <
l.
size);
4381 for(j = lbeg[i + 1]; j > k; --j)
4384 assert(m >= 0 && m <
thedim);
4415 int* idx, *lidx, *lrow, *lbeg;
4425 if((x = vec[lrow[i]]) != 0.0)
4427 assert(i >= 0 && i <
l.
size);
4429 assert(k >= 0 && k <
l.
size);
4433 for(j = lbeg[i + 1]; j > k; --j)
4435 assert(*idx >= 0 && *idx <
thedim);
4436 vec[*idx++] -= x * (*val++);
4463 #pragma warn "Not yet implemented, define WITH_L_ROWS" 4476 for(j = lbeg[i + 1]; j > k; --j)
4477 x += vec[*idx++] * (*val++);
4502 j = rbeg[r + 1] - k;
4508 assert(
l.
rperm[*idx] < i);
4533 for(i = 0; i < n; ++i)
4569 assert(k >= 0 && k <
l.
size);
4574 for(j = lbeg[i + 1]; j > k; --j)
4576 assert(*idx >= 0 && *idx <
thedim);
4577 x += vec[*idx++] * (*val++);
4593 j = rbeg[r + 1] - k;
4599 assert(
l.
rperm[*idx] < i);
4600 vec[*idx++] -= x * *val++;
4633 int* lrow, *lidx, *idx;
4644 for(i = 0; i < end; ++i)
4656 for(j = lbeg[i + 1]; j > k; --j)
4658 assert(*idx >= 0 && *idx <
thedim);
4678 for(j = lbeg[i + 1]; j > k; --j)
4680 assert(*idx >= 0 && *idx <
thedim);
4681 tmp += vec[*idx++] * (*val++);
4696 Real* vec,
int* ridx,
int& rn,
Real eps,
4697 Real* vec2,
int* ridx2,
int& rn2,
Real eps2)
4703 int* lrow, *lidx, *idx;
4714 for(i = 0; i < end; ++i)
4730 for(j = lbeg[i + 1]; j > k; --j)
4732 assert(*idx >= 0 && *idx <
thedim);
4742 for(j = lbeg[i + 1]; j > k; --j)
4744 assert(*idx >= 0 && *idx <
thedim);
4758 for(j = lbeg[i + 1]; j > k; --j)
4760 assert(*idx >= 0 && *idx <
thedim);
4781 for(j = lbeg[i + 1]; j > k; --j)
4783 assert(*idx >= 0 && *idx <
thedim);
4784 tmp1 += vec[*idx] * (*val);
4785 tmp2 += vec2[*idx++] * (*val++);
4805 Real* vec,
int* ridx,
int& rn,
Real eps,
4806 Real* vec2,
int* ridx2,
int& rn2,
Real eps2,
4807 Real* vec3,
int* ridx3,
int& rn3,
Real eps3)
4813 int* lrow, *lidx, *idx;
4823 for(i = 0; i < end; ++i)
4841 for(j = lbeg[i + 1]; j > k; --j)
4843 assert(*idx >= 0 && *idx <
thedim);
4854 for(j = lbeg[i + 1]; j > k; --j)
4856 assert(*idx >= 0 && *idx <
thedim);
4867 for(j = lbeg[i + 1]; j > k; --j)
4869 assert(*idx >= 0 && *idx <
thedim);
4879 for(j = lbeg[i + 1]; j > k; --j)
4881 assert(*idx >= 0 && *idx <
thedim);
4897 for(j = lbeg[i + 1]; j > k; --j)
4899 assert(*idx >= 0 && *idx <
thedim);
4909 for(j = lbeg[i + 1]; j > k; --j)
4911 assert(*idx >= 0 && *idx <
thedim);
4925 for(j = lbeg[i + 1]; j > k; --j)
4927 assert(*idx >= 0 && *idx <
thedim);
4949 for(j = lbeg[i + 1]; j > k; --j)
4951 assert(*idx >= 0 && *idx <
thedim);
4952 tmp1 += vec[*idx] * (*val);
4953 tmp2 += vec2[*idx] * (*val);
4954 tmp3 += vec3[*idx++] * (*val++);
4976 Real* rhs,
int* ridx,
int rn,
Real eps)
4978 int i, j, k, r, c, n;
4981 int* cidx, *clen, *cbeg;
5004 assert(i >= 0 && i <
thedim);
5006 assert(r >= 0 && r <
thedim);
5008 x =
diag[r] * rhs[r];
5014 assert(c >= 0 && c <
thedim);
5017 val = &cval[cbeg[c]];
5018 idx = &cidx[cbeg[c]];
5023 assert(*idx >= 0 && *idx <
thedim);
5025 assert(k >= 0 && k <
thedim);
5046 if(rn > i * verySparseFactor4right)
5049 for(i = *ridx; i >= 0; --i)
5052 assert(r >= 0 && r <
thedim);
5053 x =
diag[r] * rhs[r];
5059 assert(c >= 0 && c <
thedim);
5062 val = &cval[cbeg[c]];
5063 idx = &cidx[cbeg[c]];
5068 assert(*idx >= 0 && *idx <
thedim);
5069 rhs[*idx++] -= x * (*val++);
5084 Real* rhs,
int* ridx,
int rn,
Real eps)
5089 int* cidx, *clen, *cbeg;
5107 if(rn > *ridx * verySparseFactor4right)
5110 for(i = *ridx; i >= 0; --i)
5112 assert(i >= 0 && i <
thedim);
5114 assert(r >= 0 && r <
thedim);
5115 x =
diag[r] * rhs[r];
5122 val = &cval[cbeg[c]];
5123 idx = &cidx[cbeg[c]];
5128 assert(*idx >= 0 && *idx <
thedim);
5129 rhs[*idx++] -= x * (*val++);
5141 assert(i >= 0 && i <
thedim);
5145 assert(r >= 0 && r <
thedim);
5147 x =
diag[r] * rhs[r];
5155 val = &cval[cbeg[c]];
5156 idx = &cidx[cbeg[c]];
5162 assert(k >= 0 && k <
thedim);
5188 Real* vec,
int* vidx,
Real* rhs,
int* ridx,
int rn,
Real eps,
5189 Real* vec2,
Real* rhs2,
int* ridx2,
int rn2,
Real eps2)
5191 int i, j, k, r, c, n;
5194 int* cidx, *clen, *cbeg;
5221 else if(*ridx2 > *ridx)
5223 else if(*ridx2 < *ridx)
5231 assert(i >= 0 && i <
thedim);
5234 assert(r >= 0 && r <
thedim);
5236 x =
diag[r] * rhs[r];
5237 x2 =
diag[r] * rhs2[r];
5247 val = &cval[cbeg[c]];
5248 idx = &cidx[cbeg[c]];
5256 assert(k >= 0 && k <
thedim);
5300 assert(k >= 0 && k <
thedim);
5325 assert(c >= 0 && c <
thedim);
5327 val = &cval[cbeg[c]];
5328 idx = &cidx[cbeg[c]];
5334 assert(k >= 0 && k <
thedim);
5339 y2 = -x2 * (*val++);
5349 y2 -= x2 * (*val++);
5355 if(rn + rn2 > i * verySparseFactor4right)
5367 assert(r >= 0 && r <
thedim);
5368 x =
diag[r] * rhs[r];
5369 x2 =
diag[r] * rhs2[r];
5376 assert(c >= 0 && c <
thedim);
5378 val = &cval[cbeg[c]];
5379 idx = &cidx[cbeg[c]];
5389 assert(*idx >= 0 && *idx <
thedim);
5390 rhs[*idx] -= x * (*val);
5391 rhs2[*idx++] -= x2 * (*val++);
5398 assert(*idx >= 0 && *idx <
thedim);
5399 rhs2[*idx++] -= x2 * (*val++);
5406 assert(c >= 0 && c <
thedim);
5409 val = &cval[cbeg[c]];
5410 idx = &cidx[cbeg[c]];
5415 assert(*idx >= 0 && *idx <
thedim);
5416 rhs[*idx++] -= x * (*val++);
5434 int* lrow, *lidx, *idx;
5447 assert(i >= 0 && i <
thedim);
5453 assert(k >= 0 && k <
l.
size);
5457 for(j = lbeg[i + 1]; j > k; --j)
5459 int m = ridx[n] = *idx++;
5460 assert(m >= 0 && m <
thedim);
5462 n += (y == 0) ? 1 : 0;
5463 y = y - x * (*val++);
5478 int* lrow, *lidx, *idx;
5491 assert(i >= 0 && i <
thedim);
5493 if((x = vec[lrow[i]]) != 0.0)
5496 assert(k >= 0 && k <
l.
size);
5500 for(j = lbeg[i + 1]; j > k; --j)
5502 assert(*idx >= 0 && *idx <
thedim);
5503 vec[*idx++] -= x * (*val++);
5511 Real* vec,
int* idx,
5512 Real* rhs,
int* ridx,
int rn,
5513 Real* forest,
int* forestNum,
int* forestIdx)
5516 assert(rn >= 0 && rn <=
thedim);
5526 int* it = forestIdx;
5530 for(i = j = 0; i < rn; ++i)
5533 assert(k >= 0 && k <
thedim);
5545 *forestNum = rn = j;
5555 for(i = j = 0; i < rn; ++i)
5558 assert(k >= 0 && k <
thedim);
5579 Real* vec,
int* idx,
5580 Real* rhs,
int* ridx,
int rn,
5582 Real* rhs2,
int* ridx2,
int rn2,
5583 Real* forest,
int* forestNum,
int* forestIdx)
5586 assert(rn >= 0 && rn <=
thedim);
5587 assert(rn2 >= 0 && rn2 <=
thedim);
5597 int* it = forestIdx;
5601 for(i = j = 0; i < rn; ++i)
5604 assert(k >= 0 && k <
thedim);
5616 *forestNum = rn = j;
5626 for(i = j = 0; i < rn; ++i)
5629 assert(k >= 0 && k <
thedim);
5641 if(rn2 >
thedim * verySparseFactor4right)
5656 for(i = j = 0; i < rn2; ++i)
5659 assert(k >= 0 && k <
thedim);
5699 Real* rhs,
int* ridx,
int& rn,
5701 Real* rhs2,
int* ridx2,
int& rn2,
5702 Real* forest,
int* forestNum,
int* forestIdx)
5706 assert(rn >= 0 && rn <=
thedim);
5707 assert(rn2 >= 0 && rn2 <=
thedim);
5716 int* it = forestIdx;
5718 for(i = j = 0; i < rn; ++i)
5721 assert(k >= 0 && k <
thedim);
5733 *forestNum = rn = j;
5737 for(i = j = 0; i < rn; ++i)
5740 assert(k >= 0 && k <
thedim);
5752 for(i = j = 0; i < rn2; ++i)
5755 assert(k >= 0 && k <
thedim);
5768 rn2 =
vSolveUright(vec2, idx2, rhs2, ridx2, rn2, eps2);
5779 Real* vec,
int* idx,
5780 Real* rhs,
int* ridx,
int rn,
5782 Real* rhs2,
int* ridx2,
int rn2,
5784 Real* rhs3,
int* ridx3,
int rn3,
5785 Real* forest,
int* forestNum,
int* forestIdx)
5788 vSolveLright3(rhs, ridx, rn, eps, rhs2, ridx2, rn2, eps2, rhs3, ridx3, rn3, eps3);
5789 assert(rn >= 0 && rn <=
thedim);
5790 assert(rn2 >= 0 && rn2 <=
thedim);
5791 assert(rn3 >= 0 && rn3 <=
thedim);
5801 int* it = forestIdx;
5805 for(i = j = 0; i < rn; ++i)
5808 assert(k >= 0 && k <
thedim);
5820 *forestNum = rn = j;
5830 for(i = j = 0; i < rn; ++i)
5833 assert(k >= 0 && k <
thedim);
5845 if(rn2 >
thedim * verySparseFactor4right)
5857 for(i = j = 0; i < rn2; ++i)
5860 assert(k >= 0 && k <
thedim);
5878 if(rn3 >
thedim * verySparseFactor4right)
5890 for(i = j = 0; i < rn3; ++i)
5893 assert(k >= 0 && k <
thedim);
5927 Real* rhs,
int* ridx,
int& rn,
5929 Real* rhs2,
int* ridx2,
int& rn2,
5931 Real* rhs3,
int* ridx3,
int& rn3,
5932 Real* forest,
int* forestNum,
int* forestIdx)
5934 vSolveLright3(rhs, ridx, rn, eps, rhs2, ridx2, rn2, eps2, rhs3, ridx3, rn3, eps3);
5935 assert(rn >= 0 && rn <=
thedim);
5936 assert(rn2 >= 0 && rn2 <=
thedim);
5937 assert(rn3 >= 0 && rn3 <=
thedim);
5946 int* it = forestIdx;
5948 for(i = j = 0; i < rn; ++i)
5951 assert(k >= 0 && k <
thedim);
5963 *forestNum = rn = j;
5967 for(i = j = 0; i < rn; ++i)
5970 assert(k >= 0 && k <
thedim);
5982 for(i = j = 0; i < rn2; ++i)
5985 assert(k >= 0 && k <
thedim);
5996 for(i = j = 0; i < rn3; ++i)
5999 assert(k >= 0 && k <
thedim);
6011 rn2 =
vSolveUright(vec2, idx2, rhs2, ridx2, rn2, eps2);
6012 rn3 =
vSolveUright(vec3, idx3, rhs3, ridx3, rn3, eps3);
6024 Real* rhs,
int* ridx,
int rn)
6027 assert(rn >= 0 && rn <=
thedim);
6029 if(rn >
thedim * verySparseFactor4right)
6043 for(i = j = 0; i < rn; ++i)
6046 assert(k >= 0 && k <
thedim);
6075 Real* vec,
int* idx,
6076 Real* rhs,
int* ridx,
int rn)
6082 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6086 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6103 Real* vec,
int* idx,
6104 Real* rhs,
int* ridx,
int rn,
6106 Real* rhs2,
int* ridx2,
int rn2)
6112 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6118 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6132 Real* vec,
int* idx,
6133 Real* rhs,
int* ridx,
int& rn,
6134 Real* vec2,
int* idx2,
6135 Real* rhs2,
int* ridx2,
int& rn2)
6140 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6142 rn2 =
solveUleft(eps, vec2, idx2, rhs2, ridx2, rn2);
6146 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6148 rn2 =
solveUleft(eps, vec2, idx2, rhs2, ridx2, rn2);
6159 Real* vec,
int* idx,
6160 Real* rhs,
int* ridx,
int rn,
6162 Real* rhs2,
int* ridx2,
int rn2,
6164 Real* rhs3,
int* ridx3,
int rn3)
6170 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6178 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6195 Real* vec,
int* idx,
6196 Real* rhs,
int* ridx,
int& rn,
6197 Real* vec2,
int* idx2,
6198 Real* rhs2,
int* ridx2,
int& rn2,
6199 Real* vec3,
int* idx3,
6200 Real* rhs3,
int* ridx3,
int& rn3)
6205 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6207 rn2 =
solveUleft(eps, vec2, idx2, rhs2, ridx2, rn2);
6209 rn3 =
solveUleft(eps, vec3, idx3, rhs3, ridx3, rn3);
6213 rn =
solveUleft(eps, vec, idx, rhs, ridx, rn);
6215 rn2 =
solveUleft(eps, vec2, idx2, rhs2, ridx2, rn2);
6217 rn3 =
solveUleft(eps, vec3, idx3, rhs3, ridx3, rn3);
6229 Real* rhs2,
int* ridx2,
int rn2)
void solveUleft(Real *work, Real *vec)
Rational spxAbs(const Rational &r)
Absolute.
int * len
used nonzeros per row vectors
bool isNotZero(Real a, Real eps=Param::epsilon())
returns true iff |a| > eps
void solveLleft(Real *vec) const
int updateType
type of updates to be used.
void solveUpdateRight2(Real *vec1, Real *vec2)
void updateNoClear(int p_col, const Real *p_work, const int *p_idx, int num)
int solveUright2eps(Real *work1, Real *vec1, Real *work2, Real *vec2, int *nonz, Real eps)
void vSolveLright3(Real *vec, int *ridx, int &rn, Real eps, Real *vec2, int *ridx2, int &rn2, Real eps2, Real *vec3, int *ridx3, int &rn3, Real eps3)
int solveRight2update(Real *vec1, Real *vec2, Real *rhs1, Real *rhs2, int *nonz, Real eps, Real *forest, int *forestNum, int *forestIdx)
Dring list
Double linked ringlist of vector indices in the order they appear in the column file.
int * max
maximum available nonzeros per row: start[i] + max[i] == start[elem[i].next->idx] len[i] <= max[i]...
static const Real verySparseFactor4left
int vSolveRight4update(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *forest, int *forestNum, int *forestIdx)
void forestMinColMem(int size)
Memory allocation routines.
void vSolveRight4update3sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real eps2, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2, Real eps3, Real *vec3, int *idx3, Real *rhs3, int *ridx3, int &rn3, Real *forest, int *forestNum, int *forestIdx)
sparse version of above method
Pring * pivot_rowNZ
lists for rows to number of nonzeros
int size() const
Number of used indices.
struct soplex::CLUFactor::U::Col col
int * start
starting positions in val and idx
int solveLleftForest(Real *vec, int *, Real)
Real * rval
values of rows of L
Exception classes for SoPlex.
#define init2DR(elem, ring)
void solveUleftNoNZ(Real eps, Real *vec, Real *rhs, int *rhsidx, int rhsn)
Real maxabs
maximum abs number in L and U
int vSolveRight4update3(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real eps2, Real *rhs2, int *ridx2, int rn2, Real *vec3, Real eps3, Real *rhs3, int *ridx3, int rn3, Real *forest, int *forestNum, int *forestIdx)
void vSolveLeft3sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2, Real *vec3, int *idx3, Real *rhs3, int *ridx3, int &rn3)
sparse version of solving 3 systems of equations
Real * s_max
maximum absolute value per row (or -1)
static void enQueueMin(int *heap, int *size, int elem)
int size
size of array idx
R & value(int n)
Reference to value of n 'th nonzero.
int * rorig
original row permutation
void update(int p_col, Real *p_work, const int *p_idx, int num)
void solveUright(Real *wrk, Real *vec) const
Dring * elem
Array of ring elements.
void solveLeft(Real *vec, Real *rhs)
#define ASSERT_WARN(prefix, expr)
Macro to turn some assertions into warnings.
Real initMaxabs
maximum abs number in initail Matrix
int mkwtz
markowitz number of pivot
Pring * pivot_col
column index handlers for Real linked list
int vSolveLeft2(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real *rhs2, int *ridx2, int rn2)
Real * diag
Array of pivot elements.
Perm row
row permutation matrices
Dring * elem
Array of ring elements.
Perm col
column permutation matrices
void solveUpdateRight(Real *vec)
int * orig
orig[p] original index from p
int solveRight4update(Real *vec, int *nonz, Real eps, Real *rhs, Real *forest, int *forestNum, int *forestIdx)
void vSolveLright(Real *vec, int *ridx, int &rn, Real eps)
Real lMemMult
factor of minimum Memory * number of nonzeros
void eliminateRowSingletons()
virtual void start()=0
start timer, resume accounting user, system and real time.
Real * work
Working array: must always be left as 0!
void forestUpdate(int col, Real *work, int num, int *nonz)
Performs the Forrest-Tomlin update of the LU factorization.
virtual Real stop()=0
stop timer, return accounted user time.
void spx_alloc(T &p, int n=1)
Allocate memory.
void solveLleftForestNoNZ(Real *vec)
static const Real verySparseFactor4right
int * len
used nonzeros per column vector
#define SOPLEX_FACTOR_MARKER
void solveUpdateLeft2(Real *vec1, Real *vec2)
int & index(int n)
Reference to index of n 'th nonzero.
int solveLleftEps(Real *vec, int *nonz, Real eps)
int size
size of arrays val and idx
void solveUright2(Real *work1, Real *vec1, Real *work2, Real *vec2)
SLinSolver::Status stat
Status indicator.
Pring * pivot_row
row index handlers for Real linked list
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
int used
used entries of arrays idx and val
void solveLright(Real *vec)
void vSolveUpdateRightNoNZ(Real *vec, Real)
int startSize
size of array start
void vSolveLright2(Real *vec, int *ridx, int &rn, Real eps, Real *vec2, int *ridx2, int &rn2, Real eps2)
Pring * pivot_colNZ
lists for columns to number of nonzeros
static Real epsilonUpdate()
int factorCount
Number of factorizations.
Real * val
hold nonzero values: this is only initialized in the end of the factorization with DEFAULT updates...
int stage
stage of the structure
int pos
position of pivot column in row
int firstUnused
number of first unused L vector
Temp temp
Temporary storage.
void setPivot(const int p_stage, const int p_col, const int p_row, const Real val)
void solveUpdateLeft(Real *vec)
void eliminateNucleus(const Real eps, const Real threshold)
void vSolveRight4update2sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real eps2, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2, Real *forest, int *forestNum, int *forestIdx)
sparse version of above method
int thedim
dimension of factorized matrix
struct soplex::CLUFactor::U::Row row
int * start
starting positions in val and idx
Debugging, floating point type and parameter definitions.
int size
size of arrays val and idx
void spx_realloc(T &p, int n)
Change amount of allocated memory.
int * idx
indices of L vectors
void factor(const SVector **vec, Real threshold, Real eps)
epsilon for zero detection
int * perm
perm[i] permuted index from i
bool isConsistent() const
void eliminateColSingletons()
void solveUleft2(Real *work1, Real *vec1, Real *work2, Real *vec2)
Everything should be within this namespace.
void vSolveRightNoNZ(Real *vec, Real eps, Real *rhs, int *ridx, int rn)
void remaxRow(int p_row, int len)
int vSolveLeft(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn)
int solveLleft2forest(Real *vec1, int *, Real *vec2, Real)
void vSolveLeftNoNZ(Real eps, Real *vec, Real *rhs, int *ridx, int rn)
int firstUpdate
number of first update L vector
Pring pivots
ring of selected pivot rows
int vSolveLeft3(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real *rhs2, int *ridx2, int rn2, Real *vec3, Real *rhs3, int *ridx3, int rn3)
Real rowMemMult
factor of minimum Memory * number of nonzeros
void solveLright2(Real *vec1, Real *vec2)
Dring list
Double linked ringlist of vector indices in the order they appear in the row file.
int vSolveRight4update2(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real eps2, Real *rhs2, int *ridx2, int rn2, Real *forest, int *forestNum, int *forestIdx)
Timer * factorTime
Time spent in factorizations.
void clear()
clears the structure
int solveLeft2(Real *vec1, int *nonz, Real *vec2, Real eps, Real *rhs1, Real *rhs2)
void init(int p_dim)
initialization
static int deQueueMax(int *heap, int *size)
int solveLeftEps(Real *vec, Real *rhs, int *nonz, Real eps)
void vSolveUrightNoNZ(Real *vec, Real *rhs, int *ridx, int rn, Real eps)
void forestReMaxCol(int col, int len)
Implementation of sparse LU factorization.
int * idx
hold row indices of nonzeros
int idx
index of pivot row
void eliminatePivot(int prow, int pos, Real eps)
void remaxCol(int p_col, int len)
int * ridx
indices of rows of L
int vSolveUright2(Real *vec, int *vidx, Real *rhs, int *ridx, int rn, Real eps, Real *vec2, Real *rhs2, int *ridx2, int rn2, Real eps2)
Real colMemMult
factor of minimum Memory * number of nonzeros
int updateRow(int r, int lv, int prow, int pcol, Real pval, Real eps)
int vSolveUpdateRight(Real *vec, int *ridx, int n, Real eps)
int * max
maximum available nonzeros per colunn: start[i] + max[i] == start[elem[i].next->idx] len[i] <= max[i]...
static const Real verySparseFactor
int makeLvec(int p_len, int p_row)
void updateSolutionVectorLright(Real change, int j, Real &vec, int *idx, int &nnz)
int * row
column indices of L vectors
void vSolveLeft2sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2)
sparse version of solving 2 systems of equations
static Real epsilonPivot()
int * rbeg
start of rows in rval and ridx
int * s_cact
lengths of columns of active submatrix
void solveRight(Real *vec, Real *rhs)
void initFactorMatrix(const SVector **vec, const Real eps)
void solveLleft2(Real *vec1, int *, Real *vec2, Real)
static void enQueueMax(int *heap, int *size, int elem)
Exception class for status exceptions during the computationsThis class is derived from the SoPlex ex...
The loaded matrix is singular.
int nzCnt
number of nonzeros in U
void selectPivots(Real threshold)
Real * val
hold nonzero values
bool isZero(Real a, Real eps=Param::epsilon())
returns true iff |a| <= eps
int * rperm
original row permutation
int * start
starting positions in val and idx
int * idx
hold column indices of nonzeros
int used
used entries of array idx
void solveRight2(Real *vec1, Real *vec2, Real *rhs1, Real *rhs2)
int vSolveUright(Real *vec, int *vidx, Real *rhs, int *ridx, int rn, Real eps)
int solveUrightEps(Real *vec, int *nonz, Real eps, Real *rhs)
Real * val
values of L vectors
void spx_free(T &p)
Release memory.
void solveLleftNoNZ(Real *vec)
static int deQueueMin(int *heap, int *size)