Skip to content

Commit 31337cc

Browse files
committed
...
1 parent ed058ed commit 31337cc

12 files changed

Lines changed: 40 additions & 42 deletions

include/xtensor/misc/xfft.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ namespace xt
219219
auto outvec = ifft(xv, axis);
220220

221221
// Scaling (because this FFT implementation omits it)
222-
outvec = outvec / static_cast<double>(n);
222+
using outvec_type = typename decltype(outvec)::value_type::value_type;
223+
outvec_type scale = static_cast<outvec_type>(1.0) / static_cast<outvec_type>(n);
224+
outvec *= scale;
223225

224226
return outvec;
225227
}

include/xtensor/misc/xsort.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,6 @@ namespace xt
12371237
template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL, class E>
12381238
inline auto argmin(const xexpression<E>& e)
12391239
{
1240-
using value_type = typename E::value_type;
12411240
auto&& ed = eval(e.derived_cast());
12421241
auto begin = ed.template begin<L>();
12431242
auto end = ed.template end<L>();
@@ -1267,7 +1266,6 @@ namespace xt
12671266
template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL, class E>
12681267
inline auto argmax(const xexpression<E>& e)
12691268
{
1270-
using value_type = typename E::value_type;
12711269
auto&& ed = eval(e.derived_cast());
12721270
auto begin = ed.template begin<L>();
12731271
auto end = ed.template end<L>();

include/xtensor/optional/xoptional.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,14 @@ namespace xt
199199
template <class U, class... Args>
200200
constexpr result_type apply_impl(const U& t, const Args&... args) const
201201
{
202-
return t & apply_impl(args...);
202+
if constexpr (std::is_same_v<T, bool>)
203+
{
204+
return t && apply_impl(args...);
205+
}
206+
else
207+
{
208+
return t & apply_impl(args...);
209+
}
203210
}
204211

205212
template <class B>

include/xtensor/views/index_mapper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace xt
1717
{
1818

1919
template <class UndefinedView>
20-
struct index_mapper;
20+
class index_mapper;
2121

2222
/**
2323
* @enum access_t

test/CMakeLists.txt

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,55 +57,45 @@ if(NOT _cxx_std_flag)
5757
message(FATAL_ERROR "xtensor needs a C++20-compliant compiler.")
5858
endif()
5959

60-
OPTION(XTENSOR_ENABLE_WERROR "Turn on -Werror" OFF)
61-
6260
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXSIMD_ENABLE_XTL_COMPLEX=1")
6361
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND NOT WIN32))
64-
CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported)
62+
CHECK_CXX_COMPILER_FLAG(${_cxx_std_flag} -march=native arch_native_supported)
6563
if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
66-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
64+
add_compile_options(-march=native)
6765
endif()
68-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} -Wunused-parameter -Wextra -Wreorder -Wconversion -Wno-sign-conversion ")
69-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Wunused-variable -ftemplate-backtrace-limit=0")
66+
add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion)
7067
if (XTENSOR_DISABLE_EXCEPTIONS)
71-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
72-
endif()
73-
if (XTENSOR_ENABLE_WERROR)
74-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -DSKIP_ON_WERROR")
68+
add_compile_options(-fno-exceptions)
7569
endif()
7670
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
77-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /Zc:__cplusplus /MP /bigobj")
71+
add_compile_options(${_cxx_std_flag} /Zc:__cplusplus /EHsc /bigobj -fms-compatibility)
7872
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
7973
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
8074
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
8175
if (XTENSOR_DISABLE_EXCEPTIONS)
82-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
76+
add_compile_options(/EHs-c-)
8377
else()
84-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
78+
add_compile_options(/EHsc)
8579
endif()
8680
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
8781
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
8882
CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported)
8983
if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
90-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
84+
add_compile_options(-march=native)
9185
endif()
92-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion")
93-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Wunused-variable")
86+
add_compile_options(${_cxx_std_flag} -Werror -Wall -Wextra -Wconversion -Wsign-conversion)
9487
if (XTENSOR_DISABLE_EXCEPTIONS)
95-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
96-
endif()
97-
if (XTENSOR_ENABLE_WERROR)
98-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -DSKIP_ON_WERROR")
88+
add_compile_options(-fno-exceptions)
9989
endif()
10090
elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
10191
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /bigobj")
10292
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
10393
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
10494
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
10595
if (XTENSOR_DISABLE_EXCEPTIONS)
106-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
96+
add_compile_options(/EHs-c-)
10797
else()
108-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
98+
add_compile_options(/EHsc)
10999
endif()
110100
endif()
111101
else()

test/test_xcomplex.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ namespace xt
133133
};
134134
EXPECT_TRUE(allclose(cmplexpected_angle, cmplres_angle));
135135

136-
using assign_t_angle = xassign_traits<xarray<double>, decltype(cmplres_angle)>;
137136

138137
#if XTENSOR_USE_XSIMD
138+
using assign_t_angle = xassign_traits<xarray<double>, decltype(cmplres_angle)>;
139139
EXPECT_TRUE(assign_t_angle::simd_linear_assign());
140140
#endif
141141

@@ -147,9 +147,9 @@ namespace xt
147147
};
148148
EXPECT_TRUE(allclose(cmplexpected_conj, cmplres_conj));
149149

150-
using assign_t_conj = xassign_traits<xarray<std::complex<double>>, decltype(cmplres_conj)>;
151150

152151
#if XTENSOR_USE_XSIMD
152+
using assign_t_conj = xassign_traits<xarray<std::complex<double>>, decltype(cmplres_conj)>;
153153
auto b1 = cmplres_angle.template load_simd<xsimd::aligned_mode>(0);
154154
auto b2 = cmplres_conj.template load_simd<xsimd::aligned_mode>(0);
155155
static_cast<void>(b1);
@@ -164,9 +164,9 @@ namespace xt
164164
{0.57322529, 0.62248637, 0.14673763}
165165
};
166166

167-
using assign_t_norm = xassign_traits<xarray<double>, decltype(cmplres_norm)>;
168167

169168
#if XTENSOR_USE_XSIMD
169+
using assign_t_norm = xassign_traits<xarray<double>, decltype(cmplres_norm)>;
170170
EXPECT_TRUE(assign_t_norm::simd_linear_assign());
171171
#endif
172172

@@ -192,9 +192,8 @@ namespace xt
192192
++it;
193193
}
194194

195-
using assign_t_arg = xassign_traits<xarray<double>, decltype(cmplres)>;
196-
197195
#if XTENSOR_USE_XSIMD
196+
using assign_t_arg = xassign_traits<xarray<double>, decltype(cmplres)>;
198197
EXPECT_TRUE(assign_t_arg::simd_linear_assign());
199198
#endif
200199
}

test/test_xexpression.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ namespace xt
104104
auto sexpr1 = make_xshared(std::move(expr1));
105105
using expr_type = decltype(sexpr1);
106106
using strides_type = typename expr_type::strides_type;
107+
static_assert(std::is_same_v<strides_type, xt::svector<long, 4>>, "strides_type should be svector<long, 4>");
107108
using inner_strides_type = typename expr_type::inner_strides_type;
109+
static_assert(std::is_same_v<inner_strides_type, xt::svector<long, 4>>, "inner_strides_type should be svector<long, 4>");
108110
using backstrides_type = typename expr_type::backstrides_type;
111+
static_assert(std::is_same_v<backstrides_type, xt::svector<long, 4>>, "backstrides_type should be svector<long, 4>");
109112
using inner_strides_tybackstrides_typepe = typename expr_type::inner_backstrides_type;
113+
static_assert(std::is_same_v<inner_strides_tybackstrides_typepe, xt::svector<long, 4>>, "inner_backstrides_type should be svector<long, 4>");
110114
}
111115

112116
TEST(xexpression, shared_expr_return)

test/test_xexpression_holder.cpp

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

2525
xexpression_holder holder_a = xexpression_holder(a);
2626
xexpression_holder holder_b(b);
27-
xexpression_holder holder_c(std::move(xexpression_holder(c)));
27+
xexpression_holder holder_c({xexpression_holder(c)});
2828
}
2929

3030
TEST(xexpression_holder, assign)

test/test_xmath.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ namespace xt
4343
xarray<double> res2 = xt::abs(b);
4444

4545
auto f = abs(b);
46-
using assign_traits = xassign_traits<xarray<double>, decltype(f)>;
4746

4847
#if XTENSOR_USE_XSIMD
48+
using assign_traits = xassign_traits<xarray<double>, decltype(f)>;
4949
EXPECT_TRUE(assign_traits::simd_linear_assign());
5050
#endif
5151
}

test/test_xreducer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace xt
3636

3737
#define CHECK_RESULT_TYPE(EXPRESSION, EXPECTED_TYPE) \
3838
{ \
39-
using result_type = typename std::decay_t<decltype(EXPRESSION)>::value_type; \
40-
EXPECT_TRUE((std::is_same<result_type, EXPECTED_TYPE>::value)); \
39+
using result_t = typename std::decay_t<decltype(EXPRESSION)>::value_type; \
40+
EXPECT_TRUE((std::is_same<result_t, EXPECTED_TYPE>::value)); \
4141
}
4242

4343
#define CHECK_TAG_TYPE(EXPRESSION, EXPECTED_TYPE) \

0 commit comments

Comments
 (0)