Skip to content

Commit fe1ec3a

Browse files
committed
fix/add implicit padding with zeros
1 parent e4b4adc commit fe1ec3a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

m4ri/solve.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ int mzd_solve_left(mzd_t *A, mzd_t *B, int const cutoff, int const inconsistency
3636
m4ri_die("mzd_solve_left: B nrows (%d) must be equal to max of A nrows (%d) and A ncols (%d).\n", B->nrows,
3737
A->nrows, A->ncols);
3838

39-
if (inconsistency_check && B->nrows > A->nrows) {
40-
mzd_t const *Bpad = mzd_init_window_const(B, A->nrows+1, 0, B->nrows, B->ncols);
41-
if(!mzd_is_zero(Bpad))
42-
m4ri_die("mzd_solve_left: if B nrows (%d) is bigger than A nrows (%d) the additional rows must be zero.\n", B->nrows,
43-
A->nrows, A->ncols);
44-
mzd_free_window((mzd_t *) Bpad);
45-
}
46-
4739
return _mzd_solve_left(A, B, cutoff, inconsistency_check);
4840
}
4941

@@ -128,6 +120,12 @@ int _mzd_pluq_solve_left(mzd_t const *A, rci_t rank, mzp_t const *P, mzp_t const
128120
}
129121

130122
int _mzd_solve_left(mzd_t *A, mzd_t *B, int const cutoff, int const inconsistency_check) {
123+
if (inconsistency_check && B->nrows > A->nrows) {
124+
mzd_t const *Bpad = mzd_init_window_const(B, A->nrows+1, 0, B->nrows, B->ncols);
125+
if(!mzd_is_zero(Bpad)) return -1;
126+
mzd_free_window((mzd_t *) Bpad);
127+
}
128+
131129
/**
132130
* B is modified in place
133131
* (Bi's in the comments are just modified versions of B)

m4ri/solve.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
* \brief Solves A X = B with A and B matrices.
3737
*
3838
* The solution X is stored inplace on B.
39+
* If A->nrows < A->ncols, the matrix A is implicitly padded with zeros to
40+
* match B->nrows.
3941
*
4042
* \param A Input matrix (overwritten).
4143
* \param B Input matrix, being overwritten by the solution matrix X

0 commit comments

Comments
 (0)