35 #include <qpOASES/Matrices.hpp> 62 return getSparseSubmatrix(irows->
getLength(), rowsNumbers, icols->
getLength(), colsNumbers, rowoffset, coloffset, numNonzeros, irn, jcn, avals, only_lower_triangular);
79 return getSparseSubmatrix(irows->
getLength(), rowsNumbers, 1, &idx_icol, rowoffset, coloffset, numNonzeros, irn, jcn, avals, only_lower_triangular);
96 return getSparseSubmatrix(1, &idx_row, icols->
getLength(), colsNumbers, rowoffset, coloffset, numNonzeros, irn, jcn, avals, only_lower_triangular);
120 memcpy( val_new,val, ((
uint_t)(nRows*nCols))*
sizeof(
real_t) );
121 dupl =
new DenseMatrix(nRows, nCols, nCols, val_new);
135 return val[i*(leaDim+1)];
145 for ( i=0; i<nRows; ++i )
146 for ( j=0; j<i; ++j )
172 for (i = 0; i < icols->
length; i++)
173 row[i] = val[rNum*leaDim+icols->
number[i]];
175 for (i = 0; i < icols->
length; i++)
176 row[i] = -val[rNum*leaDim+icols->
number[i]];
178 for (i = 0; i < icols->
length; i++)
179 row[i] = alpha*val[rNum*leaDim+icols->
number[i]];
184 for (i = 0; i < nCols; i++)
185 row[i] = val[rNum*leaDim+i];
187 for (i = 0; i < nCols; i++)
188 row[i] = -val[rNum*leaDim+i];
190 for (i = 0; i < nCols; i++)
191 row[i] = alpha*val[rNum*leaDim+i];
202 for (i = 0; i < irows->
length; i++)
203 col[i] = val[irows->
number[i]*leaDim+cNum];
205 for (i = 0; i < irows->
length; i++)
206 col[i] = -val[irows->
number[i]*leaDim+cNum];
208 for (i = 0; i < irows->
length; i++)
209 col[i] = alpha*val[irows->
number[i]*leaDim+cNum];
215 int_t icolsLength,
const int_t*
const icolsNumber,
223 if ( only_lower_triangular ==
BT_FALSE )
227 if (jcn != 0 || avals != 0)
229 for (j = 0; j<irowsLength; j++)
231 irA = irowsNumber[j] * leaDim;
232 for (i = 0; i<icolsLength; i++)
239 for (j = 0; j<irowsLength; j++)
241 irA = irowsNumber[j] * leaDim;
242 for (i = 0; i<icolsLength; i++)
244 v = val[irA+icolsNumber[i]];
247 irn[numNonzeros] = j+rowoffset;
248 jcn[numNonzeros] = i+coloffset;
249 avals[numNonzeros] =
v;
260 if (jcn != 0 || avals != 0)
262 for (j = 0; j<irowsLength; j++)
264 irA = irowsNumber[j] * leaDim;
265 for (i = 0; i<=j; i++)
272 for (j = 0; j<irowsLength; j++)
274 irA = irowsNumber[j] * leaDim;
275 for (i = 0; i<=j; i++)
277 v = val[irA+irowsNumber[i]];
280 irn[numNonzeros] = j+rowoffset;
281 jcn[numNonzeros] = i+coloffset;
282 avals[numNonzeros] =
v;
295 unsigned long _xN = (
unsigned long)xN;
296 unsigned long _nRows = (
unsigned long)nRows;
297 unsigned long _nCols = (
unsigned long)nCols;
298 unsigned long _leaDim = (
unsigned long)
getMax(1,nCols);
299 unsigned long _xLD = (
unsigned long)
getMax(1,xLD);
300 unsigned long _yLD = (
unsigned long)
getMax(1,yLD);
303 GEMM(
"TRANS",
"NOTRANS", &_nRows, &_xN, &_nCols, &alpha, val, &_leaDim, x, &_xLD, &beta,
y, &_yLD);
309 unsigned long _xN = (
unsigned long)xN;
310 unsigned long _nRows = (
unsigned long)nRows;
311 unsigned long _nCols = (
unsigned long)nCols;
312 unsigned long _leaDim = (
unsigned long)
getMax(1,nCols);
313 unsigned long _xLD = (
unsigned long)
getMax(1,xLD);
314 unsigned long _yLD = (
unsigned long)
getMax(1,yLD);
317 GEMM(
"NOTRANS",
"NOTRANS", &_nCols, &_xN, &_nRows, &alpha, val, &_leaDim, x, &_xLD, &beta,
y, &_yLD);
330 for (k = 0; k < xN; k++)
331 for (j = 0; j < irows->
length; j++)
334 for (k = 0; k < xN; k++)
335 for (j = 0; j < irows->
length; j++)
336 y[j+k*yLD] = -
y[j+k*yLD];
338 for (k = 0; k < xN; k++)
339 for (j = 0; j < irows->
length; j++)
344 for (k = 0; k < xN; k++)
345 for (j = 0; j < irows->
length; j++)
347 row = irows->
iSort[j];
350 for (i = 0; i < nCols; i++)
351 y[iy] += val[irA+i] * x[k*xLD+i];
354 for (k = 0; k < xN; k++)
355 for (j = 0; j < irows->
length; j++)
357 row = irows->
iSort[j];
360 for (i = 0; i < nCols; i++)
361 y[iy] -= val[irA+i] * x[k*xLD+i];
364 for (k = 0; k < xN; k++)
365 for (j = 0; j < irows->
length; j++)
367 row = irows->
iSort[j];
370 for (i = 0; i < nCols; i++)
371 y[iy] += alpha * val[irA+i] * x[k*xLD+i];
375 for (k = 0; k < xN; k++)
376 for (j = 0; j < irows->
length; j++)
378 row = irows->
iSort[j];
381 for (i = 0; i < icols->
length; i++)
383 col = icols->
iSort[i];
388 for (k = 0; k < xN; k++)
389 for (j = 0; j < irows->
length; j++)
391 row = irows->
iSort[j];
394 for (i = 0; i < icols->
length; i++)
396 col = icols->
iSort[i];
401 for (k = 0; k < xN; k++)
402 for (j = 0; j < irows->
length; j++)
404 row = irows->
iSort[j];
407 for (i = 0; i < icols->
length; i++)
409 col = icols->
iSort[i];
417 for (k = 0; k < xN; k++)
418 for (j = 0; j < irows->
length; j++)
419 y[irows->
number[j]+k*yLD] = 0.0;
421 for (k = 0; k < xN; k++)
422 for (j = 0; j < irows->
length; j++)
423 y[irows->
number[j]+k*yLD] = -
y[j+k*yLD];
425 for (k = 0; k < xN; k++)
426 for (j = 0; j < irows->
length; j++)
427 y[irows->
number[j]+k*yLD] *= beta;
431 for (k = 0; k < xN; k++)
432 for (j = 0; j < irows->
length; j++)
437 for (i = 0; i < nCols; i++)
438 y[iy] += val[irA+i] * x[k*xLD+i];
441 for (k = 0; k < xN; k++)
442 for (j = 0; j < irows->
length; j++)
447 for (i = 0; i < nCols; i++)
448 y[iy] -= val[irA+i] * x[k*xLD+i];
451 for (k = 0; k < xN; k++)
452 for (j = 0; j < irows->
length; j++)
457 for (i = 0; i < nCols; i++)
458 y[iy] += alpha * val[irA+i] * x[k*xLD+i];
462 for (k = 0; k < xN; k++)
463 for (j = 0; j < irows->
length; j++)
468 for (i = 0; i < icols->
length; i++)
470 col = icols->
iSort[i];
475 for (k = 0; k < xN; k++)
476 for (j = 0; j < irows->
length; j++)
481 for (i = 0; i < icols->
length; i++)
483 col = icols->
iSort[i];
488 for (k = 0; k < xN; k++)
489 for (j = 0; j < irows->
length; j++)
494 for (i = 0; i < icols->
length; i++)
496 col = icols->
iSort[i];
511 for (k = 0; k < xN; k++)
512 for (j = 0; j < icols->
length; j++)
515 for (k = 0; k < xN; k++)
516 for (j = 0; j < icols->
length; j++)
517 y[j+k*yLD] = -
y[j+k*yLD];
519 for (k = 0; k < xN; k++)
520 for (j = 0; j < icols->
length; j++)
524 for (k = 0; k < xN; k++)
525 for (j = 0; j < irows->
length; j++)
527 row = irows->
iSort[j];
528 for (i = 0; i < icols->
length; i++)
530 col = icols->
iSort[i];
535 for (k = 0; k < xN; k++)
536 for (j = 0; j < irows->
length; j++)
538 row = irows->
iSort[j];
539 for (i = 0; i < icols->
length; i++)
541 col = icols->
iSort[i];
546 for (k = 0; k < xN; k++)
547 for (j = 0; j < irows->
length; j++)
549 row = irows->
iSort[j];
550 for (i = 0; i < icols->
length; i++)
552 col = icols->
iSort[i];
564 for (i = 0; i < nRows && i < nCols; i++)
565 val[i*(leaDim+1)] += alpha;
580 memcpy( v,val, ((
uint_t)(nRows*nCols))*
sizeof(
real_t) );
594 return duplicateSym();
606 memcpy( val_new,val, ((
uint_t)(nRows*nCols))*
sizeof(
real_t) );
607 dupl =
new SymDenseMat(nRows, nCols, nCols, val_new);
625 for (ii = 0; ii < xN; ii++)
626 for (jj = 0; jj < xN; jj++)
631 for (i=0;i<icols->
length * xN;++i)
635 for (j = 0; j < icols->
length; j++) {
636 irA = icols->
number[j] * leaDim;
637 for (i = 0; i < icols->
length; i++)
640 for (k = 0; k < xN; k++)
641 Ax[j + k * icols->
length] += h * x[k*xLD+icols->
number[i]];
645 for (ii = 0; ii < icols->
length; ++ii) {
647 for (jj = 0; jj < xN; ++jj) {
648 for (kk = 0; kk < xN; ++kk) {
649 y[kk + jj*yLD] += x[col + jj*xLD] * Ax[ii + kk*icols->
length];
663 : nRows(nr), nCols(nc), ir(r), jc(c), jd(0), val(v) {
doNotFreeMemory(); }
675 for (j = 0; j <
nCols; j++)
678 for (i = 0; i <
nRows; i++)
682 val[nnz++] =
v[i*ld+j];
706 if (
ir != 0)
delete[]
ir;
708 if (
jc != 0)
delete[]
jc;
710 if (
val != 0)
delete[]
val;
727 for (i = 0; i < length; i++) dupl->
ir[i] =
ir[i];
728 for (i = 0; i <=
nCols; i++) dupl->
jc[i] =
jc[i];
729 for (i = 0; i < length; i++) dupl->
val[i] =
val[i];
734 for (i = 0; i <
nCols; i++) dupl->
jd[i] =
jd[i];
755 return (entry <
jc[i+1] &&
ir[entry] == i) ?
val[entry] : 0.0;
766 for (j = 0; j <
nCols; ++j)
768 if (
jc[j+1] >
jc[j]+1 )
771 if ( (
jc[j+1] ==
jc[j]+1 ) && (
ir[
jc[j]] != j ) )
796 for ( j=0; j <
nCols; ++j ) {
797 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++) {};
798 norm += (i <
jc[j+1] &&
ir[i] == rNum) ?
val[i]*
val[i] : 0.0;
803 for ( j=0; j <
nCols; ++j ) {
804 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++) {};
823 for (k = 0; k < icols->
length; k++)
826 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++);
827 row[icols->
iSort[k]] = (i <
jc[j+1] &&
ir[i] == rNum) ?
val[i] : 0.0;
830 for (k = 0; k < icols->
length; k++)
833 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++);
834 row[icols->
iSort[k]] = (i <
jc[j+1] &&
ir[i] == rNum) ? -
val[i] : 0.0;
837 for (k = 0; k < icols->
length; k++)
840 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++);
841 row[icols->
iSort[k]] = (i <
jc[j+1] &&
ir[i] == rNum) ? alpha*
val[i] : 0.0;
847 for (j = 0; j <
nCols; j++)
849 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++);
850 row[j] = (i <
jc[j+1] &&
ir[i] == rNum) ?
val[i] : 0.0;
853 for (j = 0; j < icols->
length; j++)
855 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++);
856 row[j] = (i <
jc[j+1] &&
ir[i] == rNum) ? -
val[i] : 0.0;
859 for (j = 0; j < icols->
length; j++)
861 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < rNum; i++);
862 row[j] = (i <
jc[j+1] &&
ir[i] == rNum) ? alpha*
val[i] : 0.0;
876 while (i <
jc[cNum+1] && j < irows->length)
880 col[irows->
iSort[j++]] = 0.0;
884 while (i <
jc[cNum+1] && j < irows->length)
888 col[irows->
iSort[j++]] = 0.0;
892 while (i <
jc[cNum+1] && j < irows->length)
894 col[irows->
iSort[j++]] = alpha *
val[i++];
896 col[irows->
iSort[j++]] = 0.0;
901 while (j < irows->length)
902 col[irows->
iSort[j++]] = 0.0;
908 int_t icolsLength,
const int_t*
const icolsNumber,
918 for (i=0; i<
nRows; i++)
919 rowNumberInv[i] = -1;
920 for (i=0; i<irowsLength; i++)
921 rowNumberInv[irowsNumber[i]] = i;
924 if ( only_lower_triangular ==
BT_FALSE )
928 if (jcn != 0 || avals != 0)
930 for (k = 0; k < icolsLength; k++)
933 for (i =
jc[j]; i <
jc[j+1]; i++)
935 l = rowNumberInv[
ir[i]];
943 for (k = 0; k < icolsLength; k++)
946 for (i =
jc[j]; i <
jc[j+1]; i++)
948 l = rowNumberInv[
ir[i]];
951 irn[numNonzeros] = l+rowoffset;
952 jcn[numNonzeros] = k+coloffset;
953 avals[numNonzeros] =
val[i];
964 if (jcn != 0 || avals != 0)
966 for (k = 0; k < icolsLength; k++)
969 for (i =
jc[j]; i <
jc[j+1]; i++)
971 l = rowNumberInv[
ir[i]];
979 for (k = 0; k < icolsLength; k++)
982 for (i =
jc[j]; i <
jc[j+1]; i++)
984 l = rowNumberInv[
ir[i]];
987 irn[numNonzeros] = l+rowoffset;
988 jcn[numNonzeros] = k+coloffset;
989 avals[numNonzeros] =
val[i];
996 delete [] rowNumberInv;
1007 for (k = 0; k < xN; k++)
1008 for (j = 0; j <
nRows; j++)
1011 for (k = 0; k < xN; k++)
1012 for (j = 0; j <
nRows; j++)
1013 y[j+k*yLD] = -
y[j+k*yLD];
1015 for (k = 0; k < xN; k++)
1016 for (j = 0; j <
nRows; j++)
1020 for (k = 0; k < xN; k++)
1021 for (j = 0; j <
nCols; j++)
1022 for (i =
jc[j]; i <
jc[j+1]; i++)
1023 y[
ir[i]+k*yLD] +=
val[i] * x[j+k*xLD];
1025 for (k = 0; k < xN; k++)
1026 for (j = 0; j <
nCols; j++)
1027 for (i = jc[j]; i < jc[j+1]; i++)
1028 y[
ir[i]+k*yLD] -=
val[i] * x[j+k*xLD];
1030 for (k = 0; k < xN; k++)
1031 for (j = 0; j <
nCols; j++)
1032 for (i = jc[j]; i < jc[j+1]; i++)
1033 y[
ir[i]+k*yLD] += alpha *
val[i] * x[j+k*xLD];
1045 for (k = 0; k < xN; k++)
1046 for (j = 0; j <
nCols; j++)
1049 for (k = 0; k < xN; k++)
1050 for (j = 0; j <
nCols; j++)
1051 y[j+k*yLD] = -
y[j+k*yLD];
1053 for (k = 0; k < xN; k++)
1054 for (j = 0; j <
nCols; j++)
1058 for (k = 0; k < xN; k++)
1059 for (j = 0; j <
nCols; j++)
1060 for (i =
jc[j]; i <
jc[j+1]; i++)
1061 y[j+k*yLD] +=
val[i] * x[
ir[i]+k*xLD];
1063 for (k = 0; k < xN; k++)
1064 for (j = 0; j <
nCols; j++)
1065 for (i = jc[j]; i < jc[j+1]; i++)
1066 y[j+k*yLD] -=
val[i] * x[
ir[i]+k*xLD];
1068 for (k = 0; k < xN; k++)
1069 for (j = 0; j <
nCols; j++)
1070 for (i = jc[j]; i < jc[j+1]; i++)
1071 y[j+k*yLD] += alpha *
val[i] * x[
ir[i]+k*xLD];
1081 long i, j, k, l,
col;
1089 for (k = 0; k < xN; k++)
1090 for (j = 0; j < irows->
length; j++)
1093 for (k = 0; k < xN; k++)
1094 for (j = 0; j < irows->
length; j++)
1095 y[j+k*yLD] = -
y[j+k*yLD];
1097 for (k = 0; k < xN; k++)
1098 for (j = 0; j < irows->
length; j++)
1104 for (k = 0; k < xN; k++)
1105 for (j = 0; j < irows->
length; j++)
1106 y[irows->
number[j]+k*yLD] = 0.0;
1108 for (k = 0; k < xN; k++)
1109 for (j = 0; j < irows->
length; j++)
1112 for (k = 0; k < xN; k++)
1113 for (j = 0; j < irows->
length; j++)
1114 y[irows->
number[j]+k*yLD] *= beta;
1122 for (k = 0; k < xN*yfullLength; k++)
1129 for (l = 0; l < icols->
length; l++)
1131 col = icols->
iSort[l];
1136 for (i =
jc[j]; i <
jc[j+1]; i++)
1137 ytmp[
ir[i]] +=
val[i] * xcol;
1145 for (l = 0; l < icols->
length; l++)
1147 col = icols->
iSort[l];
1149 for (k=0; k<xN; k++)
1151 xcols[k] = x[k*xLD+
col];
1157 for (i =
jc[j]; i <
jc[j+1]; i++)
1158 for (k=0; k<xN; k++)
1160 ytmp[k*yfullLength+
ir[i]] +=
val[i] * xcols[k];
1170 for (col = 0; col <
nCols; col++)
1174 for (i =
jc[col]; i <
jc[col+1]; i++)
1175 ytmp[
ir[i]] +=
val[i] * xcol;
1182 for (col = 0; col <
nCols; col++)
1185 for (k=0; k<xN; k++)
1187 xcols[k] = x[k*xLD+
col];
1191 for (i =
jc[col]; i <
jc[col+1]; i++)
1192 for (k=0; k<xN; k++)
1193 ytmp[k*yfullLength+
ir[i]] +=
val[i] * xcols[k];
1202 for (k = 0; k < xN; k++)
1203 for (j = 0; j < irows->
length; j++)
1204 y[j+k*yLD] = alpha*ytmp[irows->
number[j]+k*yfullLength];
1206 for (k = 0; k < xN; k++)
1207 for (j = 0; j < irows->
length; j++)
1208 y[j+k*yLD] += alpha*ytmp[irows->
number[j]+k*yfullLength];
1210 for (k = 0; k < xN; k++)
1211 for (j = 0; j < irows->
length; j++)
1212 y[j+k*yLD] = alpha*ytmp[irows->
number[j]+k*yfullLength]-
y[j+k*yLD];
1214 for (k = 0; k < xN; k++)
1215 for (j = 0; j < irows->
length; j++)
1216 y[j+k*yLD] = alpha*ytmp[irows->
number[j]+k*yfullLength]+beta*
y[j+k*yLD];
1221 for (k = 0; k < xN; k++)
1222 for (j = 0; j < irows->
length; j++)
1223 y[irows->
number[j]+k*yLD] = alpha*ytmp[irows->
number[j]+k*yfullLength];
1225 for (k = 0; k < xN; k++)
1226 for (j = 0; j < irows->
length; j++)
1227 y[irows->
number[j]+k*yLD] = alpha*ytmp[irows->
number[j]+k*yfullLength]+
y[j+k*yLD];
1229 for (k = 0; k < xN; k++)
1230 for (j = 0; j < irows->
length; j++)
1231 y[irows->
number[j]+k*yLD] = alpha*ytmp[irows->
number[j]+k*yfullLength]-
y[j+k*yLD];
1233 for (k = 0; k < xN; k++)
1234 for (j = 0; j < irows->
length; j++)
1235 y[irows->
number[j]+k*yLD] = alpha*ytmp[irows->
number[j]+k*yfullLength]+beta*
y[j+k*yLD];
1246 long i, j, k, l,
col;
1250 for (k = 0; k < xN; k++)
1251 for (j = 0; j < icols->
length; j++)
1254 for (k = 0; k < xN; k++)
1255 for (j = 0; j < icols->
length; j++)
1256 y[j+k*yLD] = -
y[j+k*yLD];
1258 for (k = 0; k < xN; k++)
1259 for (j = 0; j < icols->
length; j++)
1267 for (k = 0; k < xN; k++)
1269 for (i = 0; i < xfullLength; i++)
1271 for (i = 0; i < irows->
length; i++)
1272 xtmp[irows->
number[i]] = x[k*xLD+i];
1273 for (l = 0; l < icols->
length; l++)
1275 col = icols->
iSort[l];
1278 for (i =
jc[j]; i <
jc[j+1]; i++)
1279 yadd +=
val[i] * xtmp[
ir[i]];
1280 y[
col] += alpha*yadd;
1304 val[
jd[i]] += alpha;
1321 for (j = 0; j <
nCols; j++)
1323 for (i =
jc[j]; i <
jc[j+1] &&
ir[i] < j; i++);
1341 for (j = 0; j <
nCols; j++)
1342 for (i =
jc[j]; i <
jc[j+1]; i++)
1343 v[
ir[i] * nCols + j] =
val[i];
1361 fprintf( output_file,
"%sjc[%d] = %d\n",prefix,(
int)i,(
int)(
jc[i]) );
1364 fprintf( output_file,
"%sir[%d] = %d\n",prefix,(
int)i,(
int)(
ir[i]) );
1367 fprintf( output_file,
"%sval[%d] = %23.16e\n",prefix,(
int)i,
val[i] );
1388 for (j = 0; j <
nRows; j++)
1391 for (i = 0; i <
nCols; i++)
1395 val[nnz++] = v[j*ld+i];
1419 if (
jr != 0)
delete[]
jr;
1421 if (
ic != 0)
delete[]
ic;
1423 if (
val != 0)
delete[]
val;
1441 for (i = 0; i < length; i++) dupl->
jr[i] =
jr[i];
1442 for (i = 0; i <=
nCols; i++) dupl->
ic[i] =
ic[i];
1443 for (i = 0; i < length; i++) dupl->
val[i] =
val[i];
1448 for (i = 0; i <
nCols; i++) dupl->
jd[i] =
jd[i];
1469 return (entry <
jr[i+1] &&
ic[entry] == i) ?
val[entry] : 0.0;
1480 for (i = 0; i <
nRows; ++i)
1482 if (
jr[i+1] >
jr[i]+1 )
1485 if ( (
jr[i+1] ==
jr[i]+1 ) && (
ic[
jr[i]] != i ) )
1520 while (j <
jr[rNum+1] && i < icols->length)
1524 row[icols->
iSort[i++]] = 0.0;
1528 while (j <
jr[rNum+1] && i < icols->length)
1530 row[icols->
iSort[i++]] = -
val[j++];
1532 row[icols->
iSort[i++]] = 0.0;
1536 while (j <
jr[rNum+1] && i < icols->length)
1538 row[icols->
iSort[i++]] = alpha *
val[j++];
1540 row[icols->
iSort[i++]] = 0.0;
1545 while (i < icols->length)
1546 row[icols->
iSort[i++]] = 0.0;
1550 for (i = 0; i <
nCols; i++)
1554 for (j =
jr[rNum]; j <
jr[rNum+1]; j++)
1555 row[
ic[j]] =
val[j];
1557 for (j = jr[rNum]; j < jr[rNum+1]; j++)
1558 row[
ic[j]] = -
val[j];
1560 for (j = jr[rNum]; j < jr[rNum+1]; j++)
1561 row[
ic[j]] = alpha *
val[j];
1575 for (k = 0; k < irows->
length; k++)
1577 srt = irows->
iSort[k];
1579 for (i =
jr[j]; i <
jr[j+1] &&
ic[i] < cNum; i++);
1580 col[srt] = (i <
jr[j+1] &&
ic[i] == cNum) ?
val[i] : 0.0;
1583 for (k = 0; k < irows->
length; k++)
1585 srt = irows->
iSort[k];
1587 for (i =
jr[j]; i <
jr[j+1] &&
ic[i] < cNum; i++);
1588 col[srt] = (i <
jr[j+1] &&
ic[i] == cNum) ? -
val[i] : 0.0;
1591 for (k = 0; k < irows->
length; k++)
1593 srt = irows->
iSort[k];
1595 for (i =
jr[j]; i <
jr[j+1] &&
ic[i] < cNum; i++);
1596 col[srt] = (i <
jr[j+1] &&
ic[i] == cNum) ? alpha*
val[i] : 0.0;
1602 for (j = 0; j <
nCols; j++)
1604 for (i =
jr[j]; i <
jr[j+1] &&
ic[i] < cNum; i++);
1605 col[j] = (i <
jr[j+1] &&
ic[i] == cNum) ?
val[i] : 0.0;
1608 for (j = 0; j < irows->
length; j++)
1610 for (i =
jr[j]; i <
jr[j+1] &&
ic[i] < cNum; i++);
1611 col[j] = (i <
jr[j+1] &&
ic[i] == cNum) ? -
val[i] : 0.0;
1614 for (j = 0; j < irows->
length; j++)
1616 for (i =
jr[j]; i <
jr[j+1] &&
ic[i] < cNum; i++);
1617 col[j] = (i <
jr[j+1] &&
ic[i] == cNum) ? alpha*
val[i] : 0.0;
1624 int_t irowsLength,
const int_t*
const irowsNumber,
1625 int_t icolsLength,
const int_t*
const icolsNumber,
1629 fprintf(stderr,
"SparseMatrixRow::getSparseSubmatrix not implemented!\n");
1640 for (k = 0; k < xN; k++)
1641 for (j = 0; j <
nRows; j++)
1644 for (k = 0; k < xN; k++)
1645 for (j = 0; j <
nRows; j++)
1646 y[j+k*yLD] = -y[j+k*yLD];
1648 for (k = 0; k < xN; k++)
1649 for (j = 0; j <
nRows; j++)
1653 for (k = 0; k < xN; k++)
1654 for (j = 0; j <
nRows; j++)
1655 for (i =
jr[j]; i <
jr[j+1]; i++)
1656 y[j+k*yLD] +=
val[i] * x[
ic[i]+k*xLD];
1658 for (k = 0; k < xN; k++)
1659 for (j = 0; j <
nRows; j++)
1660 for (i = jr[j]; i < jr[j+1]; i++)
1661 y[j+k*yLD] -=
val[i] * x[
ic[i]+k*xLD];
1663 for (k = 0; k < xN; k++)
1664 for (j = 0; j <
nRows; j++)
1665 for (i = jr[j]; i < jr[j+1]; i++)
1666 y[j+k*yLD] += alpha *
val[i] * x[
ic[i]+k*xLD];
1678 for (k = 0; k < xN; k++)
1679 for (j = 0; j <
nCols; j++)
1682 for (k = 0; k < xN; k++)
1683 for (j = 0; j <
nCols; j++)
1684 y[j+k*yLD] = -y[j+k*yLD];
1686 for (k = 0; k < xN; k++)
1687 for (j = 0; j <
nCols; j++)
1691 for (k = 0; k < xN; k++)
1692 for (i = 0; i <
nRows; i++)
1693 for (j =
jr[i]; j <
jr[i+1]; j++)
1694 y[
ic[j]+k*yLD] +=
val[j] * x[i+k*xLD];
1696 for (k = 0; k < xN; k++)
1697 for (i = 0; i <
nRows; i++)
1698 for (j = jr[i]; j < jr[i+1]; j++)
1699 y[
ic[j]+k*yLD] -=
val[j] * x[i+k*xLD];
1701 for (k = 0; k < xN; k++)
1702 for (i = 0; i <
nRows; i++)
1703 for (j = jr[i]; j < jr[i+1]; j++)
1704 y[
ic[j]+k*yLD] += alpha *
val[j] * x[i+k*xLD];
1714 long i, j, k, l, srt,
row;
1719 for (k = 0; k < xN; k++)
1720 for (j = 0; j < irows->
length; j++)
1723 for (k = 0; k < xN; k++)
1724 for (j = 0; j < irows->
length; j++)
1725 y[j+k*yLD] = -y[j+k*yLD];
1727 for (k = 0; k < xN; k++)
1728 for (j = 0; j < irows->
length; j++)
1733 for (l = 0; l < irows->
length; l++)
1735 srt = irows->
iSort[l];
1736 row = irows->
number[srt];
1737 for (j =
jr[row]; j <
jr[row+1]; j++)
1738 for (k = 0; k < xN; k++)
1739 y[k*yLD+srt] +=
val[j] * x[k*xLD+
ic[j]];
1742 for (l = 0; l < irows->
length; l++)
1744 srt = irows->
iSort[l];
1745 row = irows->
number[srt];
1746 for (j =
jr[row]; j <
jr[row+1]; j++)
1747 for (k = 0; k < xN; k++)
1748 y[k*yLD+srt] -=
val[j] * x[k*xLD+
ic[j]];
1751 for (l = 0; l < irows->
length; l++)
1753 srt = irows->
iSort[l];
1754 row = irows->
number[srt];
1755 for (j =
jr[row]; j <
jr[row+1]; j++)
1756 for (k = 0; k < xN; k++)
1757 y[k*yLD+srt] += alpha *
val[j] * x[k*xLD+
ic[j]];
1761 for (l = 0; l < irows->
length; l++)
1763 srt = irows->
iSort[l];
1764 row = irows->
number[srt];
1767 while (j <
jr[row+1] && i < icols->length)
1770 for (k = 0; k < xN; k++)
1771 y[k*yLD+srt] +=
val[j] * x[k*xLD+icols->
iSort[i]];
1778 for (l = 0; l < irows->
length; l++)
1780 srt = irows->
iSort[l];
1781 row = irows->
number[srt];
1784 while (j <
jr[row+1] && i < icols->length)
1787 for (k = 0; k < xN; k++)
1788 y[k*yLD+srt] -=
val[j] * x[k*xLD+icols->
iSort[i]];
1795 for (l = 0; l < irows->
length; l++)
1797 srt = irows->
iSort[l];
1798 row = irows->
number[srt];
1801 while (j <
jr[row+1] && i < icols->length)
1804 for (k = 0; k < xN; k++)
1805 y[k*yLD+srt] += alpha *
val[j] * x[k*xLD+icols->
iSort[i]];
1815 for (k = 0; k < xN; k++)
1816 for (j = 0; j < irows->
length; j++)
1817 y[irows->
number[j]+k*yLD] = 0.0;
1819 for (k = 0; k < xN; k++)
1820 for (j = 0; j < irows->
length; j++)
1821 y[irows->
number[j]+k*yLD] = -y[j+k*yLD];
1823 for (k = 0; k < xN; k++)
1824 for (j = 0; j < irows->
length; j++)
1825 y[irows->
number[j]+k*yLD] *= beta;
1829 for (l = 0; l < irows->
length; l++)
1832 for (j =
jr[row]; j <
jr[row+1]; j++)
1833 for (k = 0; k < xN; k++)
1834 y[k*yLD+row] +=
val[j] * x[k*xLD+
ic[j]];
1837 for (l = 0; l < irows->
length; l++)
1840 for (j =
jr[row]; j <
jr[row+1]; j++)
1841 for (k = 0; k < xN; k++)
1842 y[k*yLD+row] -=
val[j] * x[k*xLD+
ic[j]];
1845 for (l = 0; l < irows->
length; l++)
1848 for (j =
jr[row]; j <
jr[row+1]; j++)
1849 for (k = 0; k < xN; k++)
1850 y[k*yLD+row] += alpha *
val[j] * x[k*xLD+
ic[j]];
1854 for (l = 0; l < irows->
length; l++)
1856 row = irows->
iSort[l];
1859 while (j <
jr[irows->
number[row]+1] && i < icols->length)
1862 for (k = 0; k < xN; k++)
1863 y[k*yLD+row] +=
val[j] * x[k*xLD+icols->
iSort[i]];
1870 for (l = 0; l < irows->
length; l++)
1872 row = irows->
iSort[l];
1875 while (j <
jr[irows->
number[row]+1] && i < icols->length)
1878 for (k = 0; k < xN; k++)
1879 y[k*yLD+row] -=
val[j] * x[k*xLD+icols->
iSort[i]];
1886 for (l = 0; l < irows->
length; l++)
1888 row = irows->
iSort[l];
1891 while (j <
jr[irows->
number[row]+1] && i < icols->length)
1894 for (k = 0; k < xN; k++)
1895 y[k*yLD+row] += alpha *
val[j] * x[k*xLD+icols->
iSort[i]];
1909 long i, j, k, l,
row, srt;
1912 for (k = 0; k < xN; k++)
1913 for (j = 0; j < icols->
length; j++)
1916 for (k = 0; k < xN; k++)
1917 for (j = 0; j < icols->
length; j++)
1918 y[j+k*yLD] = -y[j+k*yLD];
1920 for (k = 0; k < xN; k++)
1921 for (j = 0; j < icols->
length; j++)
1925 for (l = 0; l < irows->
length; l++)
1927 srt = irows->
iSort[l];
1928 row = irows->
number[srt];
1931 while (j <
jr[row+1] && i < icols->length)
1934 for (k = 0; k < xN; k++)
1935 y[k*yLD+icols->
iSort[i]] +=
val[j] * x[k*xLD+srt];
1942 for (l = 0; l < irows->
length; l++)
1944 srt = irows->
iSort[l];
1945 row = irows->
number[srt];
1948 while (j <
jr[row+1] && i < icols->length)
1951 for (k = 0; k < xN; k++)
1952 y[k*yLD+icols->
iSort[i]] -=
val[j] * x[k*xLD+srt];
1959 for (l = 0; l < irows->
length; l++)
1961 srt = irows->
iSort[l];
1962 row = irows->
number[srt];
1965 while (j <
jr[row+1] && i < icols->length)
1968 for (k = 0; k < xN; k++)
1969 y[k*yLD+icols->
iSort[i]] += alpha *
val[j] * x[k*xLD+srt];
1993 val[
jd[i]] += alpha;
2010 for (i = 0; i <
nRows; i++)
2012 for (j =
jr[i]; j <
jr[i+1] &&
ic[j] < i; j++);
2029 for (i = 0; i <
nRows; i++)
2030 for (j =
jr[i]; j <
jr[i+1]; j++)
2053 return duplicateSym();
2060 long i, length = jc[
nCols];
2069 for (i = 0; i < length; i++) dupl->
ir[i] = ir[i];
2070 for (i = 0; i <=
nCols; i++) dupl->
jc[i] = jc[i];
2071 for (i = 0; i < length; i++) dupl->
val[i] =
val[i];
2076 for (i = 0; i <
nCols; i++) dupl->
jd[i] =
jd[i];
2096 for (i = 0; i < xN*xN; i++)
2100 for (l = 0; l < icols->
length; l++)
2105 while (idx < jc[col+1] && k < icols->length)
2113 for (i = 0; i < xN; i++)
2114 for (j = i; j < xN; j++)
2115 y[i*yLD+j] +=
val[idx] * x[i*xLD+col] * x[j*xLD+col];
2117 for (i = 0; i < xN; i++)
2118 for (j = i; j < xN; j++)
2119 y[i*yLD+j] +=
val[idx] * (x[i*xLD+col] * x[j*xLD+row] + x[i*xLD+row] * x[j*xLD+col]);
2122 else if (ir[idx] > row) k++;
2128 for (i = 0; i < xN; i++)
2129 for (j = i; j < xN; j++)
2130 y[j*yLD+i] =
y[i*yLD+j];
virtual real_t getNorm(int_t type=2) const =0
Interfaces matrix-vector operations tailored to symmetric sparse matrices.
virtual returnValue transTimes(int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const
virtual returnValue print() const =0
virtual real_t getRowNorm(int_t rNum, int_t type=2) const
BooleanType isZero(real_t x, real_t TOL=ZERO)
returnValue getNumberArray(int *const numberarray) const
virtual BooleanType isDiag() const
virtual returnValue addToDiag(real_t alpha)
virtual returnValue getRow(int rNum, const Indexlist *const icols, real_t alpha, real_t *row) const
virtual Matrix * duplicate() const
virtual SymmetricMatrix * duplicateSym() const
virtual returnValue getCol(int cNum, const Indexlist *const irows, real_t alpha, real_t *col) const
virtual real_t * full() const
BEGIN_NAMESPACE_ACADO const double EPS
virtual Matrix * duplicate() const
Allows to pass back messages to the calling function.
virtual returnValue getSparseSubmatrix(int_t irowsLength, const int_t *const irowsNumber, int_t icolsLength, const int_t *const icolsNumber, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const
Interfaces matrix-vector operations tailored to symmetric dense matrices.
virtual returnValue getRow(int rNum, const Indexlist *const icols, real_t alpha, real_t *row) const
virtual ~SparseMatrixRow()
virtual SymmetricMatrix * duplicateSym() const
#define THROWERROR(retval)
virtual returnValue getSparseSubmatrix(const Indexlist *const irows, const Indexlist *const icols, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const
virtual returnValue getCol(int cNum, const Indexlist *const irows, real_t alpha, real_t *col) const
virtual returnValue transTimes(int_t xN, real_t alpha, const real_t *x, int_t xLD, real_t beta, real_t *y, int_t yLD) const
virtual returnValue writeToFile(FILE *output_file, const char *prefix) const
virtual Matrix * duplicate() const
Interfaces matrix-vector operations tailored to general sparse matrices.
virtual returnValue times(int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const
virtual real_t getNorm(int_t type=2) const
virtual returnValue getRow(int_t rNum, const Indexlist *const icols, real_t alpha, real_t *row) const
virtual returnValue times(int_t xN, real_t alpha, const real_t *x, int_t xLD, real_t beta, real_t *y, int_t yLD) const
virtual real_t diag(int i) const
sparse_int_t * createDiagInfo()
Interfaces matrix-vector operations tailored to general dense matrices.
Interfaces matrix-vector operations tailored to general sparse matrices.
virtual returnValue print() const
virtual real_t getNorm(int_t type=2) const
virtual returnValue getSparseSubmatrix(int_t irowsLength, const int_t *const irowsNumber, int_t icolsLength, const int_t *const icolsNumber, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const
virtual returnValue getCol(int_t cNum, const Indexlist *const irows, real_t alpha, real_t *col) const
returnValue transTimes(int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const
virtual Matrix * duplicate() const
virtual returnValue print() const
virtual returnValue addToDiag(real_t alpha)
virtual returnValue writeToFile(FILE *output_file, const char *prefix) const
Abstract base class for interfacing tailored matrix-vector operations.
virtual real_t getRowNorm(int_t rNum, int_t type=2) const
virtual returnValue bilinear(const Indexlist *const icols, int xN, const real_t *x, int xLD, real_t *y, int yLD) const
virtual real_t diag(int i) const
#define END_NAMESPACE_QPOASES
virtual returnValue addToDiag(real_t alpha)
BooleanType needToFreeMemory() const
int number[INDEXLISTFACTOR *(NVMAX+NCMAX)]
Stores and manages index lists.
returnValue times(int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const
virtual returnValue getSparseSubmatrix(int_t irowsLength, const int_t *const irowsNumber, int_t icolsLength, const int_t *const icolsNumber, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const
virtual returnValue bilinear(const Indexlist *const icols, int xN, const real_t *x, int xLD, real_t *y, int yLD) const
virtual real_t getNorm(int_t type=2) const
virtual BooleanType isDiag() const
virtual real_t diag(int_t i) const
virtual BooleanType isDiag() const
#define BEGIN_NAMESPACE_QPOASES
virtual returnValue writeToFile(FILE *output_file, const char *prefix) const
virtual real_t getRowNorm(int_t rNum, int_t type=2) const
BooleanType isEqual(real_t x, real_t y, real_t TOL=ZERO)
virtual Matrix * duplicate() const
#define REFER_NAMESPACE_QPOASES
virtual real_t * full() const
Abstract base class for interfacing matrix-vector operations tailored to symmetric matrices...