Skip to content

Commit

Permalink
Fix {s|c|z}pivotL.c for singular matrices.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyeli committed Nov 26, 2023
1 parent 8f4f993 commit 32832c6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
7 changes: 4 additions & 3 deletions SRC/cpivotL.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ if ( jcol == MIN_COL ) {

/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 1
#if 0
// There is no valid pivot.
// jcol represents the rank of U,
// report the rank, let dgstrf handle the pivot
*pivrow = lsub_ptr[pivptr];
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
#endif
*usepr = 0;
return (jcol+1);
Expand Down
30 changes: 13 additions & 17 deletions SRC/dpivotL.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,26 @@ if ( jcol == MIN_COL ) {
diag = EMPTY;
old_pivptr = nsupc;
for (isub = nsupc; isub < nsupr; ++isub) {
rtemp = fabs (lu_col_ptr[isub]);
rtemp = fabs (lu_col_ptr[isub]);
if ( rtemp > pivmax ) {
pivmax = rtemp;
pivptr = isub;
}
if ( *usepr && lsub_ptr[isub] == *pivrow ) old_pivptr = isub;
if ( lsub_ptr[isub] == diagind ) diag = isub;
pivmax = rtemp;
pivptr = isub;
}
if ( *usepr && lsub_ptr[isub] == *pivrow ) old_pivptr = isub;
if ( lsub_ptr[isub] == diagind ) diag = isub;
}

/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 0
// There is no valid pivot.
// jcol represents the rank of U
// report the rank let dgstrf handle the pivot
#if 1
*pivrow = lsub_ptr[pivptr];
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
#endif
// There is no valid pivot.
// jcol represents the rank of U,
// report the rank, let dgstrf handle the pivot
*pivrow = lsub_ptr[pivptr];
perm_r[*pivrow] = jcol;
#endif
*usepr = 0;
return (jcol+1);
*usepr = 0;
return (jcol+1);
}

thresh = u * pivmax;
Expand Down
7 changes: 4 additions & 3 deletions SRC/spivotL.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ if ( jcol == MIN_COL ) {

/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 1
#if 0
// There is no valid pivot.
// jcol represents the rank of U,
// report the rank, let dgstrf handle the pivot
*pivrow = lsub_ptr[pivptr];
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
#endif
*usepr = 0;
return (jcol+1);
Expand Down
7 changes: 4 additions & 3 deletions SRC/zpivotL.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ if ( jcol == MIN_COL ) {

/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 1
#if 0
// There is no valid pivot.
// jcol represents the rank of U,
// report the rank, let dgstrf handle the pivot
*pivrow = lsub_ptr[pivptr];
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
#endif
*usepr = 0;
return (jcol+1);
Expand Down

0 comments on commit 32832c6

Please sign in to comment.