@@ -91,7 +91,7 @@ Vector &Vector::operator=(const Vector &other) {
91
91
if (this != &other) {
92
92
if (this ->getSize () != other.getSize ()) {
93
93
throw MPException (" Vectors of different size in"
94
- " Vector::operator=" );
94
+ " Vector::operator=" );
95
95
}
96
96
for (unsigned int row = 0 ; row < this ->getSize (); row++) {
97
97
this ->table [row] = other.table [row];
@@ -107,7 +107,7 @@ void Vector::negate() {
107
107
for (unsigned int row = 0 ; row < this ->getSize (); row++) {
108
108
if (this ->get (row) == MP_MINUS_INFINITY) {
109
109
throw MPException (" Cannot negate vectors with MP_MINUS_INFINITY elements in"
110
- " Vector::negate" );
110
+ " Vector::negate" );
111
111
}
112
112
this ->put (row, -this ->get (row));
113
113
}
@@ -132,7 +132,7 @@ MPTime Vector::normalize() {
132
132
133
133
if (maxEl == MP_MINUS_INFINITY) {
134
134
throw MPException (" Cannot normalize vector with norm MP_MINUS_INFINITY"
135
- " Vector::normalize" );
135
+ " Vector::normalize" );
136
136
}
137
137
for (unsigned int row = 0 ; row < this ->getSize (); row++) {
138
138
MPTime x_i = this ->get (row); // MPTime handles -INF correctly
@@ -355,27 +355,23 @@ void Matrix::addRows(uint n) {
355
355
}
356
356
357
357
/* *
358
- * Increases the number of cols of the matrix by n and fills the new elements with -\infty.
359
- */
360
- void Matrix::addCols (uint n)
361
- {
358
+ * Increases the number of cols of the matrix by n and fills the new elements with -\infty.
359
+ */
360
+ void Matrix::addCols (uint n) {
362
361
unsigned int rows = this ->getRows ();
363
362
unsigned int cols = this ->getCols ();
364
363
this ->szCols = this ->szCols + n;
365
364
auto it = this ->table .begin () + cols;
366
- for (unsigned int r = 0 ; r < rows; r++)
367
- {
368
- for (unsigned int c = 0 ; c < n; c++)
369
- {
370
- it= this ->table .insert (it, MP_MINUS_INFINITY);
365
+ for (unsigned int r = 0 ; r < rows; r++) {
366
+ for (unsigned int c = 0 ; c < n; c++) {
367
+ it = this ->table .insert (it, MP_MINUS_INFINITY);
371
368
}
372
369
if (r < rows - 1 ) {
373
- advance (it, cols+ n);
370
+ advance (it, cols + n);
374
371
}
375
372
}
376
373
}
377
374
378
-
379
375
/* *
380
376
* Get size of a square matrix
381
377
*/
@@ -390,7 +386,7 @@ unsigned int Matrix::getSize() const {
390
386
MPTime Matrix::get (unsigned int row, unsigned int column) const {
391
387
if ((row >= this ->getRows ()) || (column >= this ->getCols ())) {
392
388
throw MPException (" Index out of bounds in"
393
- " Matrix::get" );
389
+ " Matrix::get" );
394
390
}
395
391
return this ->table [row * this ->getCols () + column];
396
392
}
@@ -414,7 +410,7 @@ Vector Matrix::getRowVector(unsigned int row) const {
414
410
void Matrix::put (unsigned int row, unsigned int column, MPTime value) {
415
411
if ((row >= this ->getRows ()) || (column >= this ->getCols ())) {
416
412
throw MPException (" Index out of bounds in"
417
- " Matrix::put" );
413
+ " Matrix::put" );
418
414
}
419
415
this ->table [row * this ->getCols () + column] = value;
420
416
}
@@ -462,7 +458,7 @@ Vector Matrix::mp_multiply(const Vector &v) const {
462
458
// Check size of the matrix and vector
463
459
if (this ->getCols () != v.getSize ()) {
464
460
throw MPException (" Matrix and vector are of unequal size in "
465
- " Matrix::mp_multiply" );
461
+ " Matrix::mp_multiply" );
466
462
}
467
463
468
464
// Allocate space of the resulting vector
@@ -487,7 +483,7 @@ Matrix Matrix::mp_multiply(const Matrix &m) const {
487
483
// Check sizes of the matrices
488
484
if (this ->getCols () != m.getRows ()) {
489
485
throw MPException (" Matrices are of incompatible size in"
490
- " Matrix::mp_multiply(Matrix)" );
486
+ " Matrix::mp_multiply(Matrix)" );
491
487
}
492
488
493
489
// Allocate space of the resulting matrix
@@ -514,7 +510,7 @@ Matrix Matrix::mp_sub(const Matrix &m) const {
514
510
// Check sizes of the matrices
515
511
if ((m.getRows () != this ->getRows ()) || (m.getCols () != this ->getCols ())) {
516
512
throw MPException (" Matrices are of different size in"
517
- " Matrix::mp_sub(Matrix&" );
513
+ " Matrix::mp_sub(Matrix&" );
518
514
}
519
515
520
516
// Allocate space of the resulting matrix
@@ -537,7 +533,7 @@ Matrix Matrix::mp_maximum(const Matrix &m) const {
537
533
// Check sizes of the matrices
538
534
if ((m.getRows () != this ->getRows ()) || (m.getCols () != this ->getCols ())) {
539
535
throw MPException (" Matrices are of different size in"
540
- " Matrix::maximum(Matrix*, Matrix*" );
536
+ " Matrix::maximum(Matrix*, Matrix*" );
541
537
}
542
538
543
539
// Allocate space of the resulting matrix
@@ -575,8 +571,7 @@ Matrix Matrix::mp_power(const unsigned int p) const {
575
571
/* *
576
572
* Matrix copy.
577
573
*/
578
- std::shared_ptr<Matrix> Matrix::createCopyPtr () const
579
- {
574
+ std::shared_ptr<Matrix> Matrix::createCopyPtr () const {
580
575
std::shared_ptr<Matrix> newMatrix = std::make_shared<Matrix>(this ->getRows (), this ->getCols ());
581
576
unsigned int nEls = this ->getRows () * this ->getCols ();
582
577
for (unsigned int pos = 0 ; pos < nEls; pos++) {
@@ -587,8 +582,7 @@ std::shared_ptr<Matrix> Matrix::createCopyPtr() const
587
582
/* *
588
583
* Matrix copy.
589
584
*/
590
- Matrix Matrix::createCopy () const
591
- {
585
+ Matrix Matrix::createCopy () const {
592
586
Matrix newMatrix (this ->getRows (), this ->getCols ());
593
587
unsigned int nEls = this ->getRows () * this ->getCols ();
594
588
for (unsigned int pos = 0 ; pos < nEls; pos++) {
@@ -598,30 +592,29 @@ Matrix Matrix::createCopy() const
598
592
}
599
593
600
594
/* *
601
- * Matrix transposed copy.
602
- */
595
+ * Matrix transposed copy.
596
+ */
603
597
std::shared_ptr<Matrix> Matrix::getTransposedCopy () const {
604
598
unsigned int MR = this ->getCols ();
605
599
unsigned int MC = this ->getRows ();
606
600
std::shared_ptr<Matrix> newMatrix = std::make_shared<Matrix>(MR, MC);
607
- for (unsigned int col = 0 ; col < MC; col++)
608
- {
609
- for (unsigned int row = 0 ; row < MR; row++)
610
- {
611
- newMatrix->put (row, col, this ->get (col, row)); // NOLINT(readability-suspicious-call-argument)
601
+ for (unsigned int col = 0 ; col < MC; col++) {
602
+ for (unsigned int row = 0 ; row < MR; row++) {
603
+ newMatrix->put (
604
+ row, col, this ->get (col, row)); // NOLINT(readability-suspicious-call-argument)
612
605
}
613
606
}
614
607
return newMatrix;
615
608
}
616
609
617
-
618
610
Matrix Matrix::transpose () const {
619
611
unsigned int MR = this ->getCols ();
620
612
unsigned int MC = this ->getRows ();
621
613
Matrix newMatrix (MR, MC);
622
614
for (unsigned int col = 0 ; col < MC; col++) {
623
615
for (unsigned int row = 0 ; row < MR; row++) {
624
- newMatrix.put (row, col, this ->get (col, row)); // NOLINT(readability-suspicious-call-argument)
616
+ newMatrix.put (
617
+ row, col, this ->get (col, row)); // NOLINT(readability-suspicious-call-argument)
625
618
}
626
619
}
627
620
return newMatrix;
@@ -697,8 +690,7 @@ Matrix Matrix::getSubMatrixNonSquare(const std::list<unsigned int> &colIndices)
697
690
return newMatrix;
698
691
}
699
692
700
-
701
- Matrix Matrix::getSubMatrixNonSquareRows (const std::list<unsigned int >& rowIndices) const {
693
+ Matrix Matrix::getSubMatrixNonSquareRows (const std::list<unsigned int > &rowIndices) const {
702
694
auto NR = static_cast <unsigned int >(rowIndices.size ());
703
695
Matrix newMatrix (NR, this ->getCols ());
704
696
@@ -712,7 +704,8 @@ Matrix Matrix::getSubMatrixNonSquareRows(const std::list<unsigned int>& rowIndic
712
704
return newMatrix;
713
705
}
714
706
715
- std::shared_ptr<Matrix> Matrix::getSubMatrixNonSquareRowsPtr (const std::list<unsigned int >& rowIndices) const {
707
+ std::shared_ptr<Matrix>
708
+ Matrix::getSubMatrixNonSquareRowsPtr (const std::list<unsigned int > &rowIndices) const {
716
709
auto NR = static_cast <unsigned int >(rowIndices.size ());
717
710
auto newMatrix = std::make_shared<Matrix>(NR, this ->getCols ());
718
711
@@ -746,7 +739,7 @@ void Matrix::add(MPTime increase, Matrix &result) const {
746
739
unsigned int MC = this ->getCols ();
747
740
if ((MR != result.getRows ()) || (MC != result.getCols ())) {
748
741
throw MPException (" Matrices are of different size in"
749
- " Matrix::add(Matrix*, MPTime, Matrix*" );
742
+ " Matrix::add(Matrix*, MPTime, Matrix*" );
750
743
}
751
744
for (unsigned int r = 0 ; r < MR; r++) {
752
745
for (unsigned int c = 0 ; c < MC; c++) {
@@ -764,7 +757,7 @@ void Matrix::maximum(const Matrix &matB, Matrix &result) const {
764
757
if ((matB.getRows () != MR) || (matB.getCols () != MC) || (result.getRows () != MR)
765
758
|| (result.getCols () != MC)) {
766
759
throw MPException (" Matrices are of different size in"
767
- " Matrix::maximum(Matrix*, Matrix*, Matrix*" );
760
+ " Matrix::maximum(Matrix*, Matrix*, Matrix*" );
768
761
}
769
762
770
763
for (unsigned int r = 0 ; r < MR; r++) {
@@ -969,7 +962,7 @@ bool Matrix::allPairLongestPathMatrix(MPTime posCycleThreshold,
969
962
970
963
if ((N != res.getRows ()) || (N != res.getCols ())) {
971
964
throw MPException (" The matrix of the longest paths "
972
- " should have the same size as the given matrix." );
965
+ " should have the same size as the given matrix." );
973
966
}
974
967
975
968
// TODO(mgeilen): make / use copy operation
@@ -1081,8 +1074,7 @@ CDouble Matrix::mp_eigenvalue() const {
1081
1074
/* *
1082
1075
* returns the largest element of a row
1083
1076
*/
1084
- MPTime Matrix::getMaxOfRow (uint rowNumber) const
1085
- {
1077
+ MPTime Matrix::getMaxOfRow (uint rowNumber) const {
1086
1078
if (rowNumber > this ->getRows ()) {
1087
1079
throw MPException (" Matrix getMaxOfRow input index out of bounds." );
1088
1080
}
@@ -1252,7 +1244,7 @@ Matrix::mp_generalized_eigenvectors() const {
1252
1244
CId n = length.first ;
1253
1245
MPTime value =
1254
1246
((MPTime (length.second )) <= MP_MINUS_INFINITY ? MP_MINUS_INFINITY
1255
- : MPTime (length.second ));
1247
+ : MPTime (length.second ));
1256
1248
v.put (static_cast <unsigned int >(n), value);
1257
1249
}
1258
1250
0 commit comments