simd_complex_batch¶
-
template<class
X
>
classxsimd
::
simd_complex_batch
: public xsimd::simd_base<X>¶ Base class for batch complex numbers.
The simd_complex_batch class is the base class for all classes representing a batch of complex numbers. Each type of batch (i.e. a class inheriting from simd_complex_batch) has its dedicated type of boolean batch (i.e. a class inheriting from simd_complex_batch_bool) for logical operations.
Internally, a batch of complex numbers holds two batches of real numbers, one for the real part and one for the imaginary part.
- See
- Template Parameters
X
: The derived type
Arithmetic computed assignment
-
X &
operator+=
(const X &rhs)¶ Adds the batch
rhs
tothis
.- Return
a reference to
this
.- Parameters
rhs
: the batch to add.
-
X &
operator+=
(const value_type &rhs)¶ Adds the scalar
rhs
to each value contained inthis
.- Return
a reference to
this
.- Parameters
rhs
: the scalar to add.
-
X &
operator+=
(const real_batch &rhs)¶ Adds the real batch
rhs
tothis
.- Return
a reference to
this
.- Parameters
rhs
: the real batch to add.
-
X &
operator+=
(const real_value_type &rhs)¶ Adds the real scalar
rhs
to each value contained inthis
.- Return
a reference to
this
.- Parameters
rhs
: the real scalar to add.
-
X &
operator-=
(const X &rhs)¶ Substracts the batch
rhs
tothis
.- Return
a reference to
this
.- Parameters
rhs
: the batch to substract.
-
X &
operator-=
(const value_type &rhs)¶ Substracts the scalar
rhs
to each value contained inthis
.- Return
a reference to
this
.- Parameters
rhs
: the scalar to substract.
-
X &
operator-=
(const real_batch &rhs)¶ Substracts the real batch
rhs
tothis
.- Return
a reference to
this
.- Parameters
rhs
: the batch to substract.
-
X &
operator-=
(const real_value_type &rhs)¶ Substracts the real scalar
rhs
to each value contained inthis
.- Return
a reference to
this
.- Parameters
rhs
: the real scalar to substract.
-
X &
operator*=
(const X &rhs)¶ Multiplies
this
with the batchrhs
.- Return
a reference to
this
.- Parameters
rhs
: the batch involved in the multiplication.
-
X &
operator*=
(const value_type &rhs)¶ Multiplies each scalar contained in
this
with the scalarrhs
.- Return
a reference to
this
.- Parameters
rhs
: the scalar involved in the multiplication.
-
X &
operator*=
(const real_batch &rhs)¶ Multiplies
this
with the real batchrhs
.- Return
a reference to
this
.- Parameters
rhs
: the real batch involved in the multiplication.
-
X &
operator*=
(const real_value_type &rhs)¶ Multiplies each scalar contained in
this
with the real scalarrhs
.- Return
a reference to
this
.- Parameters
rhs
: the real scalar involved in the multiplication.
-
X &
operator/=
(const X &rhs)¶ Divides
this
by the batchrhs
.- Return
a reference to
this
.- Parameters
rhs
: the batch involved in the division.
-
X &
operator/=
(const value_type &rhs)¶ Divides each scalar contained in
this
by the scalarrhs
.- Return
a reference to
this
.- Parameters
rhs
: the scalar involved in the division.
Load and store methods
-
template<class
T
>
X &load_aligned
(const T *real_src, const T *imag_src)¶ Loads the N contiguous values pointed by
real_src
into the batch holding the real values, and N contiguous values pointed byimag_src
into the batch holding the imaginary values.real_src
andimag_src
must be aligned.
-
template<class
T
>
X &load_unaligned
(const T *real_src, const T *imag_src)¶ Loads the N contiguous values pointed by
real_src
into the batch holding the real values, and N contiguous values pointed byimag_src
into the batch holding the imaginary values.real_src
andimag_src
are not required to be aligned.
-
template<class
T
>
voidstore_aligned
(T *real_dst, T *imag_dst) const¶ Stores the N values of the batch holding the real values into a contiguous array pointed by
real_dst
., and the N values of the batch holding the imaginary values into a contiguous array pointer byimag_dst
.real_dst
andimag_dst
must be aligned.
-
template<class
T
>
voidstore_unaligned
(T *real_dst, T *imag_dst) const¶ Stores the N values of the batch holding the real values into a contiguous array pointed by
real_dst
., and the N values of the batch holding the imaginary values into a contiguous array pointer byimag_dst
.real_dst
andimag_dst
are not required to be aligned.
-
template<class
T
>
std::enable_if<detail::is_complex<T>::value, X&>::typeload_aligned
(const T *src)¶ Loads the N contiguous values pointed by
src
into the batch.src
must be aligned.
-
template<class
T
>
std::enable_if<detail::is_complex<T>::value, X&>::typeload_unaligned
(const T *src)¶ Loads the N contiguous values pointed by
src
into the batch.src
is not required to be aligned.
-
template<class
T
>
std::enable_if<detail::is_complex<T>::value, void>::typestore_aligned
(T *dst) const¶ Stores the N values of the batch into a contiguous array of complex pointed by
dst
.Stores the N values of the batch into a contiguous array of reals pointed by
dst
.dst
must be aligned.
-
template<class
T
>
std::enable_if<detail::is_complex<T>::value, void>::typestore_unaligned
(T *dst) const¶ Stores the N values of the batch into a contiguous array of complex pointed by
dst
.Stores the N values of the batch into a contiguous array of reals pointed by
dst
.dst
is not required to be aligned.
Public Functions
-
simd_complex_batch
(const value_type &v)¶ Initializes all the values of the batch to the complex value
v
.
-
simd_complex_batch
(const real_value_type &v)¶ Initializes all the values of the batch to the real value
v
.
-
simd_complex_batch
(const real_batch &re)¶ Initializes the values of the batch whith those of the real batch
re
.Imaginary parts are set to 0.
-
simd_complex_batch
(const real_batch &re, const real_batch &im)¶ Initializes the batch with two real batch, one for the real part and one for the inamginary part.
-
real_batch &
real
()¶ Returns a batch for the real part.
-
real_batch &
imag
()¶ Returns a batch for the imaginary part.
-
const real_batch &
real
() const¶ Returns a const batch for the real part.
-
const real_batch &
imag
() const¶ Returns a const batch for the imaginary part.
Arithmetic operators¶
-
template<class
X
>
Xoperator+
(const simd_complex_batch<X> &rhs)¶ No-op on
rhs
.- Return
the opposite of
rhs
.- Template Parameters
X
: the actual type of batch.
- Parameters
rhs
: batch involved in the operation.
-
template<class
X
>
Xoperator-
(const simd_complex_batch<X> &rhs)¶ Computes the opposite of the batch
rhs
.- Return
the opposite of
rhs
.- Template Parameters
X
: the actual type of batch.
- Parameters
rhs
: batch involved in the operation.
-
template<class
X
>
Xoperator+
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs)¶ Computes the sum of the batches
lhs
andrhs
.- Return
the result of the addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the addition.rhs
: batch involved in the addition.
-
template<class
X
>
Xoperator+
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the sum of the batch
lhs
and the scalarrhs
.Equivalent to the sum of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the addition.rhs
: scalar involved in the addition.
-
template<class
X
>
Xoperator+
(const typename simd_batch_traits<X>::value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the sum of the scalar
lhs
and the batchrhs
.Equivalent to the sum of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: scalar involved in the addition.rhs
: batch involved in the addition.
-
template<class
X
>
Xoperator+
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_batch &rhs)¶ Computes the sum of the batches
lhs
andrhs
.- Return
the result of the addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the addition.rhs
: real batch involved in the addition.
-
template<class
X
>
Xoperator+
(const typename simd_batch_traits<X>::real_batch &lhs, const simd_complex_batch<X> &rhs)¶ Computes the sum of the batches
lhs
andrhs
.- Return
the result of the addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real batch involved in the addition.rhs
: batch involved in the addition.
-
template<class
X
>
Xoperator+
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_value_type &rhs)¶ Computes the sum of the batch
lhs
and the real scalarrhs
.Equivalent to the sum of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the addition.rhs
: real scalar involved in the addition.
-
template<class
X
>
Xoperator+
(const typename simd_batch_traits<X>::real_value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the sum of the real scalar
lhs
and the batchrhs
.Equivalent to the sum of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the addition.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real scalar involved in the addition.rhs
: batch involved in the addition.
-
template<class
X
>
Xoperator-
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs)¶ Computes the difference of the batches
lhs
andrhs
.- Return
the result of the difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the difference.rhs
: batch involved in the difference.
-
template<class
X
>
Xoperator-
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the difference of the batch
lhs
and the scalarrhs
.Equivalent to the difference of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the difference.rhs
: scalar involved in the difference.
-
template<class
X
>
Xoperator-
(const typename simd_batch_traits<X>::value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the difference of the scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: scalar involved in the difference.rhs
: batch involved in the difference.
-
template<class
X
>
Xoperator-
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_batch &rhs)¶ Computes the difference of the batches
lhs
andrhs
.- Return
the result of the difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the difference.rhs
: real batch involved in the difference.
-
template<class
X
>
Xoperator-
(const typename simd_batch_traits<X>::real_batch &lhs, const simd_complex_batch<X> &rhs)¶ Computes the difference of the batches
lhs
andrhs
.- Return
the result of the difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real batch involved in the difference.rhs
: batch involved in the difference.
-
template<class
X
>
Xoperator-
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_value_type &rhs)¶ Computes the difference of the batch
lhs
and the real scalarrhs
.Equivalent to the difference of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the difference.rhs
: real scalar involved in the difference.
-
template<class
X
>
Xoperator-
(const typename simd_batch_traits<X>::real_value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the difference of the real scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the difference.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real scalar involved in the difference.rhs
: batch involved in the difference.
-
template<class
X
>
Xoperator*
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs)¶ Computes the product of the batches
lhs
andrhs
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the product.rhs
: batch involved in the product.
-
template<class
X
>
Xoperator*
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the product of the batch
lhs
and the scalarrhs
.Equivalent to the product of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the product.rhs
: scalar involved in the product.
-
template<class
X
>
Xoperator*
(const typename simd_batch_traits<X>::value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the product of the scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: scalar involved in the product.rhs
: batch involved in the product.
-
template<class
X
>
Xoperator*
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_batch &rhs)¶ Computes the product of the batches
lhs
andrhs
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the product.rhs
: real batch involved in the product.
-
template<class
X
>
Xoperator*
(const typename simd_batch_traits<X>::real_batch &lhs, const simd_complex_batch<X> &rhs)¶ Computes the product of the batches
lhs
andrhs
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real batch involved in the product.rhs
: batch involved in the product.
-
template<class
X
>
Xoperator*
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_value_type &rhs)¶ Computes the product of the batch
lhs
and the real scalarrhs
.Equivalent to the product of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the product.rhs
: real scalar involved in the product.
-
template<class
X
>
Xoperator*
(const typename simd_batch_traits<X>::real_value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the product of the real scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the product.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real scalar involved in the product.rhs
: batch involved in the product.
-
template<class
X
>
Xoperator/
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs)¶ Computes the division of the batch
lhs
by the batchrhs
.- Return
the result of the division.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the division.rhs
: batch involved in the division.
-
template<class
X
>
Xoperator/
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::value_type &rhs)¶ Computes the division of the batch
lhs
by the scalarrhs
.Equivalent to the division of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the division.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the division.rhs
: scalar involved in the division.
-
template<class
X
>
Xoperator/
(const typename simd_batch_traits<X>::value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the division of the scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the division.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: scalar involved in the division.rhs
: batch involved in the division.
-
template<class
X
>
Xoperator/
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_batch &rhs)¶ Computes the division of the batch
lhs
by the batchrhs
.- Return
the result of the division.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the division.rhs
: real batch involved in the division.
-
template<class
X
>
Xoperator/
(const typename simd_batch_traits<X>::real_batch &lhs, const simd_complex_batch<X> &rhs)¶ Computes the division of the batch
lhs
by the batchrhs
.- Return
the result of the division.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real batch involved in the division.rhs
: batch involved in the division.
-
template<class
X
>
Xoperator/
(const simd_complex_batch<X> &lhs, const typename simd_batch_traits<X>::real_value_type &rhs)¶ Computes the division of the batch
lhs
by the real scalarrhs
.Equivalent to the division of two batches where all the values of the second one are initialized to
rhs
.- Return
the result of the division.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: batch involved in the division.rhs
: real scalar involved in the division.
-
template<class
X
>
Xoperator/
(const typename simd_batch_traits<X>::real_value_type &lhs, const simd_complex_batch<X> &rhs)¶ Computes the division of the real scalar
lhs
and the batchrhs
.Equivalent to the difference of two batches where all the values of the first one are initialized to
rhs
.- Return
the result of the division.
- Template Parameters
X
: the actual type of batch.
- Parameters
lhs
: real scalar involved in the division.rhs
: batch involved in the division.
-
template<class
X
>
simd_batch_traits<X>::value_typehadd
(const simd_complex_batch<X> &rhs)¶ Adds all the scalars of the batch
rhs
.- Return
the result of the reduction.
- Parameters
rhs
: batch involved in the reduction
-
template<class
X
>
Xselect
(const typename simd_batch_traits<X>::batch_bool_type &cond, const simd_complex_batch<X> &a, const simd_complex_batch<X> &b)¶ Ternary operator for batches: selects values from the batches
a
orb
depending on the boolean values incond
.Equivalent to
for(std::size_t i = 0; i < N; ++i) res[i] = cond[i] ? a[i] : b[i];
- Return
the result of the selection.
- Parameters
cond
: batch condition.a
: batch values for truthy condition.b
: batch value for falsy condition.
-
template<class
X
>
simd_batch_traits<X>::batch_bool_typeoperator==
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs)¶ Element-wise equality comparison of batches
lhs
andrhs
.- Return
a boolean batch.
- Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.
-
template<class
X
>
simd_batch_traits<X>::batch_bool_typeoperator!=
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs)¶ Element-wise inequality comparison of batches
lhs
andrhs
.- Return
a boolean batch.
- Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.
Comparison operators¶
-
template<class
X
>
simd_batch_traits<X>::batch_bool_typeoperator==
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs) Element-wise equality comparison of batches
lhs
andrhs
.- Return
a boolean batch.
- Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.
-
template<class
X
>
simd_batch_traits<X>::batch_bool_typeoperator!=
(const simd_complex_batch<X> &lhs, const simd_complex_batch<X> &rhs) Element-wise inequality comparison of batches
lhs
andrhs
.- Return
a boolean batch.
- Parameters
lhs
: batch involved in the comparison.rhs
: batch involved in the comparison.
Reducers¶
Miscellaneous¶
-
template<class
X
>
Xselect
(const typename simd_batch_traits<X>::batch_bool_type &cond, const simd_complex_batch<X> &a, const simd_complex_batch<X> &b) Ternary operator for batches: selects values from the batches
a
orb
depending on the boolean values incond
.Equivalent to
for(std::size_t i = 0; i < N; ++i) res[i] = cond[i] ? a[i] : b[i];
- Return
the result of the selection.
- Parameters
cond
: batch condition.a
: batch values for truthy condition.b
: batch value for falsy condition.
Other operators¶
-
template<class
X
>
std::ostream &xsimd
::
operator<<
(std::ostream &out, const simd_complex_batch<X> &rhs)¶ Insert the batch
rhs
into the streamout
.- Return
the output stream.
- Template Parameters
X
: the actual type of batch.
- Parameters
out
: the output stream.rhs
: the batch to output.