Skip to content

Commit f8d7fba

Browse files
author
Alexandre Hoffmann
committed
-
1 parent da94403 commit f8d7fba

File tree

15 files changed

+348
-290
lines changed

15 files changed

+348
-290
lines changed

include/xtensor/containers/xfixed.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ namespace xt
325325
explicit xfixed_container(const inner_shape_type& shape, layout_type l = L);
326326
explicit xfixed_container(const inner_shape_type& shape, value_type v, layout_type l = L);
327327

328-
template <class IX = std::integral_constant<std::size_t, N>> requires (IX::value != 0)
329-
xfixed_container(nested_initializer_list_t<value_type, N> t);
328+
template <class IX = std::integral_constant<std::size_t, N>>
329+
requires(IX::value != 0) xfixed_container(nested_initializer_list_t<value_type, N> t);
330330

331331
~xfixed_container() = default;
332332

@@ -638,8 +638,10 @@ namespace xt
638638
* Note: for clang < 3.8 this is an initializer_list and the size is not checked at compile-or runtime.
639639
*/
640640
template <class ET, class S, layout_type L, bool SH, class Tag>
641-
template <class IX> requires (IX::value != 0)
642-
inline xfixed_container<ET, S, L, SH, Tag>::xfixed_container(nested_initializer_list_t<value_type, N> t)
641+
template <class IX>
642+
requires(IX::value != 0) inline xfixed_container<ET, S, L, SH, Tag>::xfixed_container(
643+
nested_initializer_list_t<value_type, N> t
644+
)
643645
{
644646
XTENSOR_ASSERT_MSG(
645647
detail::check_initializer_list_shape<N>::run(t, this->shape()) == true,

include/xtensor/containers/xscalar.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ namespace xt
316316

317317
template <class E>
318318
using is_xscalar = detail::is_xscalar_impl<E>;
319-
320-
template<class E>
319+
320+
template <class E>
321321
concept is_xscalar_concept = is_xscalar<std::decay_t<E>>::value;
322-
322+
323323
namespace detail
324324
{
325325
template <class... E>

include/xtensor/containers/xstorage.hpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -670,16 +670,16 @@ namespace xt
670670
template <input_iterator_concept IT>
671671
svector(IT begin, IT end, const allocator_type& alloc = allocator_type());
672672

673-
template <std::size_t N2, bool I2> requires (N != N2)
674-
explicit svector(const svector<T, N2, A, I2>& rhs);
673+
template <std::size_t N2, bool I2>
674+
requires(N != N2) explicit svector(const svector<T, N2, A, I2>& rhs);
675675

676676
svector& operator=(const svector& rhs);
677677
svector& operator=(svector&& rhs) noexcept(std::is_nothrow_move_assignable<value_type>::value);
678678
svector& operator=(const std::vector<T>& rhs);
679679
svector& operator=(std::initializer_list<T> il);
680680

681-
template <std::size_t N2, bool I2> requires (N != N2)
682-
svector& operator=(const svector<T, N2, A, I2>& rhs);
681+
template <std::size_t N2, bool I2>
682+
requires(N != N2) svector& operator=(const svector<T, N2, A, I2>& rhs);
683683

684684
svector(const svector& other);
685685
svector(svector&& other) noexcept(std::is_nothrow_move_constructible<value_type>::value);
@@ -809,8 +809,8 @@ namespace xt
809809
}
810810

811811
template <class T, std::size_t N, class A, bool Init>
812-
template <std::size_t N2, bool I2> requires (N != N2)
813-
inline svector<T, N, A, Init>::svector(const svector<T, N2, A, I2>& rhs)
812+
template <std::size_t N2, bool I2>
813+
requires(N != N2) inline svector<T, N, A, Init>::svector(const svector<T, N2, A, I2>& rhs)
814814
: m_allocator(rhs.get_allocator())
815815
{
816816
assign(rhs.begin(), rhs.end());
@@ -868,8 +868,10 @@ namespace xt
868868
}
869869

870870
template <class T, std::size_t N, class A, bool Init>
871-
template <std::size_t N2, bool I2> requires (N != N2)
872-
inline svector<T, N, A, Init>& svector<T, N, A, Init>::operator=(const svector<T, N2, A, I2>& rhs)
871+
template <std::size_t N2, bool I2>
872+
requires(N != N2) inline svector<T, N, A, Init>& svector<T, N, A, Init>::operator=(
873+
const svector<T, N2, A, I2>& rhs
874+
)
873875
{
874876
m_allocator = std::allocator_traits<allocator_type>::select_on_container_copy_construction(
875877
rhs.get_allocator()

include/xtensor/core/xexpression.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace xt
178178

179179
template <class E>
180180
using is_xexpression = is_crtp_base_of<xexpression, E>;
181-
181+
182182
template <class E>
183183
concept xexpression_concept = is_xexpression<E>::value;
184184

include/xtensor/core/xshape.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ namespace xt
508508
};
509509
}
510510

511-
template<typename T> concept fixed_shape_container_concept = detail::is_fixed<typename std::decay_t<T>::shape_type>::value;
511+
template <typename T>
512+
concept fixed_shape_container_concept = detail::is_fixed<typename std::decay_t<T>::shape_type>::value;
512513

513514
template <class... S>
514515
struct promote_shape

include/xtensor/generators/xgenerator.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ namespace xt
5959

6060
template <class F, class R, class S>
6161
class xgenerator;
62-
63-
template<typename T> concept xgenerator_concept = is_specialization_of<xgenerator, std::decay_t<T>>::value;
62+
63+
template <typename T>
64+
concept xgenerator_concept = is_specialization_of<xgenerator, std::decay_t<T>>::value;
6465

6566
template <class C, class R, class S>
6667
struct xiterable_inner_types<xgenerator<C, R, S>>
@@ -82,8 +83,8 @@ namespace xt
8283
* overlapping_memory_checker_traits *
8384
*************************************/
8485

85-
template <xgenerator_concept E> requires without_memory_address_concept<E>
86-
struct overlapping_memory_checker_traits<E>
86+
template <xgenerator_concept E>
87+
requires without_memory_address_concept<E> struct overlapping_memory_checker_traits<E>
8788
{
8889
static bool check_overlap(const E&, const memory_range&)
8990
{
@@ -165,8 +166,8 @@ namespace xt
165166
template <class O>
166167
const_stepper stepper_end(const O& shape, layout_type) const noexcept;
167168

168-
template <class E, class FE = F> requires has_assign_to_v<E, FE>
169-
void assign_to(xexpression<E>& e) const noexcept;
169+
template <class E, class FE = F>
170+
requires has_assign_to_v<E, FE> void assign_to(xexpression<E>& e) const noexcept;
170171

171172
const functor_type& functor() const noexcept;
172173

@@ -371,8 +372,8 @@ namespace xt
371372
}
372373

373374
template <class F, class R, class S>
374-
template <class E, class FE> requires has_assign_to_v<E, FE>
375-
inline void xgenerator<F, R, S>::assign_to(xexpression<E>& e) const noexcept
375+
template <class E, class FE>
376+
inline requires has_assign_to_v<E, FE> void xgenerator<F, R, S>::assign_to(xexpression<E>& e) const noexcept
376377
{
377378
e.derived_cast().resize(m_shape);
378379
m_f.assign_to(e);

include/xtensor/generators/xrandom.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
#include "../core/xtensor_config.hpp"
2828
#include "../generators/xbuilder.hpp"
2929
#include "../generators/xgenerator.hpp"
30+
#include "../misc/xtl_concepts.hpp"
3031
#include "../views/xindex_view.hpp"
3132
#include "../views/xview.hpp"
32-
#include "../misc/xtl_concepts.hpp"
3333

3434
namespace xt
3535
{
@@ -177,10 +177,10 @@ namespace xt
177177
void shuffle(xexpression<T>& e, E& engine = random::get_default_random_engine());
178178

179179
template <xtl::integral_concept T, class E = random::default_engine_type>
180-
xtensor<T, 1> permutation(T e, E& engine = random::get_default_random_engine());
180+
xtensor<T, 1> permutation(T e, E& engine = random::get_default_random_engine());
181181

182182
template <xexpression_concept T, class E = random::default_engine_type>
183-
std::decay_t<T> permutation(T&& e, E& engine = random::get_default_random_engine());
183+
std::decay_t<T> permutation(T&& e, E& engine = random::get_default_random_engine());
184184

185185
template <class T, class E = random::default_engine_type>
186186
xtensor<typename T::value_type, 1> choice(
@@ -835,7 +835,7 @@ namespace xt
835835
* @return randomly permuted copy of container or arange.
836836
*/
837837
template <xtl::integral_concept T, class E>
838-
xtensor<T, 1> permutation(T e, E& engine)
838+
xtensor<T, 1> permutation(T e, E& engine)
839839
{
840840
xt::xtensor<T, 1> res = xt::arange<T>(e);
841841
shuffle(res, engine);
@@ -844,7 +844,7 @@ namespace xt
844844

845845
/// @cond DOXYGEN_INCLUDE_SFINAE
846846
template <xexpression_concept T, class E>
847-
std::decay_t<T> permutation(T&& e, E& engine)
847+
std::decay_t<T> permutation(T&& e, E& engine)
848848
{
849849
using copy_type = std::decay_t<T>;
850850
copy_type res = e;

include/xtensor/misc/xfft.hpp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
#include <xtl/xcomplex.hpp>
77

8-
#include "./xtl_concepts.hpp"
98
#include "../containers/xarray.hpp"
109
#include "../core/xmath.hpp"
1110
#include "../core/xnoalias.hpp"
1211
#include "../generators/xbuilder.hpp"
1312
#include "../misc/xcomplex.hpp"
1413
#include "../views/xaxis_slice_iterator.hpp"
1514
#include "../views/xview.hpp"
15+
#include "./xtl_concepts.hpp"
1616

1717
namespace xt
1818
{
@@ -118,65 +118,65 @@ namespace xt
118118
}
119119
} // namespace detail
120120

121-
/**
121+
/**
122122
* @brief 1D FFT of an Nd array along a specified axis
123123
* @param e an Nd expression to be transformed to the fourier domain
124124
* @param axis the axis along which to perform the 1D FFT
125125
* @return a transformed xarray of the specified precision
126126
*/
127-
template<class E>
127+
template <class E>
128128
inline auto fft(E&& e, std::ptrdiff_t axis = -1)
129129
{
130-
using value_type = typename std::decay<E>::type::value_type;
131-
if constexpr (xtl::is_complex<typename std::decay<E>::type::value_type>::value)
132-
{
133-
using precision = typename value_type::value_type;
134-
const auto saxis = xt::normalize_axis(e.dimension(), axis);
135-
const size_t N = e.shape(saxis);
136-
const bool powerOfTwo = !(N == 0) && !(N & (N - 1));
137-
xt::xarray<std::complex<precision>> out = xt::eval(e);
138-
auto begin = xt::axis_slice_begin(out, saxis);
139-
auto end = xt::axis_slice_end(out, saxis);
140-
for (auto iter = begin; iter != end; iter++)
130+
using value_type = typename std::decay<E>::type::value_type;
131+
if constexpr (xtl::is_complex<typename std::decay<E>::type::value_type>::value)
141132
{
142-
if (powerOfTwo)
143-
{
144-
xt::noalias(*iter) = detail::radix2(*iter);
145-
}
146-
else
133+
using precision = typename value_type::value_type;
134+
const auto saxis = xt::normalize_axis(e.dimension(), axis);
135+
const size_t N = e.shape(saxis);
136+
const bool powerOfTwo = !(N == 0) && !(N & (N - 1));
137+
xt::xarray<std::complex<precision>> out = xt::eval(e);
138+
auto begin = xt::axis_slice_begin(out, saxis);
139+
auto end = xt::axis_slice_end(out, saxis);
140+
for (auto iter = begin; iter != end; iter++)
147141
{
148-
xt::noalias(*iter) = detail::transform_bluestein(*iter);
142+
if (powerOfTwo)
143+
{
144+
xt::noalias(*iter) = detail::radix2(*iter);
145+
}
146+
else
147+
{
148+
xt::noalias(*iter) = detail::transform_bluestein(*iter);
149+
}
149150
}
151+
return out;
150152
}
151-
return out;
152-
}
153-
else
154-
{
155-
return fft(xt::cast<std::complex<value_type>>(e), axis);
156-
}
157-
}
153+
else
154+
{
155+
return fft(xt::cast<std::complex<value_type>>(e), axis);
156+
}
157+
}
158158

159159
template <class E>
160160
inline auto ifft(E&& e, std::ptrdiff_t axis = -1)
161161
{
162-
if constexpr (xtl::is_complex<typename std::decay<E>::type::value_type>::value)
163-
{
164-
// check the length of the data on that axis
165-
const std::size_t n = e.shape(axis);
166-
if (n == 0)
162+
if constexpr (xtl::is_complex<typename std::decay<E>::type::value_type>::value)
163+
{
164+
// check the length of the data on that axis
165+
const std::size_t n = e.shape(axis);
166+
if (n == 0)
167+
{
168+
XTENSOR_THROW(std::runtime_error, "Cannot take the iFFT along an empty dimention");
169+
}
170+
auto complex_args = xt::conj(e);
171+
auto fft_res = xt::fft::fft(complex_args, axis);
172+
fft_res = xt::conj(fft_res);
173+
return fft_res;
174+
}
175+
else
167176
{
168-
XTENSOR_THROW(std::runtime_error, "Cannot take the iFFT along an empty dimention");
177+
using value_type = typename std::decay<E>::type::value_type;
178+
return ifft(xt::cast<std::complex<value_type>>(e), axis);
169179
}
170-
auto complex_args = xt::conj(e);
171-
auto fft_res = xt::fft::fft(complex_args, axis);
172-
fft_res = xt::conj(fft_res);
173-
return fft_res;
174-
}
175-
else
176-
{
177-
using value_type = typename std::decay<E>::type::value_type;
178-
return ifft(xt::cast<std::complex<value_type>>(e), axis);
179-
}
180180
}
181181

182182
/*

include/xtensor/misc/xmanipulation.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,18 @@ namespace xt
214214
template <class E, class S, class X>
215215
inline void compute_transposed_strides(E&& e, const S& shape, X& strides)
216216
{
217-
if constexpr (has_data_interface<std::decay_t<E>>::value)
218-
{
219-
std::copy(e.strides().crbegin(), e.strides().crend(), strides.begin());
220-
}
221-
else
222-
{
223-
// In the case where E does not have a data interface, the transposition
224-
// makes use of a flat storage adaptor that has layout XTENSOR_DEFAULT_TRAVERSAL
225-
// which should be the one inverted.
226-
layout_type l = transpose_layout(XTENSOR_DEFAULT_TRAVERSAL);
227-
compute_strides(shape, l, strides);
228-
}
217+
if constexpr (has_data_interface<std::decay_t<E>>::value)
218+
{
219+
std::copy(e.strides().crbegin(), e.strides().crend(), strides.begin());
220+
}
221+
else
222+
{
223+
// In the case where E does not have a data interface, the transposition
224+
// makes use of a flat storage adaptor that has layout XTENSOR_DEFAULT_TRAVERSAL
225+
// which should be the one inverted.
226+
layout_type l = transpose_layout(XTENSOR_DEFAULT_TRAVERSAL);
227+
compute_strides(shape, l, strides);
228+
}
229229
}
230230
}
231231

include/xtensor/misc/xset_operation.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ namespace xt
8787
* @param test_elements an array
8888
* @return a boolean array
8989
*/
90-
template <class E, class F> requires has_iterator_interface_concept<F>
91-
inline auto isin(E&& element, F&& test_elements) noexcept
90+
template <class E, class F>
91+
inline requires has_iterator_interface_concept<F> auto isin(E&& element, F&& test_elements) noexcept
9292
{
9393
auto lambda = detail::lambda_isin<std::is_lvalue_reference<F>::value>::make(std::forward<F>(test_elements
9494
));
@@ -143,8 +143,8 @@ namespace xt
143143
* @param test_elements an array
144144
* @return a boolean array
145145
*/
146-
template <class E, class F> requires has_iterator_interface_concept<F>
147-
inline auto in1d(E&& element, F&& test_elements) noexcept
146+
template <class E, class F>
147+
inline requires has_iterator_interface_concept<F> auto in1d(E&& element, F&& test_elements) noexcept
148148
{
149149
XTENSOR_ASSERT(element.dimension() == 1ul);
150150
XTENSOR_ASSERT(test_elements.dimension() == 1ul);

0 commit comments

Comments
 (0)