diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 285d5f55..05b91beb 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: include: - - compiler_driver: g++ + - compiler_driver: g++-12 compiler_prefix: /usr/bin steps: - name: Create Build Environment @@ -27,7 +27,7 @@ jobs: - name: Configure CMake working-directory: mdspan-build - run: cmake $GITHUB_WORKSPACE/mdspan-src -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install + run: cmake $GITHUB_WORKSPACE/mdspan-src -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install - name: Build working-directory: mdspan-build @@ -65,7 +65,7 @@ jobs: - name: Configure CMake shell: bash working-directory: stdblas-build - run: cmake $GITHUB_WORKSPACE/stdblas-src -Dmdspan_DIR=$GITHUB_WORKSPACE/mdspan-install/lib/cmake/mdspan -DLINALG_ENABLE_TESTS=On -DLINALG_ENABLE_EXAMPLES=On -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/stdblas-install + run: cmake $GITHUB_WORKSPACE/stdblas-src -DCMAKE_CXX_COMPILER=g++-12 -Dmdspan_DIR=$GITHUB_WORKSPACE/mdspan-install/lib/cmake/mdspan -DLINALG_ENABLE_TESTS=On -DLINALG_ENABLE_EXAMPLES=On -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/stdblas-install - name: Upload workspace uses: actions/upload-artifact@v2 @@ -102,8 +102,6 @@ jobs: test-stdBLAS: runs-on: ubuntu-latest - container: - image: amklinv/mdspan-dependencies:latest needs: build-stdblas steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c528fa2..32f25f2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,15 @@ if(LINALG_ENABLE_KOKKOS) find_package(KokkosKernels REQUIRED) endif() +find_package(TBB) +option(LINALG_ENABLE_TBB + "Enable Threaded Building Blocks for tests. Default: autodetect TBB installation." + ${TBB_FOUND} +) +if(LINALG_ENABLE_TBB) + find_package(TBB REQUIRED) +endif() + ################################################################################ CONFIGURE_FILE(include/experimental/__p1673_bits/linalg_config.h.in @@ -152,6 +161,10 @@ if(LINALG_ENABLE_KOKKOS) ) endif() +if(LINALG_ENABLE_TBB) + target_link_libraries(linalg INTERFACE TBB::tbb) +endif() + target_include_directories(linalg INTERFACE $ $ diff --git a/examples/01_scale.cpp b/examples/01_scale.cpp index aefd190a..a2128684 100644 --- a/examples/01_scale.cpp +++ b/examples/01_scale.cpp @@ -13,7 +13,7 @@ // Make mdspan less verbose using std::experimental::mdspan; using std::experimental::extents; -using std::experimental::dynamic_extent; +using std::dynamic_extent; int main(int argc, char* argv[]) { std::cout << "Scale" << std::endl; @@ -26,7 +26,7 @@ int main(int argc, char* argv[]) { // With CTAD working we could do, GCC 11.1 works but some others are buggy // mdspan x(x_vec.data(), N); mdspan> x(x_vec.data(),N); - for(int i=0; i> y(y_vec.data(),N); for(int i=0; i; + using dyn_1d_ext_type = std::experimental::extents; using mdspan_type = std::experimental::mdspan; mdspan_type x(x_ptr,N); mdspan_type y(y_ptr,N); diff --git a/examples/kokkos-based/dot_kokkos.cpp b/examples/kokkos-based/dot_kokkos.cpp index 1617c108..e7dfe44c 100644 --- a/examples/kokkos-based/dot_kokkos.cpp +++ b/examples/kokkos-based/dot_kokkos.cpp @@ -16,7 +16,7 @@ int main(int argc, char* argv[]) value_type* a_ptr = a_view.data(); value_type* b_ptr = b_view.data(); - using dyn_1d_ext_type = std::experimental::extents; + using dyn_1d_ext_type = std::experimental::extents; using mdspan_type = std::experimental::mdspan; mdspan_type a(a_ptr,N); mdspan_type b(b_ptr,N); diff --git a/examples/kokkos-based/dotc_kokkos.cpp b/examples/kokkos-based/dotc_kokkos.cpp index c6dbae50..24426ee0 100644 --- a/examples/kokkos-based/dotc_kokkos.cpp +++ b/examples/kokkos-based/dotc_kokkos.cpp @@ -16,7 +16,7 @@ int main(int argc, char* argv[]) value_type* a_ptr = a_view.data(); value_type* b_ptr = b_view.data(); - using dyn_1d_ext_type = std::experimental::extents; + using dyn_1d_ext_type = std::experimental::extents; using mdspan_type = std::experimental::mdspan; mdspan_type a(a_ptr,N); mdspan_type b(b_ptr,N); diff --git a/examples/kokkos-based/scale_kokkos.cpp b/examples/kokkos-based/scale_kokkos.cpp index 823e1f92..47cc8a02 100644 --- a/examples/kokkos-based/scale_kokkos.cpp +++ b/examples/kokkos-based/scale_kokkos.cpp @@ -15,7 +15,7 @@ int main(int argc, char* argv[]) // Requires CTAD working, GCC 11.1 works but some others are buggy // std::experimental::mdspan a(a_ptr,N); - std::experimental::mdspan> a(a_ptr,N); + std::experimental::mdspan> a(a_ptr,N); for(std::size_t i=0; i x_view("x",N); value_type* x_ptr = x_view.data(); - using dyn_1d_ext_type = std::experimental::extents; + using dyn_1d_ext_type = std::experimental::extents; using mdspan_type = std::experimental::mdspan; mdspan_type x(x_ptr,N); for(std::size_t i=0; i x_view("x",N); value_type* x_ptr = x_view.data(); - using dyn_1d_ext_type = std::experimental::extents; + using dyn_1d_ext_type = std::experimental::extents; using mdspan_type = std::experimental::mdspan; mdspan_type x(x_ptr,N); for(std::size_t i=0; i x_view("x",N); value_type* x_ptr = x_view.data(); - using dyn_1d_ext_type = std::experimental::extents; + using dyn_1d_ext_type = std::experimental::extents; using mdspan_type = std::experimental::mdspan; mdspan_type x(x_ptr,N); for(std::size_t i=0; i #include namespace std { @@ -90,7 +91,7 @@ template Scalar dot( - std::experimental::linalg::impl::inline_exec_t&& /* exec */, + std::experimental::linalg::impl::inline_exec_t&& exec, std::experimental::mdspan, Layout1, Accessor1> v1, std::experimental::mdspan, Layout2, Accessor2> v2, Scalar init) @@ -100,10 +101,18 @@ Scalar dot( v1.static_extent(0) == v2.static_extent(0)); using size_type = std::common_type_t; - for (size_type k = 0; k < v1.extent(0); ++k) { - init += v1(k) * v2(k); - } - return init; + using scalar_type = std::common_type_t; + using std::ranges::iota_view; + using std::ranges::begin; + using std::ranges::end; + + iota_view range{size_type{}, v1.extent(0)}; + + Scalar sum = std::transform_reduce(exec, begin(range), end(range), init, + std::plus{}, + [=](size_type i) { return v1[i] * v2[i]; }); + + return sum; } template, Layout2, Accessor2> v2, Scalar init) { - return dot(std::experimental::linalg::impl::default_exec_t(), v1, v2, init); + return dot(std::experimental::linalg::impl::default_exec(), v1, v2, init); } template, Layout1, Accessor1> x, std::experimental::mdspan, Layout2, Accessor2> y) - -> decltype(x(0) * y(0)); + -> decltype(x[0] * y[0]); } // namespace dot_detail diff --git a/include/experimental/__p1673_bits/blas1_givens.hpp b/include/experimental/__p1673_bits/blas1_givens.hpp index d9c4dd4d..ac7f9bbe 100644 --- a/include/experimental/__p1673_bits/blas1_givens.hpp +++ b/include/experimental/__p1673_bits/blas1_givens.hpp @@ -399,9 +399,9 @@ void givens_rotation_apply( using index_type = ::std::common_type_t; const auto x_extent_0 = static_cast(x.extent(0)); for (index_type i = 0; i < x_extent_0; ++i) { - const auto dtemp = c * x(i) + s * y(i); - y(i) = c * y(i) - s * x(i); - x(i) = dtemp; + const auto dtemp = c * x[i] + s * y[i]; + y[i] = c * y[i] - s * x[i]; + x[i] = dtemp; } } @@ -496,9 +496,9 @@ void givens_rotation_apply( using index_type = ::std::common_type_t; const auto x_extent_0 = static_cast(x.extent(0)); for (index_type i = 0; i < x_extent_0; ++i) { - const auto dtemp = c * x(i) + s * y(i); - y(i) = c * y(i) - conj(s) * x(i); - x(i) = dtemp; + const auto dtemp = c * x[i] + s * y[i]; + y[i] = c * y[i] - conj(s) * x[i]; + x[i] = dtemp; } } diff --git a/include/experimental/__p1673_bits/blas1_linalg_add.hpp b/include/experimental/__p1673_bits/blas1_linalg_add.hpp index 9a2d0ae1..3fbceec4 100644 --- a/include/experimental/__p1673_bits/blas1_linalg_add.hpp +++ b/include/experimental/__p1673_bits/blas1_linalg_add.hpp @@ -82,7 +82,7 @@ void add_rank_1( using size_type = std::common_type_t; for (size_type i = 0; i < z.extent(0); ++i) { - z(i) = x(i) + y(i); + z[i] = x[i] + y[i]; } } @@ -132,7 +132,7 @@ void add_rank_2( using size_type = std::common_type_t; for (size_type j = 0; j < x.extent(1); ++j) { for (size_type i = 0; i < x.extent(0); ++i) { - z(i,j) = x(i,j) + y(i,j); + z[i,j] = x[i,j] + y[i,j]; } } } diff --git a/include/experimental/__p1673_bits/blas1_linalg_copy.hpp b/include/experimental/__p1673_bits/blas1_linalg_copy.hpp index 548b6144..09b34d66 100644 --- a/include/experimental/__p1673_bits/blas1_linalg_copy.hpp +++ b/include/experimental/__p1673_bits/blas1_linalg_copy.hpp @@ -69,7 +69,7 @@ void copy_rank_1( x.static_extent(0) == y.static_extent(0)); using size_type = std::common_type_t; for (size_type i = 0; i < y.extent(0); ++i) { - y(i) = x(i); + y[i] = x[i]; } } @@ -98,7 +98,7 @@ void copy_rank_2( using size_type = std::common_type_t; for (size_type j = 0; j < y.extent(1); ++j) { for (size_type i = 0; i < y.extent(0); ++i) { - y(i,j) = x(i,j); + y[i,j] = x[i,j]; } } } diff --git a/include/experimental/__p1673_bits/blas1_linalg_swap.hpp b/include/experimental/__p1673_bits/blas1_linalg_swap.hpp index 9f3a586c..2489da53 100644 --- a/include/experimental/__p1673_bits/blas1_linalg_swap.hpp +++ b/include/experimental/__p1673_bits/blas1_linalg_swap.hpp @@ -74,7 +74,7 @@ void swap_rank_1( using size_type = std::common_type_t; for (size_type i = 0; i < y.extent(0); ++i) { - swap(x(i), y(i)); + swap(x[i], y[i]); } } @@ -106,7 +106,7 @@ void swap_rank_2( for (size_type j = 0; j < y.extent(1); ++j) { for (size_type i = 0; i < y.extent(0); ++i) { - swap(x(i,j), y(i,j)); + swap(x[i,j], y[i,j]); } } } diff --git a/include/experimental/__p1673_bits/blas1_matrix_inf_norm.hpp b/include/experimental/__p1673_bits/blas1_matrix_inf_norm.hpp index ed3fa6c4..b7f43a27 100644 --- a/include/experimental/__p1673_bits/blas1_matrix_inf_norm.hpp +++ b/include/experimental/__p1673_bits/blas1_matrix_inf_norm.hpp @@ -100,14 +100,14 @@ Scalar matrix_inf_norm( return result; } else if(A.extent(0) == size_type(1) && A.extent(1) == size_type(1)) { - result += abs(A(0, 0)); + result += abs(A[0, 0]); return result; } for (size_type i = 0; i < A.extent(0); ++i) { auto row_sum = init; for (size_type j = 0; j < A.extent(1); ++j) { - row_sum += abs(A(i,j)); + row_sum += abs(A[i,j]); } result = max(row_sum, result); } @@ -170,7 +170,7 @@ namespace matrix_inf_norm_detail { class Layout, class Accessor> auto matrix_inf_norm_return_type_deducer( - std::experimental::mdspan, Layout, Accessor> A) -> decltype(abs(A(0,0))); + std::experimental::mdspan, Layout, Accessor> A) -> decltype(abs(A[0,0])); } // namespace matrix_inf_norm_detail diff --git a/include/experimental/__p1673_bits/blas1_matrix_one_norm.hpp b/include/experimental/__p1673_bits/blas1_matrix_one_norm.hpp index 186755e5..f13bde85 100644 --- a/include/experimental/__p1673_bits/blas1_matrix_one_norm.hpp +++ b/include/experimental/__p1673_bits/blas1_matrix_one_norm.hpp @@ -101,7 +101,7 @@ Scalar matrix_one_norm( return result; } else if(A.extent(0) == size_type(1) && A.extent(1) == size_type(1)) { - result += abs(A(0, 0)); + result += abs(A[0, 0]); return result; } @@ -110,7 +110,7 @@ Scalar matrix_one_norm( for (size_type j = 0; j < A.extent(1); ++j) { auto col_sum = init; for (size_type i = 0; i < A.extent(0); ++i) { - col_sum += abs(A(i,j)); + col_sum += abs(A[i,j]); } result = max(col_sum, result); } @@ -171,7 +171,7 @@ namespace matrix_one_norm_detail { class Layout, class Accessor> auto matrix_one_norm_return_type_deducer( - std::experimental::mdspan, Layout, Accessor> A) -> decltype(abs(A(0,0))); + std::experimental::mdspan, Layout, Accessor> A) -> decltype(abs(A[0,0])); } // namespace matrix_one_norm_detail diff --git a/include/experimental/__p1673_bits/blas1_scale.hpp b/include/experimental/__p1673_bits/blas1_scale.hpp index 20cb63bb..f88b1af2 100644 --- a/include/experimental/__p1673_bits/blas1_scale.hpp +++ b/include/experimental/__p1673_bits/blas1_scale.hpp @@ -61,7 +61,7 @@ void linalg_scale_rank_1( std::experimental::mdspan, Layout, Accessor> x) { for (SizeType i = 0; i < x.extent(0); ++i) { - x(i) *= alpha; + x[i] *= alpha; } } @@ -78,7 +78,7 @@ void linalg_scale_rank_2( { for (SizeType j = 0; j < A.extent(1); ++j) { for (SizeType i = 0; i < A.extent(0); ++i) { - A(i,j) *= alpha; + A[i,j] *= alpha; } } } diff --git a/include/experimental/__p1673_bits/blas1_vector_abs_sum.hpp b/include/experimental/__p1673_bits/blas1_vector_abs_sum.hpp index 4e54f81a..d2795163 100644 --- a/include/experimental/__p1673_bits/blas1_vector_abs_sum.hpp +++ b/include/experimental/__p1673_bits/blas1_vector_abs_sum.hpp @@ -87,7 +87,7 @@ Scalar vector_abs_sum( const SizeType numElt = v.extent(0); for (SizeType i = 0; i < numElt; ++i) { using std::abs; - init += abs(v(i)); + init += abs(v[i]); } return init; } @@ -140,7 +140,7 @@ namespace vector_abs_detail { class Accessor> auto vector_abs_return_type_deducer( std::experimental::mdspan, Layout, Accessor> x) - -> decltype(abs(x(0))); + -> decltype(abs(x[0])); } // namespace vector_abs_detail diff --git a/include/experimental/__p1673_bits/blas1_vector_idx_abs_max.hpp b/include/experimental/__p1673_bits/blas1_vector_idx_abs_max.hpp index b6a09855..3b763b72 100644 --- a/include/experimental/__p1673_bits/blas1_vector_idx_abs_max.hpp +++ b/include/experimental/__p1673_bits/blas1_vector_idx_abs_max.hpp @@ -76,17 +76,17 @@ SizeType idx_abs_max_default_impl( std::experimental::mdspan, Layout, Accessor> v) { using std::abs; - using magnitude_type = decltype(abs(v(0))); + using magnitude_type = decltype(abs(v[0])); if (v.extent(0) == 0) { return std::numeric_limits::max(); } SizeType maxInd = 0; - magnitude_type maxVal = abs(v(0)); + magnitude_type maxVal = abs(v[0]); for (SizeType i = 1; i < v.extent(0); ++i) { - if (maxVal < abs(v(i))) { - maxVal = abs(v(i)); + if (maxVal < abs(v[i])) { + maxVal = abs(v[i]); maxInd = i; } } diff --git a/include/experimental/__p1673_bits/blas1_vector_norm2.hpp b/include/experimental/__p1673_bits/blas1_vector_norm2.hpp index fddd825d..5dd22827 100644 --- a/include/experimental/__p1673_bits/blas1_vector_norm2.hpp +++ b/include/experimental/__p1673_bits/blas1_vector_norm2.hpp @@ -82,7 +82,7 @@ template Scalar vector_norm2( std::experimental::linalg::impl::inline_exec_t&& exec, - std::experimental::mdspan, Layout, Accessor> x, + mdspan, Layout, Accessor> x, Scalar init) { // Initialize the sum of squares result @@ -107,7 +107,7 @@ template Scalar vector_norm2( ExecutionPolicy&& exec, - std::experimental::mdspan, Layout, Accessor> x, + mdspan, Layout, Accessor> x, Scalar init) { constexpr bool use_custom = is_custom_vector_norm2_avail< @@ -129,7 +129,7 @@ template Scalar vector_norm2( - std::experimental::mdspan, Layout, Accessor> x, + mdspan, Layout, Accessor> x, Scalar init) { return vector_norm2(std::experimental::linalg::impl::default_exec_t(), x, init); @@ -147,8 +147,8 @@ namespace vector_norm2_detail { class Layout, class Accessor> auto vector_norm2_return_type_deducer( - std::experimental::mdspan, Layout, Accessor> x) - -> decltype(abs(x(0)) * abs(x(0))); + mdspan, Layout, Accessor> x) + -> decltype(abs(x[0]) * abs(x[0])); } // namespace vector_norm2_detail template auto vector_norm2( - std::experimental::mdspan, Layout, Accessor> x) + mdspan, Layout, Accessor> x) -> decltype(vector_norm2_detail::vector_norm2_return_type_deducer(x)) { using return_t = decltype(vector_norm2_detail::vector_norm2_return_type_deducer(x)); @@ -170,7 +170,7 @@ template auto vector_norm2( ExecutionPolicy&& exec, - std::experimental::mdspan, Layout, Accessor> x) + mdspan, Layout, Accessor> x) -> decltype(vector_norm2_detail::vector_norm2_return_type_deducer(x)) { using return_t = decltype(vector_norm2_detail::vector_norm2_return_type_deducer(x)); diff --git a/include/experimental/__p1673_bits/blas1_vector_sum_of_squares.hpp b/include/experimental/__p1673_bits/blas1_vector_sum_of_squares.hpp index 126ee4c1..85dbcdb0 100644 --- a/include/experimental/__p1673_bits/blas1_vector_sum_of_squares.hpp +++ b/include/experimental/__p1673_bits/blas1_vector_sum_of_squares.hpp @@ -105,8 +105,8 @@ sum_of_squares_result vector_sum_of_squares( Scalar scale = init.scaling_factor; Scalar ssq = init.scaled_sum_of_squares; for (SizeType i = 0; i < x.extent(0); ++i) { - if (abs(x(i)) != 0.0) { - const auto absxi = abs(x(i)); + if (abs(x[i]) != 0.0) { + const auto absxi = abs(x[i]); const auto quotient = scale / absxi; if (scale < absxi) { ssq = Scalar(1.0) + ssq * quotient * quotient; diff --git a/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp b/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp index 4c8e240d..10e84580 100644 --- a/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp +++ b/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp @@ -276,9 +276,9 @@ void matrix_vector_product( std::common_type_t, SizeType_y>>; for (size_type i = 0; i < A.extent(0); ++i) { - y(i) = ElementType_y{}; + y[i] = ElementType_y{}; for (size_type j = 0; j < A.extent(1); ++j) { - y(i) += A(i,j) * x(j); + y[i] += A[i,j] * x[j]; } } } @@ -395,9 +395,9 @@ void matrix_vector_product( SizeType_y>, SizeType_z>; for (size_type i = 0; i < A.extent(0); ++i) { - z(i) = y(i); + z[i] = y[i]; for (size_type j = 0; j < A.extent(1); ++j) { - z(i) += A(i,j) * x(j); + z[i] += A[i,j] * x[j]; } } } @@ -509,24 +509,24 @@ void symmetric_matrix_vector_product( SizeType_y>; for (size_type i = 0; i < A.extent(0); ++i) { - y(i) = ElementType_y{}; + y[i] = ElementType_y{}; } if constexpr (std::is_same_v) { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = j; i < A.extent(0); ++i) { - const auto A_ij = A(i,j); - y(i) += A_ij * x(j); - y(j) += A_ij * x(i); + const auto A_ij = A[i,j]; + y[i] += A_ij * x[j]; + y[j] += A_ij * x[i]; } } } else { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = 0; i <= j; ++i) { - const auto A_ij = A(i,j); - y(i) += A_ij * x(j); - y(j) += A_ij * x(i); + const auto A_ij = A[i,j]; + y[i] += A_ij * x[j]; + y[j] += A_ij * x[i]; } } } @@ -630,24 +630,24 @@ void symmetric_matrix_vector_product( typename Extents_z::size_type>; for (size_type i = 0; i < A.extent(0); ++i) { - z(i) = y(i); + z[i] = y[i]; } if constexpr (std::is_same_v) { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = j; i < A.extent(0); ++i) { const auto A_ij = A(i,j); - z(i) += A_ij * x(j); - z(j) += A_ij * x(i); + z[i] += A_ij * x[j]; + z[j] += A_ij * x[i]; } } } else { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = 0; i <= j; ++i) { - const auto A_ij = A(i,j); - z(i) += A_ij * x(j); - z(j) += A_ij * x(i); + const auto A_ij = A[i,j]; + z[i] += A_ij * x[j]; + z[j] += A_ij * x[i]; } } } @@ -758,24 +758,24 @@ void hermitian_matrix_vector_product( SizeType_y>; for (size_type i = 0; i < A.extent(0); ++i) { - y(i) = ElementType_y{}; + y[i] = ElementType_y{}; } if constexpr (std::is_same_v) { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = j; i < A.extent(0); ++i) { - const auto A_ij = A(i,j); - y(i) += A_ij * x(j); - y(j) += impl::conj_if_needed(A_ij) * x(i); + const auto A_ij = A[i,j]; + y[i] += A_ij * x[j]; + y[j] += impl::conj_if_needed(A_ij) * x[i]; } } } else { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = 0; i <= j; ++i) { - const auto A_ij = A(i,j); - y(i) += A_ij * x(j); - y(j) += impl::conj_if_needed(A_ij) * x(i); + const auto A_ij = A[i,j]; + y[i] += A_ij * x[j]; + y[j] += impl::conj_if_needed(A_ij) * x[i]; } } } @@ -886,24 +886,24 @@ void hermitian_matrix_vector_product( typename Extents_z::size_type /* SizeType_z */ >; for (size_type i = 0; i < A.extent(0); ++i) { - z(i) = y(i); + z[i] = y[i]; } if constexpr (std::is_same_v) { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = j; i < A.extent(0); ++i) { - const auto A_ij = A(i,j); - z(i) += A_ij * x(j); - z(j) += impl::conj_if_needed(A_ij) * x(i); + const auto A_ij = A[i,j]; + z[i] += A_ij * x[j]; + z[j] += impl::conj_if_needed(A_ij) * x[i]; } } } else { for (size_type j = 0; j < A.extent(1); ++j) { for (size_type i = 0; i <= j; ++i) { - const auto A_ij = A(i,j); - z(i) += A_ij * x(j); - z(j) += impl::conj_if_needed(A_ij) * x(i); + const auto A_ij = A[i,j]; + z[i] += A_ij * x[j]; + z[j] += impl::conj_if_needed(A_ij) * x[i]; } } } @@ -1016,7 +1016,7 @@ void triangular_matrix_vector_product( SizeType_y>; for (size_type i = 0; i < A.extent(0); ++i) { - y(i) = ElementType_y{}; + y[i] = ElementType_y{}; } constexpr bool explicitDiagonal = std::is_same_v; @@ -1025,10 +1025,10 @@ void triangular_matrix_vector_product( for (size_type j = 0; j < A.extent(1); ++j) { const size_type i_lower = explicitDiagonal ? j : j + size_type(1); for (size_type i = i_lower; i < A.extent(0); ++i) { - y(i) += A(i,j) * x(j); + y[i] += A[i,j] * x[j]; } if constexpr (! explicitDiagonal) { - y(j) += /* 1 times */ x(j); + y[j] += /* 1 times */ x[j]; } } } @@ -1036,10 +1036,10 @@ void triangular_matrix_vector_product( for (ptrdiff_t j = 0; j < A.extent(1); ++j) { const ptrdiff_t i_upper = explicitDiagonal ? j : j - 1; for (ptrdiff_t i = 0; i <= i_upper; ++i) { - y(i) += A(i,j) * x(j); + y[i] += A[i,j] * x[j]; } if constexpr (! explicitDiagonal) { - y(j) += /* 1 times */ x(j); + y[j] += /* 1 times */ x[j]; } } } @@ -1162,7 +1162,7 @@ void triangular_matrix_vector_product( typename Extents_z::size_type /* SizeType_z */ >; for (size_type i = 0; i < A.extent(0); ++i) { - z(i) = y(i); + z[i] = y[i]; } constexpr bool explicitDiagonal = std::is_same_v; @@ -1171,10 +1171,10 @@ void triangular_matrix_vector_product( for (size_type j = 0; j < A.extent(1); ++j) { const size_type i_lower = explicitDiagonal ? j : j + size_type(1); for (size_type i = i_lower; i < A.extent(0); ++i) { - z(i) += A(i,j) * x(j); + z[i] += A[i,j] * x[j]; } if constexpr (! explicitDiagonal) { - z(j) += /* 1 times */ x(j); + z[j] += /* 1 times */ x[j]; } } } @@ -1182,10 +1182,10 @@ void triangular_matrix_vector_product( for (size_type j = 0; j < A.extent(1); ++j) { const ptrdiff_t i_upper = explicitDiagonal ? j : j - size_type(1); for (size_type i = 0; i <= i_upper; ++i) { - z(i) += A(i,j) * x(j); + z[i] += A[i,j] * x[j]; } if constexpr (! explicitDiagonal) { - z(j) += /* 1 times */ x(j); + z[j] += /* 1 times */ x[j]; } } } diff --git a/include/experimental/__p1673_bits/blas3_matrix_product.hpp b/include/experimental/__p1673_bits/blas3_matrix_product.hpp index 4cff48e4..f42bf726 100644 --- a/include/experimental/__p1673_bits/blas3_matrix_product.hpp +++ b/include/experimental/__p1673_bits/blas3_matrix_product.hpp @@ -726,9 +726,9 @@ void matrix_product( for (size_type i = 0; i < C.extent(0); ++i) { for (size_type j = 0; j < C.extent(1); ++j) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - C(i,j) += A(i,k) * B(k,j); + C[i,j] += A[i,k] * B[k,j]; } } } @@ -814,9 +814,9 @@ void matrix_product( for (size_type i = 0; i < C.extent(0); ++i) { for (size_type j = 0; j < C.extent(1); ++j) { - C(i,j) = E(i,j); + C[i,j] = E[i,j]; for (size_type k = 0; k < A.extent(1); ++k) { - C(i,j) += A(i,k) * B(k,j); + C[i,j] += A[i,k] * B[k,j]; } } } @@ -913,13 +913,13 @@ void triangular_matrix_left_product( if constexpr (std::is_same_v) { for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; const ptrdiff_t k_upper = explicitDiagonal ? i : i - ptrdiff_t(1); for (ptrdiff_t k = 0; k <= k_upper; ++k) { - C(i,j) += A(i,k) * B(k,j); + C[i,j] += A[i,k] * B[k,j]; } if constexpr (! explicitDiagonal) { - C(i,j) += /* 1 times */ B(i,j); + C[i,j] += /* 1 times */ B[i,j]; } } } @@ -927,13 +927,13 @@ void triangular_matrix_left_product( else { // upper_triangle_t for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; const size_type k_lower = explicitDiagonal ? i : i + 1; for (size_type k = k_lower; k < C.extent(0); ++k) { - C(i,j) += A(i,k) * B(k,j); + C[i,j] += A[i,k] * B[k,j]; } if constexpr (! explicitDiagonal) { - C(i,j) += /* 1 times */ B(i,j); + C[i,j] += /* 1 times */ B[i,j]; } } } @@ -1028,12 +1028,12 @@ void triangular_matrix_right_product( for (size_type j = 0; j < C.extent(1); ++j) { const size_type k_lower = explicitDiagonal ? j : j + 1; for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = k_lower; k < C.extent(1); ++k) { - C(i,j) += B(i,k) * A(k,j); + C[i,j] += B[i,k] * A[k,j]; } if constexpr (! explicitDiagonal) { - C(i,j) += /* 1 times */ B(i,j); + C[i,j] += /* 1 times */ B[i,j]; } } } @@ -1042,12 +1042,12 @@ void triangular_matrix_right_product( for (size_type j = 0; j < C.extent(1); ++j) { const ptrdiff_t k_upper = explicitDiagonal ? j : j - ptrdiff_t(1); for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (ptrdiff_t k = 0; k <= k_upper; ++k) { - C(i,j) += B(i,k) * A(k,j); + C[i,j] += B[i,k] * A[k,j]; } if constexpr (! explicitDiagonal) { - C(i,j) += /* 1 times */ B(i,j); + C[i,j] += /* 1 times */ B[i,j]; } } } @@ -1139,10 +1139,10 @@ void triangular_matrix_left_product( for (size_type j=0; j < C.extent(1); ++j) { for (size_type k=0; k < C.extent(0); ++k) { for (size_type i=0; i < k; ++i) { - C(i,j) += A(i,k) * C(k,j); + C[i,j] += A[i,k] * C[k,j]; } if constexpr (explicitDiagonal) { - C(k,j) = A(k,k) * C(k,j); + C[k,j] = A[k,k] * C[k,j]; } } } @@ -1151,10 +1151,10 @@ void triangular_matrix_left_product( for (size_type j=0; j < C.extent(1); ++j) { for (size_type k=C.extent(0); k > 0; --k) { for (size_type i=k; i < C.extent(0); i++) { - C(i,j) += A(i,k-1) * C(k-1,j); + C[i,j] += A[i,k-1] * C[k-1,j]; } if constexpr (explicitDiagonal) { - C(k-1,j) = A(k-1,k-1) * C(k-1,j); + C[k-1,j] = A[k-1,k-1] * C[k-1,j]; } } } @@ -1233,12 +1233,12 @@ void triangular_matrix_right_product( for (size_type j=C.extent(1); j > 0; --j) { if constexpr (explicitDiagonal) { for(size_type i=0; i < C.extent(0); ++i) { - C(i,j-1) = C(i,j-1) * A(j-1,j-1); + C[i,j-1] = C[i,j-1] * A[j-1,j-1]; } } for (size_type k=0; k < j-1; k++) { for(size_type i=0; i < C.extent(0); ++i) { - C(i,j-1) += C(i,k) * A(k,j-1); + C[i,j-1] += C[i,k] * A[k,j-1]; } } } @@ -1247,12 +1247,12 @@ void triangular_matrix_right_product( for (size_type j=0; j < C.extent(1); ++j) { if constexpr (explicitDiagonal) { for (size_type i=0; i < C.extent(0); ++i) { - C(i,j) = C(i,j) * A(j,j); + C[i,j] = C[i,j] * A[j,j]; } } for (size_type k=j+1; k < C.extent(1); ++k) { for (size_type i=0; i < C.extent(0); i++) { - C(i,j) += C(i,k) * A(k,j); + C[i,j] += C[i,k] * A[k,j]; } } } @@ -1334,10 +1334,10 @@ void symmetric_matrix_left_product( if constexpr (std::is_same_v) { for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - ElementType_A aik = i <= k ? A(k,i) : A(i,k); - C(i,j) += aik * B(k,j); + ElementType_A aik = i <= k ? A[k,i] : A[i,k]; + C[i,j] += aik * B[k,j]; } } } @@ -1345,10 +1345,10 @@ void symmetric_matrix_left_product( else { // upper_triangle_t for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - ElementType_A aik = i >= k ? A(k,i) : A(i,k); - C(i,j) += aik * B(k,j); + ElementType_A aik = i >= k ? A[k,i] : A[i,k]; + C[i,j] += aik * B[k,j]; } } } @@ -1436,10 +1436,10 @@ void symmetric_matrix_right_product( if constexpr (std::is_same_v) { for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - ElementType_A akj = j <= k ? A(k,j) : A(j,k); - C(i,j) += B(i,k) * akj; + ElementType_A akj = j <= k ? A[k,j] : A[j,k]; + C[i,j] += B[i,k] * akj; } } } @@ -1447,10 +1447,10 @@ void symmetric_matrix_right_product( else { // upper_triangle_t for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - ElementType_A akj = j >= k ? A(k,j) : A(j,k); - C(i,j) += B(i,k) * akj; + ElementType_A akj = j >= k ? A[k,j] : A[j,k]; + C[i,j] += B[i,k] * akj; } } } @@ -1726,10 +1726,10 @@ void hermitian_matrix_left_product( if constexpr (std::is_same_v) { for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k){ - ElementType_A aik = i <= k ? impl::conj_if_needed(A(k,i)) : A(i,k); - C(i,j) += aik * B(k,j); + ElementType_A aik = i <= k ? impl::conj_if_needed(A[k,i]) : A[i,k]; + C[i,j] += aik * B[k,j]; } } } @@ -1737,10 +1737,10 @@ void hermitian_matrix_left_product( else { // upper_triangle_t for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - ElementType_A aik = i >= k ? impl::conj_if_needed(A(k,i)) : A(i,k); - C(i,j) += aik * B(k,j); + ElementType_A aik = i >= k ? impl::conj_if_needed(A[k,i]) : A[i,k]; + C[i,j] += aik * B[k,j]; } } } @@ -1827,10 +1827,10 @@ void hermitian_matrix_right_product( if constexpr (std::is_same_v) { for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - ElementType_A akj = j <= k ? A(k,j) : impl::conj_if_needed(A(j,k)); - C(i,j) += B(i,k) * akj; + ElementType_A akj = j <= k ? A[k,j] : impl::conj_if_needed(A[j,k]); + C[i,j] += B[i,k] * akj; } } } @@ -1838,10 +1838,10 @@ void hermitian_matrix_right_product( else { // upper_triangle_t for (size_type j = 0; j < C.extent(1); ++j) { for (size_type i = 0; i < C.extent(0); ++i) { - C(i,j) = ElementType_C{}; + C[i,j] = ElementType_C{}; for (size_type k = 0; k < A.extent(1); ++k) { - ElementType_A akj = j >= k ? A(k,j) : impl::conj_if_needed(A(j,k)); - C(i,j) += B(i,k) * akj; + ElementType_A akj = j >= k ? A[k,j] : impl::conj_if_needed(A[j,k]); + C[i,j] += B[i,k] * akj; } } } diff --git a/include/experimental/__p1673_bits/blas3_triangular_matrix_matrix_solve.hpp b/include/experimental/__p1673_bits/blas3_triangular_matrix_matrix_solve.hpp index 34116700..479ccd37 100644 --- a/include/experimental/__p1673_bits/blas3_triangular_matrix_matrix_solve.hpp +++ b/include/experimental/__p1673_bits/blas3_triangular_matrix_matrix_solve.hpp @@ -77,17 +77,17 @@ void trsm_upper_triangular_left_side( // TODO this would be a great opportunity for an implementer to // add value, by accumulating in extended precision (or at least // in a type with the max precision of X and B). - using sum_type = decltype (B(i,k) - A(0,0) * X(0,0)); + using sum_type = decltype (B[i,k] - A[0,0] * X[0,0]); //using sum_type = typename out_object_t::element_type; - sum_type t (B(i,k)); + sum_type t (B[i,k]); for (size_type j = i + 1; j < A_num_rows; ++j) { - t = t - A(i,j) * X(j,k); + t = t - A[i,j] * X[j,k]; } if constexpr (explicit_diagonal) { - X(i,k) = t / A(i,i); + X[i,k] = t / A[i,i]; } else { - X(i,k) = t; + X[i,k] = t; } } } @@ -117,15 +117,15 @@ void trsm_lower_triangular_left_side( // TODO this would be a great opportunity for an implementer to // add value, by accumulating in extended precision (or at least // in a type with the max precision of X and B). - ElementType_X t (B(i,k)); + ElementType_X t (B[i,k]); for (size_type j = 0; j < i; ++j) { - t = t - A(i,j) * X(j,k); + t = t - A[i,j] * X[j,k]; } if constexpr (explicit_diagonal) { - X(i,k) = t / A(i,i); + X[i,k] = t / A[i,i]; } else { - X(i,k) = t; + X[i,k] = t; } } } @@ -152,16 +152,16 @@ void trsm_upper_triangular_right_side( for (size_type i = 0; i < B_num_rows; ++i) { for (size_type j = 0; j < A_num_cols; ++j) { - using sum_type = decltype (B(i,j) - A(0,0) * X(0,0)); - sum_type t (B(i,j)); + using sum_type = decltype (B[i,j] - A[0,0] * X[0,0]); + sum_type t (B[i,j]); for (size_type k = 0; k < j; ++k) { - t = t - X(i,k) * A(k,j); + t = t - X[i,k] * A[k,j]; } if constexpr (explicit_diagonal) { - X(i,j) = t / A(j,j); + X[i,j] = t / A[j,j]; } else { - X(i,j) = t; + X[i,j] = t; } } } @@ -190,16 +190,16 @@ void trsm_lower_triangular_right_side( for (size_type i = 0; i < B_num_rows; ++i) { for (signed_index_type j = A_num_cols - 1; j >= 0; --j) { - using sum_type = decltype (B(i,j) - A(0,0) * X(0,0)); - sum_type t (B(i,j)); + using sum_type = decltype (B[i,j] - A[0,0] * X[0,0]); + sum_type t (B[i,j]); for (size_type k = j + 1; k < A_num_rows; ++k) { - t = t - X(i,k) * A(k,j); + t = t - X[i,k] * A[k,j]; } if constexpr (explicit_diagonal) { - X(i,j) = t / A(j,j); + X[i,j] = t / A[j,j]; } else { - X(i,j) = t; + X[i,j] = t; } } } diff --git a/include/experimental/__p1673_bits/linalg_execpolicy_mapper.hpp b/include/experimental/__p1673_bits/linalg_execpolicy_mapper.hpp index 0f96b5bb..dc0cf39b 100644 --- a/include/experimental/__p1673_bits/linalg_execpolicy_mapper.hpp +++ b/include/experimental/__p1673_bits/linalg_execpolicy_mapper.hpp @@ -12,11 +12,12 @@ inline namespace __p1673_version_0 { namespace linalg { namespace impl { // the execution policy used for default serial inline implementations -struct inline_exec_t {}; +using inline_exec_t = std::execution::sequenced_policy; // The execution policy used when no execution policy is provided // It must be remapped to some other execution policy, which the default mapper does -struct default_exec_t {}; +using default_exec_t = std::execution::parallel_policy; +auto default_exec() { return std::execution::par; }; // helpers template struct is_inline_exec : std::false_type{}; diff --git a/tests/kokkos-based/gtest_fixtures.hpp b/tests/kokkos-based/gtest_fixtures.hpp index 7d9d9101..5c22b8db 100644 --- a/tests/kokkos-based/gtest_fixtures.hpp +++ b/tests/kokkos-based/gtest_fixtures.hpp @@ -53,7 +53,7 @@ // is a header since this is limited to tests using std::experimental::mdspan; using std::experimental::extents; -using std::experimental::dynamic_extent; +using std::dynamic_extent; // // helper class for generating random numbers diff --git a/tests/kokkos-based/matrix_frob_norm_kokkos.cpp b/tests/kokkos-based/matrix_frob_norm_kokkos.cpp index 1f5a37fc..719360e1 100644 --- a/tests/kokkos-based/matrix_frob_norm_kokkos.cpp +++ b/tests/kokkos-based/matrix_frob_norm_kokkos.cpp @@ -87,7 +87,7 @@ TEST_F(blas2_signed_float_fixture, kokkos_matrix_frob_norm_trivial_empty) { std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -109,7 +109,7 @@ TEST_F(blas2_signed_float_fixture, kokkos_matrix_frob_norm_trivial_one_element) constexpr value_type myvalue = static_cast(-1.5); std::vector v = {myvalue}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 1, 1); namespace stdla = std::experimental::linalg; @@ -143,7 +143,7 @@ TEST_F(blas2_signed_double_fixture, kokkos_matrix_frob_norm_trivial_empty) { std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -165,7 +165,7 @@ TEST_F(blas2_signed_double_fixture, kokkos_matrix_frob_norm_trivial_one_element) constexpr value_type myvalue = static_cast(-1.5); std::vector v = {myvalue}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 1, 1); namespace stdla = std::experimental::linalg; @@ -202,7 +202,7 @@ TEST_F(blas2_signed_complex_double_fixture, kokkos_matrix_frob_norm_trivial_empt using stdc_t = value_type; if constexpr (alignof(value_type) == alignof(kc_t)){ std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -229,7 +229,7 @@ TEST_F(blas2_signed_complex_double_fixture, kokkos_matrix_frob_norm_trivial_one_ constexpr value_type myvalue{-1.5, 2.2}; std::vector v = {myvalue}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 1, 1); namespace stdla = std::experimental::linalg; diff --git a/tests/kokkos-based/matrix_inf_norm_kokkos.cpp b/tests/kokkos-based/matrix_inf_norm_kokkos.cpp index d706e7f7..2b6e2340 100644 --- a/tests/kokkos-based/matrix_inf_norm_kokkos.cpp +++ b/tests/kokkos-based/matrix_inf_norm_kokkos.cpp @@ -88,7 +88,7 @@ TEST_F(blas2_signed_float_fixture, kokkos_matrix_inf_norm_trivial_empty) { std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -109,7 +109,7 @@ TEST_F(blas2_signed_float_fixture, kokkos_matrix_inf_norm_trivial_zero_rows) { std::vector v{1.2, -2.4}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 2); namespace stdla = std::experimental::linalg; @@ -143,7 +143,7 @@ TEST_F(blas2_signed_double_fixture, kokkos_matrix_inf_norm_trivial_empty) { std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -164,7 +164,7 @@ TEST_F(blas2_signed_double_fixture, kokkos_matrix_inf_norm_trivial_zero_rows) { std::vector v{1.2, -2.4}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 2); namespace stdla = std::experimental::linalg; @@ -202,7 +202,7 @@ TEST_F(blas2_signed_complex_double_fixture, kokkos_matrix_inf_norm_trivial_empty if constexpr (alignof(value_type) == alignof(kc_t)){ std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -230,7 +230,7 @@ TEST_F(blas2_signed_complex_double_fixture, kokkos_matrix_inf_norm_trivial_zero_ v[0] = {1.2, -1.}; v[1] = {-2.4, 4.}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 2); namespace stdla = std::experimental::linalg; diff --git a/tests/kokkos-based/matrix_one_norm_kokkos.cpp b/tests/kokkos-based/matrix_one_norm_kokkos.cpp index da7c29c1..e658bade 100644 --- a/tests/kokkos-based/matrix_one_norm_kokkos.cpp +++ b/tests/kokkos-based/matrix_one_norm_kokkos.cpp @@ -88,7 +88,7 @@ TEST_F(blas2_signed_float_fixture, kokkos_matrix_one_norm_trivial_empty) { std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -109,7 +109,7 @@ TEST_F(blas2_signed_float_fixture, kokkos_matrix_one_norm_trivial_zero_col) { std::vector v{1.2, -2.4}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 2, 0); namespace stdla = std::experimental::linalg; @@ -143,7 +143,7 @@ TEST_F(blas2_signed_double_fixture, kokkos_matrix_one_norm_trivial_empty) { std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -164,7 +164,7 @@ TEST_F(blas2_signed_double_fixture, kokkos_matrix_one_norm_trivial_zero_col) { std::vector v{1.2, -2.4}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 2, 0); namespace stdla = std::experimental::linalg; @@ -203,7 +203,7 @@ TEST_F(blas2_signed_complex_double_fixture, kokkos_matrix_one_norm_trivial_empty std::vector v; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 0, 0); namespace stdla = std::experimental::linalg; @@ -231,7 +231,7 @@ TEST_F(blas2_signed_complex_double_fixture, kokkos_matrix_one_norm_trivial_zero_ v[0] = {1.2, -1.}; v[1] = {-2.4, 4.}; - constexpr auto de = std::experimental::dynamic_extent; + constexpr auto de = std::dynamic_extent; using s_t = std::experimental::mdspan>; s_t M(v.data(), 2, 0); namespace stdla = std::experimental::linalg; diff --git a/tests/kokkos-based/mdspan_to_view.cpp b/tests/kokkos-based/mdspan_to_view.cpp index 3f13ff45..1abc47d1 100644 --- a/tests/kokkos-based/mdspan_to_view.cpp +++ b/tests/kokkos-based/mdspan_to_view.cpp @@ -13,7 +13,7 @@ void mdspan_to_view_test_impl() { using std::experimental::mdspan; using std::experimental::extents; - using std::experimental::dynamic_extent; + using std::dynamic_extent; // rank1, non-const { @@ -96,7 +96,7 @@ void transposed_mdspan_to_view_test_impl() { using std::experimental::mdspan; using std::experimental::extents; - using std::experimental::dynamic_extent; + using std::dynamic_extent; using lr_t = std::experimental::layout_right; using ll_t = std::experimental::layout_left; diff --git a/tests/native/add.cpp b/tests/native/add.cpp index 0d387a5e..881f0175 100644 --- a/tests/native/add.cpp +++ b/tests/native/add.cpp @@ -6,7 +6,7 @@ #include namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::add; @@ -27,9 +27,9 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t (k) + 1.0; const scalar_t y_k = scalar_t (k) + 2.0; - x(k) = x_k; - y(k) = y_k; - z(k) = 0.0; + x[k] = x_k; + y[k] = y_k; + z[k] = 0.0; } add(x, y, z); @@ -37,9 +37,9 @@ namespace { const scalar_t x_k = scalar_t (k) + 1.0; const scalar_t y_k = scalar_t (k) + 2.0; // Make sure the function didn't modify the input. - EXPECT_EQ( x(k), x_k ); - EXPECT_EQ( y(k), y_k ); - EXPECT_EQ( z(k), x_k + y_k ); // check the output + EXPECT_EQ( x[k], x_k ); + EXPECT_EQ( y[k], y_k ); + EXPECT_EQ( z[k], x_k + y_k ); // check the output } } @@ -60,9 +60,9 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); const scalar_t y_k(real_t(k) + 5.0, -real_t(k) - 2.0); - x(k) = x_k; - y(k) = y_k; - z(k) = scalar_t(0.0, 0.0); + x[k] = x_k; + y[k] = y_k; + z[k] = scalar_t(0.0, 0.0); } add(x, y, z); @@ -70,9 +70,9 @@ namespace { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); const scalar_t y_k(real_t(k) + 5.0, -real_t(k) - 2.0); // Make sure the function didn't modify the input. - EXPECT_EQ( x(k), x_k ); - EXPECT_EQ( y(k), y_k ); - EXPECT_EQ( z(k), x_k + y_k ); // check the output + EXPECT_EQ( x[k], x_k ); + EXPECT_EQ( y[k], y_k ); + EXPECT_EQ( z[k], x_k + y_k ); // check the output } } @@ -93,22 +93,24 @@ namespace { for (std::size_t c = 0; c < numCols; ++c) { for (std::size_t r = 0; r < numRows; ++r) { - const scalar_t A_rc = scalar_t(c) + scalar_t(numCols) * scalar_t(r); - const scalar_t B_rc = scalar_t(2.0) * A_rc; - A(r,c) = A_rc; - B(r,c) = B_rc; - C(r,c) = scalar_t{}; + const scalar_t A_rc = scalar_t(c) + scalar_t(numCols) * scalar_t(r); + const scalar_t B_rc = scalar_t(2.0) * A_rc; + A[r,c] = A_rc; + B[r,c] = B_rc; + C[r,c] = scalar_t{}; } } add(A, B, C); for (std::size_t c = 0; c < numCols; ++c) { for (std::size_t r = 0; r < numRows; ++r) { - const scalar_t A_rc = scalar_t(c) + scalar_t(numCols) * scalar_t(r); - const scalar_t B_rc = scalar_t(2.0) * A_rc; - // Make sure the function didn't modify the input. - EXPECT_EQ( A(r,c), A_rc ); - EXPECT_EQ( B(r,c), B_rc ); - EXPECT_EQ( C(r,c), A_rc + B_rc ); // check the output + const scalar_t A_rc = scalar_t(c) + scalar_t(numCols) * scalar_t(r); + const scalar_t B_rc = scalar_t(2.0) * A_rc; + // Make sure the function didn't modify the input. + // AMK 5.6.23 googletest gets confused by the [r,c] notation + // and gives an error message about having 3 params instead of 2 + EXPECT_EQ( (A[r,c]), A_rc ); + EXPECT_EQ( (B[r,c]), B_rc ); + EXPECT_EQ( (C[r,c]), A_rc + B_rc ); // check the output } } } diff --git a/tests/native/conjugate_transposed.cpp b/tests/native/conjugate_transposed.cpp index 41edac6a..995c72de 100644 --- a/tests/native/conjugate_transposed.cpp +++ b/tests/native/conjugate_transposed.cpp @@ -6,7 +6,7 @@ #include namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::conjugate_transposed; @@ -37,8 +37,8 @@ namespace { const scalar_t j_val (j_val_re, j_val_re); const scalar_t val = i_val + real_t(dim) * j_val; - A(i,j) = val; - B(i,j) = -val; + A[i,j] = val; + B[i,j] = -val; } } @@ -53,14 +53,16 @@ namespace { const scalar_t j_val (j_val_re, j_val_re); const scalar_t val = i_val + real_t(dim) * j_val; - EXPECT_EQ( A(i,j), val ); - EXPECT_EQ( B(i,j), -val ); + // AMK 5.6.23 googletest gets confused by the [r,c] notation + // and gives an error message about having 3 params instead of 2 + EXPECT_EQ( (A[i,j]), val ); + EXPECT_EQ( (B[i,j]), -val ); - EXPECT_EQ( scalar_t(A_h(j,i)), conj(val) ); - EXPECT_EQ( scalar_t(B_h(j,i)), -conj(val) ); + EXPECT_EQ( scalar_t(A_h[j,i]), conj(val) ); + EXPECT_EQ( scalar_t(B_h[j,i]), -conj(val) ); - EXPECT_EQ( scalar_t(A_h(j,i)), conj(A(i,j)) ); - EXPECT_EQ( scalar_t(B_h(j,i)), conj(B(i,j)) ); + EXPECT_EQ( scalar_t(A_h[j,i]), conj(A[i,j]) ); + EXPECT_EQ( scalar_t(B_h[j,i]), conj(B[i,j]) ); } } } diff --git a/tests/native/conjugated.cpp b/tests/native/conjugated.cpp index 3362d2c6..ec24a5e7 100644 --- a/tests/native/conjugated.cpp +++ b/tests/native/conjugated.cpp @@ -6,8 +6,8 @@ #include namespace { - using std::experimental::dextents; - using std::experimental::dynamic_extent; + using std::dextents; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::conjugated; @@ -73,8 +73,8 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 1.0, real_t(k) + 1.0); const scalar_t y_k(real_t(k) + 2.0, real_t(k) + 2.0); - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; } // Make sure that accessor_conjugate compiles @@ -88,15 +88,15 @@ namespace { auto y_conj = conjugated(y); for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 1.0, real_t(k) + 1.0); - EXPECT_EQ( x(k), x_k ); + EXPECT_EQ( x[k], x_k ); // Make sure that conjugated doesn't modify the entries of // the original thing. const scalar_t y_k (real_t(k) + 2.0, real_t(k) + 2.0); - EXPECT_EQ( y(k), y_k ); + EXPECT_EQ( y[k], y_k ); const scalar_t y_k_conj (real_t(k) + 2.0, -real_t(k) - 2.0); - EXPECT_EQ( scalar_t(y_conj(k)), y_k_conj ); + EXPECT_EQ( scalar_t(y_conj[k]), y_k_conj ); } } } diff --git a/tests/native/copy.cpp b/tests/native/copy.cpp index 0bfe1023..572c3717 100644 --- a/tests/native/copy.cpp +++ b/tests/native/copy.cpp @@ -6,7 +6,7 @@ #include namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::copy; @@ -49,16 +49,16 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const auto vals = makeVectorValues(k); - x(k) = vals.first; - y(k) = vals.second; + x[k] = vals.first; + y[k] = vals.second; } copy(x, y); for (std::size_t k = 0; k < vectorSize; ++k) { const auto vals = makeVectorValues(k); // Make sure the function didn't modify the input. - EXPECT_EQ( x(k), vals.first ); - EXPECT_EQ( y(k), vals.first ); // check the output + EXPECT_EQ( x[k], vals.first ); + EXPECT_EQ( y[k], vals.first ); // check the output } } @@ -77,16 +77,16 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const auto vals = makeVectorValues(k); - x(k) = vals.first; - y(k) = vals.second; + x[k] = vals.first; + y[k] = vals.second; } copy(x, y); for (std::size_t k = 0; k < vectorSize; ++k) { const auto vals = makeVectorValues(k); // Make sure the function didn't modify the input. - EXPECT_EQ( x(k), vals.first ); - EXPECT_EQ( y(k), vals.first ); // check the output + EXPECT_EQ( x[k], vals.first ); + EXPECT_EQ( y[k], vals.first ); // check the output } } } @@ -141,8 +141,8 @@ TEST(BLAS1_copy_matrix, mdspan_double) for (std::size_t j = 0; j < numCols; ++j) { for (std::size_t i = 0; i < numRows; ++i) { const auto vals = makeMatrixValues(i, j, numRows); - A(i,j) = vals.first; - B(i,j) = vals.second; + A[i,j] = vals.first; + B[i,j] = vals.second; } } @@ -150,9 +150,11 @@ TEST(BLAS1_copy_matrix, mdspan_double) for (std::size_t j = 0; j < numCols; ++j) { for (std::size_t i = 0; i < numRows; ++i) { const auto vals = makeMatrixValues(i, j, numRows); + // AMK 5.6.23 googletest gets confused by the [r,c] notation + // and gives an error message about having 3 params instead of 2 // Make sure the function didn't modify the input. - EXPECT_EQ( A(i,j), vals.first ); - EXPECT_EQ( B(i,j), vals.first ); // check the output + EXPECT_EQ( (A[i,j]), vals.first ); + EXPECT_EQ( (B[i,j]), vals.first ); // check the output } } } @@ -174,8 +176,8 @@ TEST(BLAS1_copy_matrix, mdspan_complex_double) for (std::size_t j = 0; j < numCols; ++j) { for (std::size_t i = 0; i < numRows; ++i) { const auto vals = makeMatrixValues(i, j, numRows); - A(i,j) = vals.first; - B(i,j) = vals.second; + A[i,j] = vals.first; + B[i,j] = vals.second; } } @@ -183,9 +185,11 @@ TEST(BLAS1_copy_matrix, mdspan_complex_double) for (std::size_t j = 0; j < numCols; ++j) { for (std::size_t i = 0; i < numRows; ++i) { const auto vals = makeMatrixValues(i, j, numRows); + // AMK 5.6.23 googletest gets confused by the [r,c] notation + // and gives an error message about having 3 params instead of 2 // Make sure the function didn't modify the input. - EXPECT_EQ( A(i,j), vals.first ); - EXPECT_EQ( B(i,j), vals.first ); // check the output + EXPECT_EQ( (A[i,j]), vals.first ); + EXPECT_EQ( (B[i,j]), vals.first ); // check the output } } } diff --git a/tests/native/dot.cpp b/tests/native/dot.cpp index f5773589..7643de0b 100644 --- a/tests/native/dot.cpp +++ b/tests/native/dot.cpp @@ -2,6 +2,7 @@ #include #include +#include #include // FIXME (mfh 2022/06/17) Temporarily disable calling the BLAS, @@ -22,7 +23,7 @@ double ddot_wrapper (const int N, const double* DX, #endif // 0 namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::dot; @@ -44,8 +45,8 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t(k) + 1.0; const scalar_t y_k = scalar_t(k) + 2.0; - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; expectedDotResult += x_k * y_k; } @@ -74,14 +75,13 @@ namespace { const scalar_t conjDotResult = dotc(x, y, scalar_t{}); EXPECT_EQ( conjDotResult, expectedDotResult ); - // scalar_t dotResultPar {}; - // See note above. - //std::experimental::dot (std::execution::par, x, y, dotResultPar); - - // This is noncomforming, but I need some way to test the executor overloads. - //using fake_executor_t = int; - //dot (fake_executor_t (), x, y, dotResultPar); - //EXPECT_EQ( dotResultPar, expectedDotResult ); +#ifdef LINALG_ENABLE_TBB + const auto dotResultPar = dot (std::execution::par, x, y); +#else + const auto dotResultPar = dot (std::execution::seq, x, y); +#endif // LINALG_ENABLE_TBB + static_assert( std::is_same_v, scalar_t> ); + EXPECT_EQ( dotResultPar, expectedDotResult ); } TEST(BLAS1_dot, mdspan_complex_double_test1) @@ -102,8 +102,8 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 1.0, real_t(k) + 1.0); const scalar_t y_k(real_t(k) + 2.0, real_t(k) + 2.0); - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; expectedDotResult += x_k * y_k; using std::conj; expectedConjDotResult += conj(x_k) * (y_k); @@ -125,14 +125,13 @@ namespace { static_assert( std::is_same_v, scalar_t> ); EXPECT_EQ( conjDotResultTwoArg, expectedConjDotResult ); - //scalar_t dotResultPar {}; - // See note above. - //std::experimental::dot (std::execution::par, x, y, dotResultPar); - - // This is noncomforming, but I need some way to test the executor overloads. - //using fake_executor_t = int; - //dot (fake_executor_t (), x, y, dotResultPar); - //EXPECT_EQ( dotResultPar, expectedDotResult ); +#ifdef LINALG_ENABLE_TBB + const auto dotResultPar = dot (std::execution::par, x, y); +#else + const auto dotResultPar = dot (std::execution::seq, x, y); +#endif // LINALG_ENABLE_TBB + static_assert( std::is_same_v, scalar_t> ); + EXPECT_EQ( dotResultPar, expectedDotResult ); } TEST(BLAS1_dot, mdspan_complex_double_test2) @@ -152,19 +151,18 @@ namespace { scalar_t expectedConjDotResult{}; for (std::size_t k = 0; k < vectorSize; ++k) { - scalar_t x_k = {}; scalar_t y_k = {}; if (k % 2 == 0){ - x_k = scalar_t(real_t(k) + 1.0, real_t(k) + 1.0); - y_k = scalar_t(real_t(k) + 2.0, real_t(k) + 2.0); + x_k = scalar_t(real_t(k) + 1.0, real_t(k) + 1.0); + y_k = scalar_t(real_t(k) + 2.0, real_t(k) + 2.0); } else{ - x_k = scalar_t(real_t(k) - 1.0, real_t(k) + 1.0); - y_k = scalar_t(real_t(k) + 2.0, real_t(k) - 2.0); + x_k = scalar_t(real_t(k) - 1.0, real_t(k) + 1.0); + y_k = scalar_t(real_t(k) + 2.0, real_t(k) - 2.0); } - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; expectedDotResult += x_k * y_k; using std::conj; expectedConjDotResult += conj(x_k) * (y_k); @@ -185,9 +183,13 @@ namespace { const auto conjDotResultTwoArg = dotc(x, y); static_assert( std::is_same_v, scalar_t> ); EXPECT_EQ( conjDotResultTwoArg, expectedConjDotResult ); + +#ifdef LINALG_ENABLE_TBB + const auto dotResultPar = dot (std::execution::par, x, y); +#else + const auto dotResultPar = dot (std::execution::seq, x, y); +#endif // LINALG_ENABLE_TBB + static_assert( std::is_same_v, scalar_t> ); + EXPECT_EQ( dotResultPar, expectedDotResult ); } } - -// int main() { -// std::cout << "hello world" << std::endl; -// } diff --git a/tests/native/gemm.cpp b/tests/native/gemm.cpp index e88d7267..c7417f47 100644 --- a/tests/native/gemm.cpp +++ b/tests/native/gemm.cpp @@ -7,7 +7,7 @@ namespace { using std::experimental::mdspan; - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::layout_left; using std::experimental::linalg::explicit_diagonal; @@ -33,7 +33,7 @@ namespace { const std::size_t A_numCols = A.extent(1); for (std::size_t j = 0; j < A_numCols; ++j) { for (std::size_t i = 0; i < A_numRows; ++i) { - A(i,j) = int((i+startVal) + (j+startVal) * A_numRows); + A[i,j] = int((i+startVal) + (j+startVal) * A_numRows); } } } @@ -47,7 +47,7 @@ namespace { const std::size_t A_numCols = A.extent(1); for (std::size_t j = 0; j < A_numCols; ++j) { for (std::size_t i = 0; i < A_numRows; ++i) { - A(i,j) = (double(i)+startVal) + + A[i,j] = (double(i)+startVal) + (double(j)+startVal) * double(A_numRows); } } @@ -109,20 +109,20 @@ namespace { fill_matrix(B, scalar_t(real_t(2))); for (std::size_t j = 0; j < A_numCols; ++j) { for (std::size_t i = 0; i < A_numRows; ++i) { - A_t(j,i) = A(i,j); + A_t[j,i] = A[i,j]; } } for (std::size_t j = 0; j < B_numCols; ++j) { for (std::size_t i = 0; i < B_numRows; ++i) { - B_t(j,i) = B(i,j); + B_t[j,i] = B[i,j]; } } for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - C(i,j) = scalar_t(0.0); // this works even for complex + C[i,j] = scalar_t(0.0); // this works even for complex for (std::size_t k = 0; k < A_numCols; ++k) { - C(i,j) += A(i,k) * B(k,j); + C[i,j] += A[i,k] * B[k,j]; } } } @@ -131,7 +131,7 @@ namespace { // computed everything. for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - C2(i,j) = std::numeric_limits::min(); + C2[i,j] = std::numeric_limits::min(); } } @@ -142,7 +142,9 @@ namespace { matrix_product(A, B, C2); for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - EXPECT_DOUBLE_EQ(C2(i,j), C(i,j)) << "Matrices differ at index (" + // AMK 5.6.23 googletest gets confused by the [r,c] notation + // and gives an error message about having 3 params instead of 2 + EXPECT_DOUBLE_EQ((C2[i,j]), (C[i,j])) << "Matrices differ at index (" << i << "," << j << ")=\n"; } } @@ -151,7 +153,7 @@ namespace { // we computed everything. for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - C3(i,j) = std::numeric_limits::min(); + C3[i,j] = std::numeric_limits::min(); } } @@ -165,7 +167,7 @@ namespace { transposed(B_t), C3); for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - EXPECT_DOUBLE_EQ(C3(i,j), C(i,j)) << "Matrices differ at index (" + EXPECT_DOUBLE_EQ((C3[i,j]), (C[i,j])) << "Matrices differ at index (" << i << "," << j << ")=\n"; } } @@ -183,9 +185,9 @@ namespace { for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - C(i,j) = scalar_t(0.0); // this works even for complex + C[i,j] = scalar_t(0.0); // this works even for complex for (std::size_t k = 0; k < A_tt.extent(1); ++k) { - C(i,j) += A_tt(i,k) * B_tt(k,j); + C[i,j] += A_tt[i,k] * B_tt[k,j]; } } } @@ -196,7 +198,7 @@ namespace { for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - EXPECT_DOUBLE_EQ(C3(i,j), C(i,j)) << "Matrices differ at index (" + EXPECT_DOUBLE_EQ((C3[i,j]), (C[i,j])) << "Matrices differ at index (" << i << "," << j << ")=\n"; } } @@ -212,7 +214,7 @@ namespace { for (std::size_t j = 0; j < C_numCols; ++j) { for (std::size_t i = 0; i < C_numRows; ++i) { - EXPECT_DOUBLE_EQ(C3(i,j), scalar_t(2.0)*C(i,j)) + EXPECT_DOUBLE_EQ((C3[i,j]), (scalar_t(2.0)*C[i,j])) << "Matrices differ at index (" << i << "," << j << ")=\n"; } diff --git a/tests/native/gemv.cpp b/tests/native/gemv.cpp index b126ae4f..2ff51860 100644 --- a/tests/native/gemv.cpp +++ b/tests/native/gemv.cpp @@ -7,7 +7,7 @@ namespace { using std::experimental::mdspan; - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::layout_left; using std::experimental::linalg::matrix_vector_product; @@ -28,7 +28,7 @@ namespace { const std::size_t A_numCols = A.extent(1); for (std::size_t j = 0; j < A_numCols; ++j) { for (std::size_t i = 0; i < A_numRows; ++i) { - A(i,j) = int((i+startVal) + (j+startVal) * A_numRows); + A[i,j] = int((i+startVal) + (j+startVal) * A_numRows); } } } @@ -42,7 +42,7 @@ namespace { const std::size_t A_numCols = A.extent(1); for (std::size_t j = 0; j < A_numCols; ++j) { for (std::size_t i = 0; i < A_numRows; ++i) { - A(i,j) = (double(i)+startVal) + + A[i,j] = (double(i)+startVal) + (double(j)+startVal) * double(A_numRows); } } @@ -65,7 +65,7 @@ namespace { { const std::size_t numRows = x.extent(0); for (std::size_t i = 0; i < numRows; ++i) { - x(i) = int(i+startVal); + x[i] = int(i+startVal); } } }; @@ -76,7 +76,7 @@ namespace { { const std::size_t numRows = x.extent(0); for (std::size_t i = 0; i < numRows; ++i) { - x(i) = double(i+startVal); + x[i] = double(i+startVal); } } }; @@ -125,27 +125,27 @@ namespace { // Initialize vector to zero for (std::size_t i = 0; i < numRows; i++) { - gs(i) = scalar_t(0.0); // this works even for complex + gs[i] = scalar_t(0.0); // this works even for complex } // Perform matvec for (std::size_t j = 0; j < numCols; ++j) { for (std::size_t i = 0; i < numRows; ++i) { - gs(i) += A(i,j) * x(j); + gs[i] += A[i,j] * x[j]; } } // Fill result vector with flag values to make sure that we // computed everything. for (std::size_t j = 0; j < numRows; ++j) { - y(j) = std::numeric_limits::min(); + y[j] = std::numeric_limits::min(); } cout << " Test y = A(" << numRows << " x " << numCols << ") * x = y\n"; matrix_vector_product(A, x, y); for (std::size_t i = 0; i < numRows; ++i) { - EXPECT_DOUBLE_EQ(y(i), gs(i)) << "Vectors differ at index " << i; + EXPECT_DOUBLE_EQ(y[i], gs[i]) << "Vectors differ at index " << i; } } // numCols } // numRows diff --git a/tests/native/gemv_no_ambig.cpp b/tests/native/gemv_no_ambig.cpp index 17c3a21c..231d2fd2 100644 --- a/tests/native/gemv_no_ambig.cpp +++ b/tests/native/gemv_no_ambig.cpp @@ -16,7 +16,7 @@ namespace { using std::experimental::mdspan; using std::experimental::extents; -using std::experimental::dynamic_extent; +using std::dynamic_extent; using std::experimental::linalg::matrix_vector_product; using std::experimental::linalg::scaled; @@ -34,11 +34,11 @@ TEST(gemv, no_ambiguity) mdspan> y(y_vec.data(),N); for(int i=0; i namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::givens_rotation_setup; @@ -168,8 +168,8 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0); const scalar_t y_k(real_t(k) + 5.0); - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; } { @@ -185,8 +185,8 @@ namespace { y_k = c * y_k - s * x_k; x_k = tmp; - EXPECT_EQ( x(k), x_k ); - EXPECT_EQ( y(k), y_k ); + EXPECT_EQ( x[k], x_k ); + EXPECT_EQ( y[k], y_k ); } } { @@ -202,8 +202,8 @@ namespace { y_k = c * y_k - s * x_k; x_k = tmp; - EXPECT_EQ( x(k), x_k ); - EXPECT_EQ( y(k), y_k ); + EXPECT_EQ( x[k], x_k ); + EXPECT_EQ( y[k], y_k ); } } } @@ -224,8 +224,8 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); const scalar_t y_k(real_t(k) + 5.0, -real_t(k) - 2.0); - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; } using std::conj; @@ -243,8 +243,8 @@ namespace { y_k = c * y_k - conj(s) * x_k; x_k = tmp; - EXPECT_EQ( x(k), x_k ); - EXPECT_EQ( y(k), y_k ); + EXPECT_EQ( x[k], x_k ); + EXPECT_EQ( y[k], y_k ); } } { @@ -260,8 +260,8 @@ namespace { y_k = c * y_k - conj(s) * x_k; x_k = tmp; - EXPECT_EQ( x(k), x_k ); - EXPECT_EQ( y(k), y_k ); + EXPECT_EQ( x[k], x_k ); + EXPECT_EQ( y[k], y_k ); } } } diff --git a/tests/native/gtest_fixtures.hpp b/tests/native/gtest_fixtures.hpp index 04f1a039..7ac992a2 100644 --- a/tests/native/gtest_fixtures.hpp +++ b/tests/native/gtest_fixtures.hpp @@ -49,7 +49,7 @@ #include #include - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using dbl_vector_t = mdspan>; @@ -64,16 +64,16 @@ storage(10), v(storage.data(), 10) { - v(0) = 0.5; - v(1) = 0.2; - v(2) = 0.1; - v(3) = 0.4; - v(4) = 0.8; - v(5) = 0.7; - v(6) = 0.3; - v(7) = 0.5; - v(8) = 0.2; - v(9) = 0.9; + v[0] = 0.5; + v[1] = 0.2; + v[2] = 0.1; + v[3] = 0.4; + v[4] = 0.8; + v[5] = 0.7; + v[6] = 0.3; + v[7] = 0.5; + v[8] = 0.2; + v[9] = 0.9; } std::vector storage; @@ -88,16 +88,16 @@ storage(10), v(storage.data(), 10) { - v(0) = 0.5; - v(1) = 0.2; - v(2) = 0.1; - v(3) = 0.4; - v(4) = -0.8; - v(5) = -0.7; - v(6) = -0.3; - v(7) = 0.5; - v(8) = 0.2; - v(9) = -0.9; + v[0] = 0.5; + v[1] = 0.2; + v[2] = 0.1; + v[3] = 0.4; + v[4] = -0.8; + v[5] = -0.7; + v[6] = -0.3; + v[7] = 0.5; + v[8] = 0.2; + v[9] = -0.9; } std::vector storage; @@ -113,11 +113,11 @@ storage(5), v(storage.data(), 5) { - v(0) = std::complex( 0.5, 0.2); - v(1) = std::complex( 0.1, 0.4); - v(2) = std::complex(-0.8, -0.7); - v(3) = std::complex(-0.3, 0.5); - v(4) = std::complex( 0.2, -0.9); + v[0] = std::complex( 0.5, 0.2); + v[1] = std::complex( 0.1, 0.4); + v[2] = std::complex(-0.8, -0.7); + v[3] = std::complex(-0.3, 0.5); + v[4] = std::complex( 0.2, -0.9); } std::vector> storage; diff --git a/tests/native/hemm.cpp b/tests/native/hemm.cpp index e493aa3b..7b6aa3ba 100644 --- a/tests/native/hemm.cpp +++ b/tests/native/hemm.cpp @@ -8,7 +8,7 @@ namespace { using std::experimental::mdspan; - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::layout_left; using std::experimental::linalg::explicit_diagonal; @@ -46,28 +46,28 @@ namespace { cmatrix_t gs(gs_mem.data(), m, n); // Fill A - A(0,0) = -4.0; - A(1,0) = 4.0 + 4.4i; - A(1,1) = 3.5; - A(2,0) = 4.4 + 2.2i; - A(2,1) = -2.8 - 4.0i; - A(2,2) = -1.2; + A[0,0] = -4.0; + A[1,0] = 4.0 + 4.4i; + A[1,1] = 3.5; + A[2,0] = 4.4 + 2.2i; + A[2,1] = -2.8 - 4.0i; + A[2,2] = -1.2; // Fill B - B(0,0) = 1.3; - B(0,1) = 2.5; - B(1,0) = -4.6; - B(1,1) = -3.7; - B(2,0) = 3.1; - B(2,1) = -1.5; + B[0,0] = 1.3; + B[0,1] = 2.5; + B[1,0] = -4.6; + B[1,1] = -3.7; + B[2,0] = 3.1; + B[2,1] = -1.5; // Fill GS - gs(0,0) = -9.96 + 13.42i; - gs(0,1) = -31.4 + 19.58i; - gs(1,0) = -19.58 + 18.12i; - gs(1,1) = 1.25 + 5.0i; - gs(2,0) = 14.88 + 21.26i; - gs(2,1) = 23.16 + 20.3i; + gs[0,0] = -9.96 + 13.42i; + gs[0,1] = -31.4 + 19.58i; + gs[1,0] = -19.58 + 18.12i; + gs[1,1] = 1.25 + 5.0i; + gs[2,0] = 14.88 + 21.26i; + gs[2,1] = 23.16 + 20.3i; hermitian_matrix_left_product(A, lower_triangle, B, C); @@ -75,7 +75,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -102,28 +102,28 @@ namespace { cmatrix_t gs(gs_mem.data(), m, n); // Fill A - A(0,0) = -4.0; - A(0,1) = 4.0 - 4.4i; - A(1,1) = 3.5; - A(0,2) = 4.4 - 2.2i; - A(1,2) = -2.8 + 4.0i; - A(2,2) = -1.2; + A[0,0] = -4.0; + A[0,1] = 4.0 - 4.4i; + A[1,1] = 3.5; + A[0,2] = 4.4 - 2.2i; + A[1,2] = -2.8 + 4.0i; + A[2,2] = -1.2; // Fill B - B(0,0) = 1.3; - B(0,1) = 2.5; - B(1,0) = -4.6; - B(1,1) = -3.7; - B(2,0) = 3.1; - B(2,1) = -1.5; + B[0,0] = 1.3; + B[0,1] = 2.5; + B[1,0] = -4.6; + B[1,1] = -3.7; + B[2,0] = 3.1; + B[2,1] = -1.5; // Fill GS - gs(0,0) = -9.96 + 13.42i; - gs(0,1) = -31.4 + 19.58i; - gs(1,0) = -19.58 + 18.12i; - gs(1,1) = 1.25 + 5.0i; - gs(2,0) = 14.88 + 21.26i; - gs(2,1) = 23.16 + 20.3i; + gs[0,0] = -9.96 + 13.42i; + gs[0,1] = -31.4 + 19.58i; + gs[1,0] = -19.58 + 18.12i; + gs[1,1] = 1.25 + 5.0i; + gs[2,0] = 14.88 + 21.26i; + gs[2,1] = 23.16 + 20.3i; hermitian_matrix_left_product(A, upper_triangle, B, C); @@ -131,7 +131,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -158,28 +158,28 @@ namespace { cmatrix_t gs(gs_mem.data(), n, m); // Fill A - A(0,0) = -4.0; - A(1,0) = 4.0 + 4.4i; - A(1,1) = 3.5; - A(2,0) = 4.4 + 2.2i; - A(2,1) = -2.8 - 4.0i; - A(2,2) = -1.2; + A[0,0] = -4.0; + A[1,0] = 4.0 + 4.4i; + A[1,1] = 3.5; + A[2,0] = 4.4 + 2.2i; + A[2,1] = -2.8 - 4.0i; + A[2,2] = -1.2; // Fill B - B(0,0) = 1.3; - B(1,0) = 2.5; - B(0,1) = -4.6; - B(1,1) = -3.7; - B(0,2) = 3.1; - B(1,2) = -1.5; + B[0,0] = 1.3; + B[1,0] = 2.5; + B[0,1] = -4.6; + B[1,1] = -3.7; + B[0,2] = 3.1; + B[1,2] = -1.5; // Fill GS - gs(0,0) = -9.96 - 13.42i; - gs(1,0) = -31.4 - 19.58i; - gs(0,1) = -19.58 - 18.12i; - gs(1,1) = 1.25 - 5.0i; - gs(0,2) = 14.88 - 21.26i; - gs(1,2) = 23.16 - 20.3i; + gs[0,0] = -9.96 - 13.42i; + gs[1,0] = -31.4 - 19.58i; + gs[0,1] = -19.58 - 18.12i; + gs[1,1] = 1.25 - 5.0i; + gs[0,2] = 14.88 - 21.26i; + gs[1,2] = 23.16 - 20.3i; hermitian_matrix_right_product(A, lower_triangle, B, C); @@ -187,7 +187,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -214,28 +214,28 @@ namespace { cmatrix_t gs(gs_mem.data(), n, m); // Fill A - A(0,0) = -4.0; - A(0,1) = 4.0 - 4.4i; - A(1,1) = 3.5; - A(0,2) = 4.4 - 2.2i; - A(1,2) = -2.8 + 4.0i; - A(2,2) = -1.2; + A[0,0] = -4.0; + A[0,1] = 4.0 - 4.4i; + A[1,1] = 3.5; + A[0,2] = 4.4 - 2.2i; + A[1,2] = -2.8 + 4.0i; + A[2,2] = -1.2; // Fill B - B(0,0) = 1.3; - B(1,0) = 2.5; - B(0,1) = -4.6; - B(1,1) = -3.7; - B(0,2) = 3.1; - B(1,2) = -1.5; + B[0,0] = 1.3; + B[1,0] = 2.5; + B[0,1] = -4.6; + B[1,1] = -3.7; + B[0,2] = 3.1; + B[1,2] = -1.5; // Fill GS - gs(0,0) = -9.96 - 13.42i; - gs(1,0) = -31.4 - 19.58i; - gs(0,1) = -19.58 - 18.12i; - gs(1,1) = 1.25 - 5.0i; - gs(0,2) = 14.88 - 21.26i; - gs(1,2) = 23.16 - 20.3i; + gs[0,0] = -9.96 - 13.42i; + gs[1,0] = -31.4 - 19.58i; + gs[0,1] = -19.58 - 18.12i; + gs[1,1] = 1.25 - 5.0i; + gs[0,2] = 14.88 - 21.26i; + gs[1,2] = 23.16 - 20.3i; hermitian_matrix_right_product(A, upper_triangle, B, C); @@ -243,7 +243,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } diff --git a/tests/native/idx_abs_max.cpp b/tests/native/idx_abs_max.cpp index d17148d5..fc8d6176 100644 --- a/tests/native/idx_abs_max.cpp +++ b/tests/native/idx_abs_max.cpp @@ -31,7 +31,7 @@ namespace { constexpr auto expected = std::numeric_limits::max(); std::array arr; - using extents_type = stdexp::extents; + using extents_type = stdexp::extents; stdexp::mdspan a(arr.data(),0); EXPECT_EQ(expected, idx_abs_max(a)); diff --git a/tests/native/iterator.cpp b/tests/native/iterator.cpp index 75bac785..a1773f08 100644 --- a/tests/native/iterator.cpp +++ b/tests/native/iterator.cpp @@ -10,8 +10,8 @@ #include namespace { - using std::experimental::full_extent; - using std::experimental::dynamic_extent; + using std::full_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::layout_left; using std::experimental::layout_right; @@ -108,7 +108,7 @@ namespace { } reference operator*() const { - return x_(current_index_); + return x_[current_index_]; } pointer operator->() const { @@ -247,14 +247,14 @@ namespace { const ptrdiff_t dim = x.extent(0); for (ptrdiff_t k = 0; k < dim; ++k) { - x(k) = value_type(real_t(k+1)); + x[k] = value_type(real_t(k+1)); } std::rotate(begin(x), begin(x) + 1, end(x)); std::sort(begin(x), end(x)); for (ptrdiff_t k = 0; k < dim; ++k) { const ptrdiff_t km1 = (k + dim) % dim; - if (x(km1) != value_type(real_t(k+1))) { + if (x[km1] != value_type(real_t(k+1))) { return false; } } @@ -280,7 +280,7 @@ namespace { for (ptrdiff_t i = 0; i < dim; ++i) { for (ptrdiff_t j = 0; j < dim; ++j) { - A(i,j) = scalar_t(real_t(j+1)) + + A[i,j] = scalar_t(real_t(j+1)) + scalar_t(real_t(A.stride(0)*(i+1))); } } @@ -309,8 +309,8 @@ namespace { ptrdiff_t k = 0; auto it = the_beg; for ( ; it != the_end; ++it, ++k) { // test prefix ++ - ASSERT_TRUE( *it == A_col0(k) ); - ASSERT_TRUE( *it == A(k,0) ); + ASSERT_TRUE( *it == A_col0[k] ); + ASSERT_TRUE( *it == (A[k,0]) ); const auto expected_val = scalar_t(real_t(1)) + scalar_t(real_t(A.stride(0)*(k+1))); ASSERT_TRUE( *it == expected_val ); @@ -328,8 +328,8 @@ namespace { ptrdiff_t k = 0; auto it = the_beg; for ( ; it != the_end; ++k, it++) { // test postfix ++ - ASSERT_TRUE( *it == A_col0(k) ); - ASSERT_TRUE( *it == A(k,0) ); + ASSERT_TRUE( *it == A_col0[k] ); + ASSERT_TRUE( *it == (A[k,0]) ); const auto expected_val = scalar_t(real_t(1)) + scalar_t(real_t(A.stride(0)*(k+1))); ASSERT_TRUE( *it == expected_val ); @@ -349,7 +349,7 @@ namespace { for (ptrdiff_t i = 0; i < dim; ++i) { for (ptrdiff_t j = 0; j < dim; ++j) { - A(i,j) = scalar_t(real_t(j+1)) + + A[i,j] = scalar_t(real_t(j+1)) + scalar_t(real_t(A.stride(0)*(i+1))); } } @@ -381,8 +381,8 @@ namespace { ptrdiff_t k = 0; auto it = the_beg; for ( ; it != the_end; ++it, ++k) { // test prefix ++ - ASSERT_TRUE( *it == A_row0(k) ); - ASSERT_TRUE( *it == A(0,k) ); + ASSERT_TRUE( *it == A_row0[k] ); + ASSERT_TRUE( *it == (A[0,k]) ); const auto expected_val = scalar_t(real_t(k+1)) + scalar_t(real_t(A.stride(0))); ASSERT_TRUE( *it == expected_val ); @@ -402,8 +402,8 @@ namespace { ptrdiff_t k = 0; auto it = the_beg; for ( ; it != the_end; ++k, it++) { // test postfix ++ - ASSERT_TRUE( *it == A_row0(k) ); - ASSERT_TRUE( *it == A(0,k) ); + ASSERT_TRUE( *it == A_row0[k] ); + ASSERT_TRUE( *it == (A[0,k]) ); const auto expected_val = scalar_t(real_t(k+1)) + scalar_t(real_t(A.stride(0))); ASSERT_TRUE( *it == expected_val ); diff --git a/tests/native/matrix_inf_norm.cpp b/tests/native/matrix_inf_norm.cpp index 48e58c38..57326492 100644 --- a/tests/native/matrix_inf_norm.cpp +++ b/tests/native/matrix_inf_norm.cpp @@ -15,8 +15,8 @@ namespace { using basic_matrix_t = std::experimental::mdspan< ElementType, std::experimental::extents, + std::dynamic_extent, + std::dynamic_extent>, Layout, std::experimental::default_accessor>; @@ -50,7 +50,7 @@ namespace { for (std::size_t j = 0; j < A_numCols; ++j) { const auto A_ij = (ElementType(i)+startVal) + (ElementType(j)+startVal) * ElementType(A_numRows); - A(i,j) = A_ij; + A[i,j] = A_ij; curRowOneNorm += abs(A_ij); } maxRowNorm = std::max(maxRowNorm, curRowOneNorm); diff --git a/tests/native/matrix_one_norm.cpp b/tests/native/matrix_one_norm.cpp index 65b8bc1a..42b68885 100644 --- a/tests/native/matrix_one_norm.cpp +++ b/tests/native/matrix_one_norm.cpp @@ -8,7 +8,7 @@ namespace { //using std::experimental::mdspan; - //using std::experimental::dynamic_extent; + //using std::dynamic_extent; //using std::experimental::extents; using std::experimental::linalg::matrix_one_norm; using std::cout; @@ -19,8 +19,8 @@ namespace { ElementType, std::experimental::extents< std::size_t, - std::experimental::dynamic_extent, - std::experimental::dynamic_extent>, + std::dynamic_extent, + std::dynamic_extent>, Layout, std::experimental::default_accessor>; @@ -54,7 +54,7 @@ namespace { for (std::size_t i = 0; i < A_numRows; ++i) { const auto A_ij = (ElementType(i)+startVal) + (ElementType(j)+startVal) * ElementType(A_numRows); - A(i,j) = A_ij; + A[i,j] = A_ij; curColOneNorm += abs(A_ij); } maxColNorm = std::max(maxColNorm, curColOneNorm); diff --git a/tests/native/norm2.cpp b/tests/native/norm2.cpp index 7294773e..97d30c86 100644 --- a/tests/native/norm2.cpp +++ b/tests/native/norm2.cpp @@ -21,7 +21,7 @@ double dnrm2_wrapper(const int N, const double* X, const int INCX) #endif // 0 namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::vector_norm2; @@ -107,7 +107,7 @@ namespace { mag_t expectedNormResultSquared {}; for (std::size_t k = vectorSize; k > 1; --k) { const scalar_t x_k = scalar_t(k); - x(k-1) = x_k; + x[k-1] = x_k; expectedNormResultSquared += x_k * x_k; } @@ -152,7 +152,7 @@ namespace { mag_t expectedNormResultSquared {}; for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 3.0, -real_t(k) - 1.0); - x(k) = x_k; + x[k] = x_k; expectedNormResultSquared += abs(x_k) * abs(x_k); } diff --git a/tests/native/scale.cpp b/tests/native/scale.cpp index 0b3af6b4..4278c3f1 100644 --- a/tests/native/scale.cpp +++ b/tests/native/scale.cpp @@ -5,7 +5,7 @@ #include namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::scale; @@ -24,25 +24,25 @@ namespace { { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t (k) + 1.0; - x(k) = x_k; + x[k] = x_k; } const scalar_t scaleFactor = 5.0; scale(scaleFactor, x); for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t (k) + 1.0; - EXPECT_EQ( x(k), scaleFactor * x_k ); + EXPECT_EQ( x[k], scaleFactor * x_k ); } } { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t (k) + 1.0; - x(k) = x_k; + x[k] = x_k; } const float scaleFactor = 5.0; scale(scaleFactor, x); for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t (k) + 1.0; - EXPECT_EQ( x(k), scaleFactor * x_k ); + EXPECT_EQ( x[k], scaleFactor * x_k ); } } } @@ -62,25 +62,25 @@ namespace { { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); - x(k) = x_k; + x[k] = x_k; } const real_t scaleFactor = 5.0; scale(scaleFactor, x); for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); - EXPECT_EQ( x(k), scaleFactor * x_k ); + EXPECT_EQ( x[k], scaleFactor * x_k ); } } { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); - x(k) = x_k; + x[k] = x_k; } const scalar_t scaleFactor (5.0, -1.0); scale(scaleFactor, x); for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); - EXPECT_EQ( x(k), scaleFactor * x_k ); + EXPECT_EQ( x[k], scaleFactor * x_k ); } } } diff --git a/tests/native/scaled.cpp b/tests/native/scaled.cpp index 9f554226..d3bbe07a 100644 --- a/tests/native/scaled.cpp +++ b/tests/native/scaled.cpp @@ -6,7 +6,7 @@ #include namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::scaled; @@ -81,8 +81,8 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const vector_element_type x_k = vector_element_type(k) + 1.0; const vector_element_type y_k = vector_element_type(k) + 2.0; - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; } const scaling_factor_type scalingFactor (-3.0); @@ -99,19 +99,19 @@ namespace { auto y_scaled = scaled (scalingFactor, y); for (std::size_t k = 0; k < vectorSize; ++k) { const vector_element_type x_k = vector_element_type(k) + 1.0; - EXPECT_EQ( x(k), x_k ); + EXPECT_EQ( x[k], x_k ); // Make sure that scaled doesn't modify the entries of the // original thing. const vector_element_type y_k = vector_element_type(k) + 2.0; - EXPECT_EQ( y(k), y_k ); + EXPECT_EQ( y[k], y_k ); const vector_element_type y_k_scaled = scalingFactor * y_k; - EXPECT_EQ( y_scaled(k), y_k_scaled ); + EXPECT_EQ( y_scaled[k], y_k_scaled ); // Don't ever capture an expression template type by auto in // real code. I'm just testing whether some operators work. - auto y_scaled_ref = y_scaled(k); + auto y_scaled_ref = y_scaled[k]; using ref_t = decltype(y_scaled_ref); static_assert(! std::is_same_v); @@ -148,7 +148,7 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const vector_element_type x_k = vector_element_type(k) + 1.0; - x(k) = x_k; + x[k] = x_k; } const scaling_factor_type scalingFactor (-3.0); diff --git a/tests/native/swap.cpp b/tests/native/swap.cpp index bc9e7ebc..bda15879 100644 --- a/tests/native/swap.cpp +++ b/tests/native/swap.cpp @@ -5,7 +5,7 @@ #include namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::swap_elements; @@ -25,16 +25,16 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t (k) + 1.0; const scalar_t y_k = scalar_t (k) + 2.0; - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; } swap_elements(x, y); for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k = scalar_t (k) + 1.0; const scalar_t y_k = scalar_t (k) + 2.0; - EXPECT_EQ( x(k), y_k ); - EXPECT_EQ( y(k), x_k ); + EXPECT_EQ( x[k], y_k ); + EXPECT_EQ( y[k], x_k ); } } @@ -54,16 +54,16 @@ namespace { for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); const scalar_t y_k(real_t(k) + 5.0, -real_t(k) - 2.0); - x(k) = x_k; - y(k) = y_k; + x[k] = x_k; + y[k] = y_k; } swap_elements(x, y); for (std::size_t k = 0; k < vectorSize; ++k) { const scalar_t x_k(real_t(k) + 4.0, -real_t(k) - 1.0); const scalar_t y_k(real_t(k) + 5.0, -real_t(k) - 2.0); - EXPECT_EQ( x(k), y_k ); - EXPECT_EQ( y(k), x_k ); + EXPECT_EQ( x[k], y_k ); + EXPECT_EQ( y[k], x_k ); } } } diff --git a/tests/native/symm.cpp b/tests/native/symm.cpp index 45bd9384..1b501d61 100644 --- a/tests/native/symm.cpp +++ b/tests/native/symm.cpp @@ -8,7 +8,7 @@ namespace { using std::experimental::mdspan; - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::layout_left; using std::experimental::linalg::explicit_diagonal; @@ -46,28 +46,28 @@ namespace { cmatrix_t gs(gs_mem.data(), m, n); // Fill A - A(0,0) = -4.0 + 0.9i; - A(1,0) = 4.0 + 4.4i; - A(1,1) = 3.5 - 4.2i; - A(2,0) = 4.4 + 2.2i; - A(2,1) = -2.8 - 4.0i; - A(2,2) = -1.2 + 1.7i; + A[0,0] = -4.0 + 0.9i; + A[1,0] = 4.0 + 4.4i; + A[1,1] = 3.5 - 4.2i; + A[2,0] = 4.4 + 2.2i; + A[2,1] = -2.8 - 4.0i; + A[2,2] = -1.2 + 1.7i; // Fill B - B(0,0) = 1.3; - B(0,1) = 2.5; - B(1,0) = -4.6; - B(1,1) = -3.7; - B(2,0) = 3.1; - B(2,1) = -1.5; + B[0,0] = 1.3; + B[0,1] = 2.5; + B[1,0] = -4.6; + B[1,1] = -3.7; + B[2,0] = 3.1; + B[2,1] = -1.5; // Fill GS - gs(0,0) = -9.96 - 12.25i; - gs(0,1) = -31.4 - 17.33i; - gs(1,0) = -19.58 + 12.64i; - gs(1,1) = 1.25 + 32.54i; - gs(2,0) = 14.88 + 26.53i; - gs(2,1) = 23.16 + 17.75i; + gs[0,0] = -9.96 - 12.25i; + gs[0,1] = -31.4 - 17.33i; + gs[1,0] = -19.58 + 12.64i; + gs[1,1] = 1.25 + 32.54i; + gs[2,0] = 14.88 + 26.53i; + gs[2,1] = 23.16 + 17.75i; symmetric_matrix_left_product(A, lower_triangle, B, C); @@ -75,7 +75,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -102,28 +102,28 @@ namespace { cmatrix_t gs(gs_mem.data(), m, n); // Fill A - A(0,0) = -4.0 + 0.9i; - A(0,1) = 4.0 + 4.4i; - A(1,1) = 3.5 - 4.2i; - A(0,2) = 4.4 + 2.2i; - A(1,2) = -2.8 - 4.0i; - A(2,2) = -1.2 + 1.7i; + A[0,0] = -4.0 + 0.9i; + A[0,1] = 4.0 + 4.4i; + A[1,1] = 3.5 - 4.2i; + A[0,2] = 4.4 + 2.2i; + A[1,2] = -2.8 - 4.0i; + A[2,2] = -1.2 + 1.7i; // Fill B - B(0,0) = 1.3; - B(0,1) = 2.5; - B(1,0) = -4.6; - B(1,1) = -3.7; - B(2,0) = 3.1; - B(2,1) = -1.5; + B[0,0] = 1.3; + B[0,1] = 2.5; + B[1,0] = -4.6; + B[1,1] = -3.7; + B[2,0] = 3.1; + B[2,1] = -1.5; // Fill GS - gs(0,0) = -9.96 - 12.25i; - gs(0,1) = -31.4 - 17.33i; - gs(1,0) = -19.58 + 12.64i; - gs(1,1) = 1.25 + 32.54i; - gs(2,0) = 14.88 + 26.53i; - gs(2,1) = 23.16 + 17.75i; + gs[0,0] = -9.96 - 12.25i; + gs[0,1] = -31.4 - 17.33i; + gs[1,0] = -19.58 + 12.64i; + gs[1,1] = 1.25 + 32.54i; + gs[2,0] = 14.88 + 26.53i; + gs[2,1] = 23.16 + 17.75i; symmetric_matrix_left_product(A, upper_triangle, B, C); @@ -131,7 +131,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -158,28 +158,28 @@ namespace { cmatrix_t gs(gs_mem.data(), n, m); // Fill A - A(0,0) = -4.0 + 0.9i; - A(1,0) = 4.0 + 4.4i; - A(1,1) = 3.5 - 4.2i; - A(2,0) = 4.4 + 2.2i; - A(2,1) = -2.8 - 4.0i; - A(2,2) = -1.2 + 1.7i; + A[0,0] = -4.0 + 0.9i; + A[1,0] = 4.0 + 4.4i; + A[1,1] = 3.5 - 4.2i; + A[2,0] = 4.4 + 2.2i; + A[2,1] = -2.8 - 4.0i; + A[2,2] = -1.2 + 1.7i; // Fill B - B(0,0) = 1.3; - B(1,0) = 2.5; - B(0,1) = -4.6; - B(1,1) = -3.7; - B(0,2) = 3.1; - B(1,2) = -1.5; + B[0,0] = 1.3; + B[1,0] = 2.5; + B[0,1] = -4.6; + B[1,1] = -3.7; + B[0,2] = 3.1; + B[1,2] = -1.5; // Fill GS - gs(0,0) = -9.96 - 12.25i; - gs(1,0) = -31.4 - 17.33i; - gs(0,1) = -19.58 + 12.64i; - gs(1,1) = 1.25 + 32.54i; - gs(0,2) = 14.88 + 26.53i; - gs(1,2) = 23.16 + 17.75i; + gs[0,0] = -9.96 - 12.25i; + gs[1,0] = -31.4 - 17.33i; + gs[0,1] = -19.58 + 12.64i; + gs[1,1] = 1.25 + 32.54i; + gs[0,2] = 14.88 + 26.53i; + gs[1,2] = 23.16 + 17.75i; symmetric_matrix_right_product(A, lower_triangle, B, C); @@ -187,7 +187,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -214,28 +214,28 @@ namespace { cmatrix_t gs(gs_mem.data(), n, m); // Fill A - A(0,0) = -4.0 + 0.9i; - A(0,1) = 4.0 + 4.4i; - A(1,1) = 3.5 - 4.2i; - A(0,2) = 4.4 + 2.2i; - A(1,2) = -2.8 - 4.0i; - A(2,2) = -1.2 + 1.7i; + A[0,0] = -4.0 + 0.9i; + A[0,1] = 4.0 + 4.4i; + A[1,1] = 3.5 - 4.2i; + A[0,2] = 4.4 + 2.2i; + A[1,2] = -2.8 - 4.0i; + A[2,2] = -1.2 + 1.7i; // Fill B - B(0,0) = 1.3; - B(1,0) = 2.5; - B(0,1) = -4.6; - B(1,1) = -3.7; - B(0,2) = 3.1; - B(1,2) = -1.5; + B[0,0] = 1.3; + B[1,0] = 2.5; + B[0,1] = -4.6; + B[1,1] = -3.7; + B[0,2] = 3.1; + B[1,2] = -1.5; // Fill GS - gs(0,0) = -9.96 - 12.25i; - gs(1,0) = -31.4 - 17.33i; - gs(0,1) = -19.58 + 12.64i; - gs(1,1) = 1.25 + 32.54i; - gs(0,2) = 14.88 + 26.53i; - gs(1,2) = 23.16 + 17.75i; + gs[0,0] = -9.96 - 12.25i; + gs[1,0] = -31.4 - 17.33i; + gs[0,1] = -19.58 + 12.64i; + gs[1,1] = 1.25 + 32.54i; + gs[0,2] = 14.88 + 26.53i; + gs[1,2] = 23.16 + 17.75i; symmetric_matrix_right_product(A, upper_triangle, B, C); @@ -243,7 +243,7 @@ namespace { constexpr double TOL = 1e-9; for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_COMPLEX_NEAR(gs(i,j), C(i,j), TOL) + EXPECT_COMPLEX_NEAR((gs[i,j]), (C[i,j]), TOL) << "Matrices differ at index (" << i << "," << j << ")\n"; } diff --git a/tests/native/transposed.cpp b/tests/native/transposed.cpp index 24ed4d56..c4a99b94 100644 --- a/tests/native/transposed.cpp +++ b/tests/native/transposed.cpp @@ -6,7 +6,7 @@ #include namespace { - using std::experimental::dynamic_extent; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::mdspan; using std::experimental::linalg::transposed; @@ -111,8 +111,8 @@ namespace { const scalar_t j_val = scalar_t(real_t(dim)) * (scalar_t(j) + 1.0); const scalar_t val = i_val + j_val; - A(i,j) = val; - B(i,j) = -val; + A[i,j] = val; + B[i,j] = -val; } } @@ -134,14 +134,14 @@ namespace { const scalar_t j_val = scalar_t(real_t(dim)) * (scalar_t(j) + 1.0); const scalar_t val = i_val + j_val; - EXPECT_EQ( A(i,j), val ); - EXPECT_EQ( B(i,j), -val ); + EXPECT_EQ( (A[i,j]), val ); + EXPECT_EQ( (B[i,j]), -val ); - EXPECT_EQ( A_t(j,i), val ); - EXPECT_EQ( B_t(j,i), -val ); + EXPECT_EQ( (A_t[j,i]), val ); + EXPECT_EQ( (B_t[j,i]), -val ); - EXPECT_EQ( A_t(j,i), A(i,j) ); - EXPECT_EQ( B_t(j,i), B(i,j) ); + EXPECT_EQ( (A_t[j,i]), (A[i,j]) ); + EXPECT_EQ( (B_t[j,i]), (B[i,j]) ); } } @@ -168,8 +168,8 @@ namespace { const scalar_t j_val = scalar_t(real_t(dim)) * (scalar_t(j) + 1.0); const scalar_t val = i_val + j_val; - EXPECT_EQ( A_sub_trans(i,j), A_sub(j,i) ); - EXPECT_EQ( A_sub_trans(i,j), A(j,i) ); + EXPECT_EQ( (A_sub_trans[i,j]), (A_sub[j,i]) ); + EXPECT_EQ( (A_sub_trans[i,j]), (A[j,i]) ); } } } diff --git a/tests/native/trmm.cpp b/tests/native/trmm.cpp index 70185745..aab73db4 100644 --- a/tests/native/trmm.cpp +++ b/tests/native/trmm.cpp @@ -12,8 +12,8 @@ namespace { using std::experimental::linalg::matrix_product; using std::experimental::linalg::transposed; using std::experimental::linalg::upper_triangle; - using std::experimental::dextents; - using std::experimental::dynamic_extent; + using std::dextents; + using std::dynamic_extent; using std::experimental::extents; using std::experimental::layout_left; using std::experimental::mdspan; @@ -39,35 +39,35 @@ namespace { matrix_t gs(gs_mem.data(), m, n); // Fill A - A(0,0) = 3.5; - A(1,0) = -2.0; - A(1,1) = 1.2; - A(2,0) = -0.1; - A(2,1) = 4.5; - A(2,2) = -1.0; + A[0,0] = 3.5; + A[1,0] = -2.0; + A[1,1] = 1.2; + A[2,0] = -0.1; + A[2,1] = 4.5; + A[2,2] = -1.0; // Fill B - B(0,0) = -4.4; - B(0,1) = 1.8; - B(1,0) = -1.4; - B(1,1) = 3.4; - B(2,0) = 1.8; - B(2,1) = 1.6; + B[0,0] = -4.4; + B[0,1] = 1.8; + B[1,0] = -1.4; + B[1,1] = 3.4; + B[2,0] = 1.8; + B[2,1] = 1.6; // Fill GS - gs(0,0) = -15.4; - gs(0,1) = 6.3; - gs(1,0) = 7.12; - gs(1,1) = 0.48; - gs(2,0) = -7.66; - gs(2,1) = 13.52; + gs[0,0] = -15.4; + gs[0,1] = 6.3; + gs[1,0] = 7.12; + gs[1,1] = 0.48; + gs[2,0] = -7.66; + gs[2,1] = 13.52; // Check the non-overwriting version triangular_matrix_left_product(A, lower_triangle, explicit_diagonal, B, C); for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), C(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (C[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -78,7 +78,7 @@ namespace { for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), B(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (B[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -104,33 +104,33 @@ TEST(BLAS3_trmm, left_lower_tri_implicit_diag) matrix_t gs(gs_mem.data(), m, n); // Fill A - A(1,0) = -2.0; - A(2,0) = -0.1; - A(2,1) = 4.5; + A[1,0] = -2.0; + A[2,0] = -0.1; + A[2,1] = 4.5; // Fill B - B(0,0) = -4.4; - B(0,1) = 1.8; - B(1,0) = -1.4; - B(1,1) = 3.4; - B(2,0) = 1.8; - B(2,1) = 1.6; + B[0,0] = -4.4; + B[0,1] = 1.8; + B[1,0] = -1.4; + B[1,1] = 3.4; + B[2,0] = 1.8; + B[2,1] = 1.6; triangular_matrix_left_product(A, lower_triangle, implicit_unit_diagonal, B, C); // Fill GS - gs(0,0) = -4.4; - gs(0,1) = 1.8; - gs(1,0) = 7.4; - gs(1,1) = -0.2; - gs(2,0) = -4.06; - gs(2,1) = 16.72; + gs[0,0] = -4.4; + gs[0,1] = 1.8; + gs[1,0] = 7.4; + gs[1,1] = -0.2; + gs[2,0] = -4.06; + gs[2,1] = 16.72; for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), C(i,j), tol) + EXPECT_NEAR((gs[i,j]), (C[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -143,7 +143,7 @@ TEST(BLAS3_trmm, left_lower_tri_implicit_diag) for (ptrdiff_t i = 0; i < m; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), B(i,j), tol) + EXPECT_NEAR((gs[i,j]), (B[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -169,35 +169,35 @@ TEST(BLAS3_trmm, left_upper_tri_explicit_diag) matrix_t gs(gs_mem.data(), m, n); // Fill A - A(0,0) = 3.5; - A(0,1) = -2.0; - A(1,1) = 1.2; - A(0,2) = -0.1; - A(1,2) = 4.5; - A(2,2) = -1.0; + A[0,0] = 3.5; + A[0,1] = -2.0; + A[1,1] = 1.2; + A[0,2] = -0.1; + A[1,2] = 4.5; + A[2,2] = -1.0; // Fill B - B(0,0) = -4.4; - B(0,1) = 1.8; - B(1,0) = -1.4; - B(1,1) = 3.4; - B(2,0) = 1.8; - B(2,1) = 1.6; + B[0,0] = -4.4; + B[0,1] = 1.8; + B[1,0] = -1.4; + B[1,1] = 3.4; + B[2,0] = 1.8; + B[2,1] = 1.6; // Fill GS - gs(0,0) = -12.78; - gs(0,1) = -0.66; - gs(1,0) = 6.42; - gs(1,1) = 11.28; - gs(2,0) = -1.8; - gs(2,1) = -1.6; + gs[0,0] = -12.78; + gs[0,1] = -0.66; + gs[1,0] = 6.42; + gs[1,1] = 11.28; + gs[2,0] = -1.8; + gs[2,1] = -1.6; // Check the non-overwriting version triangular_matrix_left_product(A, upper_triangle, explicit_diagonal, B, C); for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), C(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (C[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -208,7 +208,7 @@ TEST(BLAS3_trmm, left_upper_tri_explicit_diag) for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), B(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (B[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -234,33 +234,33 @@ TEST(BLAS3_trmm, left_upper_tri_implicit_diag) matrix_t gs(gs_mem.data(), m, n); // Fill A - A(0,1) = -2.0; - A(0,2) = -0.1; - A(1,2) = 4.5; + A[0,1] = -2.0; + A[0,2] = -0.1; + A[1,2] = 4.5; // Fill B - B(0,0) = -4.4; - B(0,1) = 1.8; - B(1,0) = -1.4; - B(1,1) = 3.4; - B(2,0) = 1.8; - B(2,1) = 1.6; + B[0,0] = -4.4; + B[0,1] = 1.8; + B[1,0] = -1.4; + B[1,1] = 3.4; + B[2,0] = 1.8; + B[2,1] = 1.6; triangular_matrix_left_product(A, upper_triangle, implicit_unit_diagonal, B, C); // Fill GS - gs(0,0) = -1.78; - gs(0,1) = -5.16; - gs(1,0) = 6.7; - gs(1,1) = 10.6; - gs(2,0) = 1.8; - gs(2,1) = 1.6; + gs[0,0] = -1.78; + gs[0,1] = -5.16; + gs[1,0] = 6.7; + gs[1,1] = 10.6; + gs[2,0] = 1.8; + gs[2,1] = 1.6; for (ptrdiff_t j = 0; j < n; ++j) { for (ptrdiff_t i = 0; i < m; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), C(i,j), tol) + EXPECT_NEAR((gs[i,j]), (C[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -273,7 +273,7 @@ TEST(BLAS3_trmm, left_upper_tri_implicit_diag) for (ptrdiff_t i = 0; i < m; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), B(i,j), tol) + EXPECT_NEAR((gs[i,j]), (B[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -299,35 +299,35 @@ TEST(BLAS3_trmm, right_lower_tri_explicit_diag) matrix_t gs(gs_mem.data(), n, m); // Fill A - A(0,0) = 3.5; - A(1,0) = -2.0; - A(1,1) = 1.2; - A(2,0) = -0.1; - A(2,1) = 4.5; - A(2,2) = -1.0; + A[0,0] = 3.5; + A[1,0] = -2.0; + A[1,1] = 1.2; + A[2,0] = -0.1; + A[2,1] = 4.5; + A[2,2] = -1.0; // Fill B - B(0,0) = -4.4; - B(1,0) = 1.8; - B(0,1) = -1.4; - B(1,1) = 3.4; - B(0,2) = 1.8; - B(1,2) = 1.6; + B[0,0] = -4.4; + B[1,0] = 1.8; + B[0,1] = -1.4; + B[1,1] = 3.4; + B[0,2] = 1.8; + B[1,2] = 1.6; // Fill GS - gs(0,0) = -12.78; - gs(1,0) = -0.66; - gs(0,1) = 6.42; - gs(1,1) = 11.28; - gs(0,2) = -1.8; - gs(1,2) = -1.6; + gs[0,0] = -12.78; + gs[1,0] = -0.66; + gs[0,1] = 6.42; + gs[1,1] = 11.28; + gs[0,2] = -1.8; + gs[1,2] = -1.6; // Check the non-overwriting version triangular_matrix_right_product(A, lower_triangle, explicit_diagonal, B, C); for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), C(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (C[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -338,7 +338,7 @@ TEST(BLAS3_trmm, right_lower_tri_explicit_diag) for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), B(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (B[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -364,33 +364,33 @@ TEST(BLAS3_trmm, right_lower_tri_implicit_diag) matrix_t gs(gs_mem.data(), n, m); // Fill A - A(1,0) = -2.0; - A(2,0) = -0.1; - A(2,1) = 4.5; + A[1,0] = -2.0; + A[2,0] = -0.1; + A[2,1] = 4.5; // Fill B - B(0,0) = -4.4; - B(1,0) = 1.8; - B(0,1) = -1.4; - B(1,1) = 3.4; - B(0,2) = 1.8; - B(1,2) = 1.6; + B[0,0] = -4.4; + B[1,0] = 1.8; + B[0,1] = -1.4; + B[1,1] = 3.4; + B[0,2] = 1.8; + B[1,2] = 1.6; triangular_matrix_right_product(A, lower_triangle, implicit_unit_diagonal, B, C); // Fill GS - gs(0,0) = -1.78; - gs(1,0) = -5.16; - gs(0,1) = 6.7; - gs(1,1) = 10.6; - gs(0,2) = 1.8; - gs(1,2) = 1.6; + gs[0,0] = -1.78; + gs[1,0] = -5.16; + gs[0,1] = 6.7; + gs[1,1] = 10.6; + gs[0,2] = 1.8; + gs[1,2] = 1.6; for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), C(i,j), tol) + EXPECT_NEAR((gs[i,j]), (C[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -403,7 +403,7 @@ TEST(BLAS3_trmm, right_lower_tri_implicit_diag) for (ptrdiff_t i = 0; i < n; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), B(i,j), tol) + EXPECT_NEAR((gs[i,j]), (B[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -429,35 +429,35 @@ TEST(BLAS3_trmm, right_upper_tri_explicit_diag) matrix_t gs(gs_mem.data(), n, m); // Fill A - A(0,0) = 3.5; - A(0,1) = -2.0; - A(1,1) = 1.2; - A(0,2) = -0.1; - A(1,2) = 4.5; - A(2,2) = -1.0; + A[0,0] = 3.5; + A[0,1] = -2.0; + A[1,1] = 1.2; + A[0,2] = -0.1; + A[1,2] = 4.5; + A[2,2] = -1.0; // Fill B - B(0,0) = -4.4; - B(1,0) = 1.8; - B(0,1) = -1.4; - B(1,1) = 3.4; - B(0,2) = 1.8; - B(1,2) = 1.6; + B[0,0] = -4.4; + B[1,0] = 1.8; + B[0,1] = -1.4; + B[1,1] = 3.4; + B[0,2] = 1.8; + B[1,2] = 1.6; // Fill GS - gs(0,0) = -15.4; - gs(1,0) = 6.3; - gs(0,1) = 7.12; - gs(1,1) = 0.48; - gs(0,2) = -7.66; - gs(1,2) = 13.52; + gs[0,0] = -15.4; + gs[1,0] = 6.3; + gs[0,1] = 7.12; + gs[1,1] = 0.48; + gs[0,2] = -7.66; + gs[1,2] = 13.52; // Check the non-overwriting version triangular_matrix_right_product(A, upper_triangle, explicit_diagonal, B, C); for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), C(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (C[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -468,7 +468,7 @@ TEST(BLAS3_trmm, right_upper_tri_explicit_diag) for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { - EXPECT_DOUBLE_EQ(gs(i,j), B(i,j)) + EXPECT_DOUBLE_EQ((gs[i,j]), (B[i,j])) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -494,33 +494,33 @@ TEST(BLAS3_trmm, right_upper_tri_implicit_diag) matrix_t gs(gs_mem.data(), n, m); // Fill A - A(0,1) = -2.0; - A(0,2) = -0.1; - A(1,2) = 4.5; + A[0,1] = -2.0; + A[0,2] = -0.1; + A[1,2] = 4.5; // Fill B - B(0,0) = -4.4; - B(1,0) = 1.8; - B(0,1) = -1.4; - B(1,1) = 3.4; - B(0,2) = 1.8; - B(1,2) = 1.6; + B[0,0] = -4.4; + B[1,0] = 1.8; + B[0,1] = -1.4; + B[1,1] = 3.4; + B[0,2] = 1.8; + B[1,2] = 1.6; triangular_matrix_right_product(A, upper_triangle, implicit_unit_diagonal, B, C); // Fill GS - gs(0,0) = -4.4; - gs(1,0) = 1.8; - gs(0,1) = 7.4; - gs(1,1) = -0.2; - gs(0,2) = -4.06; - gs(1,2) = 16.72; + gs[0,0] = -4.4; + gs[1,0] = 1.8; + gs[0,1] = 7.4; + gs[1,1] = -0.2; + gs[0,2] = -4.06; + gs[1,2] = 16.72; for (ptrdiff_t j = 0; j < m; ++j) { for (ptrdiff_t i = 0; i < n; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), C(i,j), tol) + EXPECT_NEAR((gs[i,j]), (C[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } @@ -533,7 +533,7 @@ TEST(BLAS3_trmm, right_upper_tri_implicit_diag) for (ptrdiff_t i = 0; i < n; ++i) { // FIXME: Choose a more reasonable value for the tolerance constexpr double tol = 1e-9; - EXPECT_NEAR(gs(i,j), B(i,j), tol) + EXPECT_NEAR((gs[i,j]), (B[i,j]), tol) << "Matrices differ at index (" << i << "," << j << ")\n"; } diff --git a/tests/native/trsm.cpp b/tests/native/trsm.cpp index 101c2752..6f5b9574 100644 --- a/tests/native/trsm.cpp +++ b/tests/native/trsm.cpp @@ -8,8 +8,8 @@ namespace { using std::experimental::mdspan; - using std::experimental::dynamic_extent; - using std::experimental::dextents; + using std::dynamic_extent; + using std::dextents; using std::experimental::layout_right; using std::experimental::layout_left; @@ -47,7 +47,7 @@ namespace { mdspan, layout_right> in(in_storage, num_rows, num_cols); for(std::size_t i = 0; i < num_rows; ++i) { for(std::size_t j = 0; j < num_cols; ++j) { - out(i,j) = in(i,j); + out[i,j] = in[i,j]; } } } @@ -82,9 +82,9 @@ namespace { for(IndexType r = 0; r < IndexType(num_rows_B); ++r) { for(IndexType c = 0; c < IndexType(num_cols_A); ++c) { - // We chose the values in A and B so that triangular - // solve could compute them without rounding error. - EXPECT_EQ( X(r,c), B_times_inv_A(r,c) ); + // We chose the values in A and B so that triangular + // solve could compute them without rounding error. + EXPECT_EQ( (X[r,c]), (B_times_inv_A[r,c]) ); } } } diff --git a/tpl-implementations/include/experimental/__p1673_bits/kokkos-kernels/static_extent_match.hpp b/tpl-implementations/include/experimental/__p1673_bits/kokkos-kernels/static_extent_match.hpp index e73ea10c..f8ad070d 100644 --- a/tpl-implementations/include/experimental/__p1673_bits/kokkos-kernels/static_extent_match.hpp +++ b/tpl-implementations/include/experimental/__p1673_bits/kokkos-kernels/static_extent_match.hpp @@ -50,8 +50,8 @@ namespace Impl { template constexpr bool static_extent_match(size_type extent1, size_type extent2) { - return extent1 == std::experimental::dynamic_extent || - extent2 == std::experimental::dynamic_extent || + return extent1 == std::dynamic_extent || + extent2 == std::dynamic_extent || extent1 == extent2; }