Allow zero A matrices as a special case.
@@ -37,6 +37,8 @@ scs_int SCS(validate_lin_sys)(const ScsMatrix *A) {
return -1;
}
/* detects some errors in A col ptrs: */
+ Anz = A->p[A->n];
+ if (Anz > 0) {
for (i = 0; i < A->n; ++i) {
if (A->p[i] == A->p[i + 1]) {
scs_printf(
@@ -48,8 +50,8 @@ scs_int SCS(validate_lin_sys)(const ScsMatrix *A) {
return -1;
}
}
- Anz = A->p[A->n];
- if (((scs_float)Anz / A->m > A->n) || (Anz <= 0)) {
+ }
+ if (((scs_float)Anz / A->m > A->n) || (Anz < 0)) {
scs_printf("Anz (nonzeros in A) = %li, outside of valid range\n",
(long)Anz);
return -1;
