Skip to content

Commit afe4d7d

Browse files
authored
Merge pull request #448 from serge-sans-paille/feature/support-building-complex-from-real-pointer
Support creating complex batch from real pointer
2 parents 5b8046e + 5f30972 commit afe4d7d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

include/xsimd/types/xsimd_complex_base.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ namespace xsimd
144144
explicit simd_complex_batch(const value_type& v);
145145
explicit simd_complex_batch(const real_value_type& v);
146146
explicit simd_complex_batch(const real_batch& re);
147+
explicit simd_complex_batch(const real_value_type* v) : simd_complex_batch(real_batch(v)) {}
147148
simd_complex_batch(const real_batch& re, const real_batch& im);
149+
simd_complex_batch(const real_value_type* re, const real_value_type* im) : simd_complex_batch(real_batch(re), real_batch(im)) {}
148150

149151
real_batch& real();
150152
real_batch& imag();

test/test_batch_complex.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,17 @@ class batch_complex_test : public testing::Test
113113
tmp[i] = value_type(real[i]);
114114
}
115115

116-
batch_type b2(real_batch_type(real.data()));
116+
batch_type b2(real.data());
117117
EXPECT_EQ(b2, tmp) << print_function_name("batch(real_batch)");
118118

119-
batch_type b3(real_batch_type(real.data()), real_batch_type(imag.data()));
119+
batch_type b3(real.data(), imag.data());
120120
EXPECT_EQ(b3, lhs) << print_function_name("batch(real_batch, real_batch)");
121+
122+
batch_type b4(real_batch_type(real.data()));
123+
EXPECT_EQ(b4, tmp) << print_function_name("batch(real_ptr)");
124+
125+
batch_type b5(real_batch_type(real.data()), real_batch_type(imag.data()));
126+
EXPECT_EQ(b5, lhs) << print_function_name("batch(real_ptr, real_ptr)");
121127
}
122128

123129
void test_access_operator() const

0 commit comments

Comments
 (0)