Skip to content

Commit

Permalink
review 1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cval26 committed Jul 28, 2023
1 parent 7a5459c commit 67580b5
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/linalg/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,24 +1839,18 @@ Matrix::rescale_rows_max()
for (int i = 0; i < d_num_rows; i++)
{
// Find the row's max absolute value.
double local_max = fabs(item(i, 0));
double row_max = fabs(item(i, 0));
for (int j = 1; j < d_num_cols; j++)
{
if (fabs(item(i, j)) > local_max)
local_max = fabs(item(i, j));
if (fabs(item(i, j)) > row_max)
row_max = fabs(item(i, j));
}

// Get the max of all processes, if applicable.
double global_max = local_max;
if (d_num_procs > 1)
MPI_Allreduce(&local_max, &global_max, 1, MPI_DOUBLE, MPI_MAX,
MPI_COMM_WORLD);

// Rescale every row entry, if max nonzero.
if (global_max > 1.0e-14)
if (row_max > 1.0e-14)
{
for (int j = 0; j < d_num_cols; j++)
item(i, j) /= global_max;
item(i, j) /= row_max;
}
}
}
Expand Down

0 comments on commit 67580b5

Please sign in to comment.