diff --git a/include/experimental/__p1673_bits/blas1_dot.hpp b/include/experimental/__p1673_bits/blas1_dot.hpp index 2fa00f7c..2f986f86 100644 --- a/include/experimental/__p1673_bits/blas1_dot.hpp +++ b/include/experimental/__p1673_bits/blas1_dot.hpp @@ -63,6 +63,10 @@ Scalar dot(std::experimental::mdspan, Layout2, Accessor2> v2, Scalar init) { + static_assert(v1.static_extent(0) == dynamic_extent || + v2.static_extent(0) == dynamic_extent || + v1.static_extent(0) == v2.static_extent(0)); + for (size_t k = 0; k < v1.extent(0); ++k) { init += v1(k) * v2(k); } diff --git a/include/experimental/__p1673_bits/blas1_givens.hpp b/include/experimental/__p1673_bits/blas1_givens.hpp index 3370af4d..f12d521b 100644 --- a/include/experimental/__p1673_bits/blas1_givens.hpp +++ b/include/experimental/__p1673_bits/blas1_givens.hpp @@ -359,6 +359,10 @@ void givens_rotation_apply( const Real c, const Real s) { + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + for (extents<>::size_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); @@ -401,6 +405,10 @@ void givens_rotation_apply( const Real c, const complex s) { + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + using std::conj; for (extents<>::size_type i = 0; i < x.extent(0); ++i) { const auto dtemp = c * x(i) + s * y(i); diff --git a/include/experimental/__p1673_bits/blas1_linalg_add.hpp b/include/experimental/__p1673_bits/blas1_linalg_add.hpp index 0ec725fc..f3e23888 100644 --- a/include/experimental/__p1673_bits/blas1_linalg_add.hpp +++ b/include/experimental/__p1673_bits/blas1_linalg_add.hpp @@ -67,6 +67,16 @@ void add_rank_1( std::experimental::mdspan, Layout_y, Accessor_y> y, std::experimental::mdspan, Layout_z, Accessor_z> z) { + static_assert(x.static_extent(0) == dynamic_extent || + z.static_extent(0) == dynamic_extent || + x.static_extent(0) == z.static_extent(0)); + static_assert(y.static_extent(0) == dynamic_extent || + z.static_extent(0) == dynamic_extent || + y.static_extent(0) == z.static_extent(0)); + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + for (extents<>::size_type i = 0; i < z.extent(0); ++i) { z(i) = x(i) + y(i); } @@ -92,6 +102,26 @@ void add_rank_2( std::experimental::mdspan, Layout_y, Accessor_y> y, std::experimental::mdspan, Layout_z, Accessor_z> z) { + static_assert(x.static_extent(0) == dynamic_extent || + z.static_extent(0) == dynamic_extent || + x.static_extent(0) == z.static_extent(0)); + static_assert(y.static_extent(0) == dynamic_extent || + z.static_extent(0) == dynamic_extent || + y.static_extent(0) == z.static_extent(0)); + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + + static_assert(x.static_extent(1) == dynamic_extent || + z.static_extent(1) == dynamic_extent || + x.static_extent(1) == z.static_extent(1)); + static_assert(y.static_extent(1) == dynamic_extent || + z.static_extent(1) == dynamic_extent || + y.static_extent(1) == z.static_extent(1)); + static_assert(x.static_extent(1) == dynamic_extent || + y.static_extent(1) == dynamic_extent || + x.static_extent(1) == y.static_extent(1)); + using size_type = typename extents<>::size_type; for (size_type j = 0; j < x.extent(1); ++j) { diff --git a/include/experimental/__p1673_bits/blas1_linalg_copy.hpp b/include/experimental/__p1673_bits/blas1_linalg_copy.hpp index 2032c1f8..b8f1e86f 100644 --- a/include/experimental/__p1673_bits/blas1_linalg_copy.hpp +++ b/include/experimental/__p1673_bits/blas1_linalg_copy.hpp @@ -62,6 +62,10 @@ void copy_rank_1( std::experimental::mdspan, Layout_x, Accessor_x> x, std::experimental::mdspan, Layout_y, Accessor_y> y) { + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + for (extents<>::size_type i = 0; i < y.extent(0); ++i) { y(i) = x(i); } @@ -81,6 +85,13 @@ void copy_rank_2( std::experimental::mdspan, Layout_x, Accessor_x> x, std::experimental::mdspan, Layout_y, Accessor_y> y) { + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + static_assert(x.static_extent(1) == dynamic_extent || + y.static_extent(1) == dynamic_extent || + x.static_extent(1) == y.static_extent(1)); + using size_type = typename extents<>::size_type; for (size_type j = 0; j < y.extent(1); ++j) { diff --git a/include/experimental/__p1673_bits/blas1_linalg_swap.hpp b/include/experimental/__p1673_bits/blas1_linalg_swap.hpp index 6131e942..36e832ac 100644 --- a/include/experimental/__p1673_bits/blas1_linalg_swap.hpp +++ b/include/experimental/__p1673_bits/blas1_linalg_swap.hpp @@ -64,6 +64,10 @@ void swap_rank_1( std::experimental::mdspan, Layout_x, Accessor_x> x, std::experimental::mdspan, Layout_y, Accessor_y> y) { + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + using std::swap; using size_type = typename extents<>::size_type; @@ -86,6 +90,13 @@ void swap_rank_2( std::experimental::mdspan, Layout_x, Accessor_x> x, std::experimental::mdspan, Layout_y, Accessor_y> y) { + static_assert(x.static_extent(0) == dynamic_extent || + y.static_extent(0) == dynamic_extent || + x.static_extent(0) == y.static_extent(0)); + static_assert(x.static_extent(1) == dynamic_extent || + y.static_extent(1) == dynamic_extent || + x.static_extent(1) == y.static_extent(1)); + using std::swap; using size_type = typename extents<>::size_type; @@ -111,10 +122,10 @@ void swap_elements( std::experimental::mdspan, Layout_x, Accessor_x> x, std::experimental::mdspan, Layout_y, Accessor_y> y) { - if constexpr (x.rank() == 1) { + if constexpr (x.rank() == 1 && y.rank() == 1) { swap_rank_1(x, y); } - else if constexpr (x.rank() == 2) { + else if constexpr (x.rank() == 2 && y.rank() == 2) { swap_rank_2(x, y); } else { diff --git a/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp b/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp index 1231cefe..2aa23053 100644 --- a/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp +++ b/include/experimental/__p1673_bits/blas2_matrix_vector_product.hpp @@ -66,6 +66,7 @@ template::size_type ext_y, class Layout_y, class Accessor_y> + requires (Layout_A::is_always_unique()) void matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, std::experimental::mdspan, Layout_x, Accessor_x> x, @@ -123,6 +124,7 @@ template::size_type ext_z, class Layout_z, class Accessor_z> + requires (Layout_A::is_always_unique()) void matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, std::experimental::mdspan, Layout_x, Accessor_x> x, @@ -183,6 +185,7 @@ template::size_type ext_y, class Layout_y, class Accessor_y> + requires (Layout_A::is_always_unique()) void symmetric_matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, Triangle t, @@ -260,6 +263,7 @@ template::size_type ext_z, class Layout_z, class Accessor_z> + requires (Layout_A::is_always_unique()) void symmetric_matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, Triangle t, @@ -339,6 +343,7 @@ template::size_type ext_y, class Layout_y, class Accessor_y> + requires (Layout_A::is_always_unique()) void hermitian_matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, Triangle t, @@ -387,6 +392,7 @@ template::size_type ext_y, class Layout_y, class Accessor_y> + requires (Layout_A::is_always_unique()) void hermitian_matrix_vector_product( ExecutionPolicy&& /* exec */, std::experimental::mdspan, Layout_A, Accessor_A> A, @@ -417,6 +423,7 @@ template::size_type ext_z, class Layout_z, class Accessor_z> + requires (Layout_A::is_always_unique()) void hermitian_matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, Triangle t, @@ -498,6 +505,7 @@ template::size_type ext_y, class Layout_y, class Accessor_y> + requires (Layout_A::is_always_unique()) void triangular_matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, Triangle t, @@ -585,6 +593,7 @@ template::size_type ext_z, class Layout_z, class Accessor_z> + requires (Layout_A::is_always_unique()) void triangular_matrix_vector_product( std::experimental::mdspan, Layout_A, Accessor_A> A, Triangle t,