Skip to content

Commit 710a154

Browse files
committed
Bugfix for IntFullPivLU::solve when called with rectangular matrices (rows > cols).
1 parent ce81946 commit 710a154

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/core/matrices/codac2_IntvFullPivLU.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,9 @@ IntervalMatrix IntvFullPivLU::cokernel() const {
410410
IntervalMatrix IntvFullPivLU::solve(const IntervalMatrix &rhs) const {
411411
assert_release(rhs.rows()==matrixLU_.rows());
412412
IntervalMatrix prhs = _LU.permutationP()*rhs;
413+
Index dim = std::min(matrixLU_.rows(),matrixLU_.cols());
413414
/* inverse L */
414-
for (Index r = 0; r<matrixLU_.rows()-1; r++) {
415+
for (Index r = 0; r<dim; r++) {
415416
for (Index r1=r+1;r1<matrixLU_.rows();r1++) {
416417
prhs.row(r1) -= matrixLU_(r1,r)*prhs.row(r);
417418
}
@@ -428,7 +429,6 @@ IntervalMatrix IntvFullPivLU::solve(const IntervalMatrix &rhs) const {
428429
}
429430
/* then use the diagonal elements */
430431
IntervalMatrix res = IntervalMatrix::Zero(matrixLU_.cols(),rhs.cols());
431-
Index dim = std::min(matrixLU_.cols(),matrixLU_.rows());
432432
for (Index r = dim-1;r>=0;r--) {
433433
for (Index r1=r+1;r1<dim;r1++) {
434434
prhs.row(r) -= matrixLU_(r,r1)*res.row(r1);
@@ -450,8 +450,9 @@ IntervalMatrix IntvFullPivLU::solve(const IntervalMatrix &rhs) const {
450450
void IntvFullPivLU::solve(const IntervalMatrix &rhs, IntervalMatrix &B) const {
451451
assert_release(rhs.rows()==matrixLU_.rows() && B.rows()==matrixLU_.cols());
452452
IntervalMatrix prhs = _LU.permutationP()*rhs;
453+
Index dim = std::min(matrixLU_.cols(),matrixLU_.rows());
453454
/* inverse L */
454-
for (Index r = 0; r<matrixLU_.rows()-1; r++) {
455+
for (Index r = 0; r<dim; r++) {
455456
for (Index r1=r+1;r1<matrixLU_.rows();r1++) {
456457
prhs.row(r1) -= matrixLU_(r1,r)*prhs.row(r);
457458
}
@@ -467,7 +468,6 @@ void IntvFullPivLU::solve(const IntervalMatrix &rhs, IntervalMatrix &B) const {
467468
IntervalMatrix qB = _LU.permutationQ().inverse()*B;
468469
/* then use the diagonal elements */
469470
// IntervalMatrix res = IntervalMatrix::Zero(matrixLU_.cols(),rhs.cols());
470-
Index dim = std::min(matrixLU_.cols(),matrixLU_.rows());
471471
IntervalMatrix U = matrixLU_.triangularView<Eigen::Upper>();
472472
for (Index r = dim-1;r>=0;r--) {
473473
IntervalRow rw=U.row(r);

0 commit comments

Comments
 (0)