Skip to content

Commit 562a5df

Browse files
committed
sedenion test
1 parent f160baa commit 562a5df

3 files changed

Lines changed: 65 additions & 59 deletions

File tree

include/boost/multi/detail/layout.hpp

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -198,61 +198,25 @@ struct extents_t : boost::multi::detail::tuple_prepend_t<index_extension, typena
198198
BOOST_MULTI_HD constexpr extents_t(index_extension ext1, index_extension ext2, index_extension ext3, index_extension ext4, index_extension ext5, index_extension ext6)
199199
: base_{ext1, ext2, ext3, ext4, ext5, ext6} {}
200200

201-
template<class T1, class T = void, class = decltype(base_{tuple<T1>{}}), std::enable_if_t<sizeof(T*) && D == 1, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
202-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
203-
BOOST_MULTI_HD constexpr extents_t(detail::tuple<T1> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor)
204-
: base_{std::move(extensions)} {}
205-
206-
template<class T1, class T = void, class = decltype(base_{::std::tuple<T1>{}}), std::enable_if_t<sizeof(T*) && D == 1, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
207-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
208-
BOOST_MULTI_HD constexpr extents_t(::std::tuple<T1> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
201+
template<class... Ts, std::enable_if_t<sizeof...(Ts) == static_cast<std::size_t>(D), int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
202+
// cppcheck-suppress noExplicitConstructor ; allow terse syntax // NOLINTNEXTLINE(runtime/explicit)
203+
BOOST_MULTI_HD constexpr extents_t(detail::tuple<Ts...> const& extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor)
204+
: extents_t(extensions, std::make_index_sequence<static_cast<std::size_t>(D)>()) {}
205+
206+
template<class... Ts, std::enable_if_t<sizeof...(Ts) == static_cast<std::size_t>(D), int> = 0, class = decltype(base_{std::declval<::std::tuple<Ts...> >()})> // NOLINT(modernize-use-constraints) TODO(correaa)
207+
// cppcheck-suppress noExplicitConstructor ; allow terse syntax // NOLINTNEXTLINE(runtime/explicit)
208+
BOOST_MULTI_HD constexpr extents_t(::std::tuple<Ts...> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor)
209209
: base_{std::move(extensions)} {}
210210

211-
template<class T1, class T2, class T = void, class = decltype(base_{tuple<T1, T2>{}}), std::enable_if_t<sizeof(T*) && D == 2, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
212-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
213-
BOOST_MULTI_HD constexpr extents_t(detail::tuple<T1, T2> const& extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
214-
: base_{extensions} {}
215-
216-
template<class T1, class T2, class T = void, class = decltype(base_{::std::tuple<T1, T2>{}}), std::enable_if_t<sizeof(T*) && D == 2, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
217-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
218-
BOOST_MULTI_HD constexpr extents_t(::std::tuple<T1, T2> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
219-
: base_{std::move(extensions)} {}
220-
221-
template<class T1, class T2, class T3, class T = void, class = decltype(base_{tuple<T1, T2, T3>{}}), std::enable_if_t<sizeof(T*) && D == 3, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
222-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int, int> // NOLINTNEXTLINE(runtime/explicit)
223-
BOOST_MULTI_HD constexpr extents_t(tuple<T1, T2, T3> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
224-
: base_{std::move(extensions)} {}
225-
226-
template<class T1, class T2, class T3, class T = void, class = decltype(base_{::std::tuple<T1, T2, T3>{}}), std::enable_if_t<sizeof(T*) && D == 3, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
227-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int, int> // NOLINTNEXTLINE(runtime/explicit)
228-
BOOST_MULTI_HD constexpr extents_t(::std::tuple<T1, T2, T3> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
229-
: base_{std::move(extensions)} {}
230-
231-
template<class T1, class T2, class T3, class T4, class T = void, class = decltype(base_{tuple<T1, T2, T3, T4>{}}), std::enable_if_t<sizeof(T*) && D == 4, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
232-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
233-
BOOST_MULTI_HD constexpr extents_t(tuple<T1, T2, T3, T4> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
234-
: base_{std::move(extensions)} {}
235-
236-
template<class T1, class T2, class T3, class T4, class T = void, class = decltype(base_{::std::tuple<T1, T2, T3, T4>{}}), std::enable_if_t<sizeof(T*) && D == 4, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
237-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
238-
BOOST_MULTI_HD constexpr extents_t(::std::tuple<T1, T2, T3, T4> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
239-
: base_{std::move(extensions)} {}
240-
241-
template<class T1, class T2, class T3, class T4, class T5, class T = void, class = decltype(base_{tuple<T1, T2, T3, T4, T5>{}}), std::enable_if_t<sizeof(T*) && D == 5, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
242-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
243-
BOOST_MULTI_HD constexpr extents_t(tuple<T1, T2, T3, T4, T5> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
244-
: base_{std::move(extensions)} {}
245-
246-
template<class T1, class T2, class T3, class T4, class T5, class T = void, class = decltype(base_{::std::tuple<T1, T2, T3, T4, T5>{}}), std::enable_if_t<sizeof(T*) && D == 5, int> = 0> // NOLINT(modernize-use-constraints) TODO(correaa)
247-
// cppcheck-suppress noExplicitConstructor ; to allow passing tuple<int, int> // NOLINTNEXTLINE(runtime/explicit)
248-
BOOST_MULTI_HD constexpr extents_t(::std::tuple<T1, T2, T3, T4, T5> extensions) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor)
249-
: base_{std::move(extensions)} {}
250-
251-
template<class... Ts>
252-
BOOST_MULTI_HD constexpr explicit extents_t(tuple<Ts...> const& tup)
253-
: extents_t(tup, std::make_index_sequence<static_cast<std::size_t>(D)>()) {}
254-
255-
// template<std::size_t I, class TU> static constexpr auto get_(TU const& tu) { using std::get; return get<I>(tu); }
211+
template<
212+
class... Exts,
213+
std::enable_if_t<
214+
(sizeof...(Exts) >= 2) && (sizeof...(Exts) == static_cast<std::size_t>(D))
215+
&& (std::is_convertible_v<Exts, index_extension> && ...),
216+
int> = 0
217+
> // NOLINT(modernize-use-constraints) TODO(correaa)
218+
BOOST_MULTI_HD constexpr extents_t(Exts... exts) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions,cppcoreguidelines-explicit-constructor,misc-explicit-constructor) allow terse syntax
219+
: base_{index_extension(exts)...} {}
256220

257221
template<class OtherExtensions,
258222
decltype( multi::detail::implicit_cast<index_extension>(OtherExtensions{}.extension()) )* = nullptr,
@@ -918,11 +882,6 @@ template<> struct extents_t<1> : tuple<multi::index_extension> {
918882
return elements_t{get<0>(static_cast<tuple<multi::index_extension> const&>(*this))};
919883
}
920884

921-
// template<class Fun>
922-
// friend BOOST_MULTI_HD constexpr auto operator^(Fun&& fun, extents_t const& xs) {
923-
// return restriction<1, std::decay_t<Fun> >(xs, std::forward<Fun>(fun));
924-
// }
925-
926885
using nelems_type = index;
927886

928887
// cppcheck-suppress noExplicitConstructor ; to allow terse syntax (compatible with std::vector(int) constructor

pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ if [[ $OSTYPE != "darwin"* ]]; then
5050
export PMIX_MCA_gds=hash
5151
export UBSAN_OPTIONS=print_stacktrace=1
5252

53+
([ -d .build.clang++.libcpp ] || CXX=clang++ cmake -S . -B .build.clang++.libcpp -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_STANDARD=23 -DDISABLE_MPI=1 -DCMAKE_CXX_FLAGS="-stdlib=libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -fsanitize=address,undefined" -DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -fsanitize=address,undefined" && cmake --build .build.clang++.libcpp $CMT && (ctest --test-dir .build.clang++.libcpp $CTR || ctest --test-dir .build.clang++.libcpp --rerun-failed $CTR) ) || exit 666
5354
([ -d .build.g++ ] || CXX=g++ cmake -S . -B .build.g++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_FLAGS="-Wno-error=deprecated-declarations" && cmake --build .build.g++ $CMT && (ctest --test-dir .build.g++ --rerun-failed $CTR || ctest --test-dir .build.g++ --rerun-failed $CTR) ) || exit 666
5455
#([ -d .build.clang++ ] || CXX=clang++ CXXFLAGS=-Weverything cmake -S . -B .build.clang++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR="ON" && cmake --build .build.clang++ $CMT && (ctest --test-dir .build.clang++ $CTR || ctest --test-dir .build.clang++ --rerun-failed $CTR) ) || exit 666
55-
([ -d .build.clang++.libcpp ] || CXX=clang++ cmake -S . -B .build.clang++.libcpp -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_STANDARD=23 -DDISABLE_MPI=1 -DCMAKE_CXX_FLAGS="-stdlib=libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -fsanitize=address,undefined" -DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -fsanitize=address,undefined" && cmake --build .build.clang++.libcpp $CMT && (ctest --test-dir .build.clang++.libcpp $CTR || ctest --test-dir .build.clang++.libcpp --rerun-failed $CTR) ) || exit 666
5656

5757
([ -d .build.g++.c++23 ] || CXX=g++ cmake -S . -B .build.g++.c++23 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_FLAGS="-fconcepts-diagnostics-depth=30" && cmake --build .build.g++.c++23 $CMT && (ctest --test-dir .build.g++.c++23 $CTR || ctest --test-dir .build.g++.c++23 --rerun-failed $CTR) ) || exit 666
5858

test/sedenion.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2026 Alfredo A. Correa
2+
// Copyright 2024 Matt Borland
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// https://www.boost.org/LICENSE_1_0.txt
5+
6+
#include <boost/multi/array.hpp> // for implicit_cast, explicit_cast
7+
8+
#include <boost/core/lightweight_test.hpp>
9+
10+
#include <numeric>
11+
12+
namespace multi = boost::multi;
13+
14+
auto main() -> int { // NOLINT(readability-function-cognitive-complexity,bugprone-exception-escape)
15+
{
16+
multi::array<int, 2> arr(multi::extents_t<2>{2, 2}, 0);
17+
BOOST_TEST( arr.num_elements() == 2*2 );
18+
}
19+
{
20+
multi::array<int, 4> arr(multi::extents_t<4>{2, 2, 2, 2}, 0);
21+
BOOST_TEST( arr.num_elements() == 2*2*2*2 );
22+
}
23+
{
24+
multi::array<int, 8> arr(multi::extents_t<8>{2, 2, 2, 2, 2, 2, 2, 2}, 0);
25+
BOOST_TEST( arr.num_elements() == 256 );
26+
}
27+
{
28+
multi::array<int, 10> arr(multi::extents_t<10>{2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, 0);
29+
BOOST_TEST( arr.num_elements() == 256*2*2 );
30+
}
31+
#ifdef __clang__
32+
{
33+
multi::array<int, 12> arr( multi::extents_t<12>{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, 0);
34+
BOOST_TEST( arr.num_elements() == 256*2*2*2*2 );
35+
}
36+
{
37+
multi::array<int, 14> arr( multi::extents_t<14>{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, 0);
38+
BOOST_TEST( arr.num_elements() == 256*2*2*2*2*2*2 );
39+
}
40+
{
41+
multi::array<int, 16> arr( multi::extents_t<16>{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, 0);
42+
BOOST_TEST( arr.num_elements() == 65536 );
43+
}
44+
#endif
45+
46+
return boost::report_errors();
47+
}

0 commit comments

Comments
 (0)