Skip to content

Commit 604335b

Browse files
committed
fix residual norm for MPI
1 parent 9875528 commit 604335b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/stop/residual_norm.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,14 @@ class ResidualNormFactory
300300
>(args.b, [&](auto dense_b) {
301301
using value_type =
302302
typename std::decay_t<decltype(*dense_b)>::value_type;
303-
auto dense_x = as<matrix::Dense<value_type>>(args.x);
304-
auto dense_r = as<matrix::Dense<value_type>>(args.initial_residual);
303+
constexpr bool is_distributed =
304+
std::is_same_v<std::decay_t<decltype(*dense_b)>,
305+
experimental::distributed::Vector<value_type>>;
306+
using vector_type = std::conditional_t<
307+
is_distributed, experimental::distributed::Vector<value_type>,
308+
matrix::Dense<value_type>>;
309+
auto dense_x = as<vector_type>(args.x);
310+
auto dense_r = as<vector_type>(args.initial_residual);
305311
auto cast_threshold = static_cast<remove_complex<value_type>>(
306312
this->parameters_.threshold);
307313
auto cast_args =

0 commit comments

Comments
 (0)