bool compareRank2(const vector_type& y, const vector_type& y_exp, const scalar_type rel_tol, const scalar_type abs_tol, Teuchos::FancyOStream& out) { typedef typename vector_type::size_type size_type; typename vector_type::HostMirror hy = Kokkos::create_mirror_view(y); typename vector_type::HostMirror hy_exp = Kokkos::create_mirror_view(y_exp); Kokkos::deep_copy(hy, y); Kokkos::deep_copy(hy_exp, y_exp); size_type num_rows = y.dimension_0(); size_type num_cols = y.dimension_1(); bool success = true; for (size_type col = 0; col < num_cols; ++col){ for (size_type i=0; i<num_rows; ++i) { for (size_type j=0; j<y.sacado_size(); ++j) { scalar_type diff = std::abs( hy(i,col).fastAccessCoeff(j) - hy_exp(i,col).fastAccessCoeff(j) ); scalar_type tol = rel_tol*std::abs(hy_exp(i,col).fastAccessCoeff(j)) + abs_tol; bool s = diff < tol; out << "y_expected(" << i << ").coeff(" << j << ") - " << "y(" << i << ").coeff(" << j << ") = " << hy_exp(i,col).fastAccessCoeff(j) << " - " << hy(i,col).fastAccessCoeff(j) << " == " << diff << " < " << tol << " : "; if (s) out << "passed"; else out << "failed"; out << std::endl; success = success && s; } } } return success; }