# Batch of Complex Numbers

template<class T, class A>
class batch<std::complex<T>, A> : public types::simd_register<T, A>, public xsimd::types::integral_only_operators<T, A>

  batch of complex values.

  Abstract representation of an SIMD register for complex values.

  Template Parameters:

    - T – the type of the underlying values.

    - A – the architecture this batch is tied too.

  Public Types

  using value_type = std::complex<T>

    Type of the complex elements within this batch.

  using real_batch = batch<T, A>

    Type of the scalar elements within this batch.

  using arch_type = A

    SIMD Architecture abstracted by this batch.

  using batch_bool_type = batch_bool<T, A>

    Associated batch type used to represented logical operations on this batch.

  using register_type = typename types::simd_register<T, A>::register_type

    SIMD register type abstracted by this batch.

  Public Functions

  inline batch() = default

    Create a batch initialized with undefined values.

  inline batch<T, A> broadcast(U val) noexcept

    Equivalent to batch::batch(T val).

  inline batch<T, A> load_aligned(U const *mem) noexcept

    Loading from aligned memory.

    May involve a conversion if `U` is different from `T`.

  inline batch<T, A> load_unaligned(U const *mem) noexcept

    Loading from unaligned memory.

    May involve a conversion if `U` is different from `T`.

  inline batch<T, A> load(U const *mem, aligned_mode) noexcept

    Equivalent to batch::load_aligned().

  inline batch<T, A> load(U const *mem, unaligned_mode) noexcept

    Equivalent to batch::load_unaligned().

  inline batch<T, A> gather(U const *src, batch<V, A> const &index) noexcept

    Create a new batch gathering elements starting at address `src` and offset by each element in `index`.

    If `T` is not of the same size as `U`, a `static_cast` is performed at element gather time.

  inline void scatter(U *dst, batch<V, arch_type> const &index) const noexcept

    Scatter elements from this batch into addresses starting at `dst` and offset by each element in `index`.

    If `T` is not of the same size as `U`, a `static_cast` is performed at element scatter time.

  Public Static Attributes

  static std::size_t size = real_batch::size

    Number of complex elements in this batch.

  Friends

  inline friend batch operator+(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::add().

  inline friend batch operator-(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::sub().

  inline friend batch operator*(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::mul().

  inline friend batch operator/(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::div().

  inline friend batch operator&(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::bitwise_and().

  inline friend batch operator|(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::bitwise_or().

  inline friend batch operator^(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::bitwise_xor().

  inline friend batch operator&&(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::logical_and().

  inline friend batch operator||(batch const &self, batch const &other) noexcept

    Shorthand for xsimd::logical_or().

## Operations Specific to Batches of Complex Numbers

template<class T, class A>
inline batch<T, A> abs(batch<std::complex<T>, A> const &z) noexcept

  Computes the absolute values of each complex in the batch `z`.

  Parameters:

    z – batch of complex values.

  Returns:

    the absolute values of `z`.

template<class T, class A>
inline real_batch_type_t<batch<T, A>> arg(batch<T, A> const &z) noexcept

  Computes the argument of the batch `z`.

  Parameters:

    z – batch of complex or real values.

  Returns:

    the argument of `z`.

template<class A, class T>
inline complex_batch_type_t<batch<T, A>> conj(batch<T, A> const &z) noexcept

  Computes the conjugate of the batch `z`.

  Parameters:

    z – batch of complex values.

  Returns:

    the argument of `z`.

template<class T, class A>
inline real_batch_type_t<batch<T, A>> imag(batch<T, A> const &x) noexcept

  Computes the imaginary part of the batch `x`.

  Parameters:

    x – batch of complex or real values.

  Returns:

    the argument of `x`.

template<class T, class A>
inline real_batch_type_t<batch<T, A>> norm(batch<T, A> const &x) noexcept

  Computes the norm of the batch `x`.

  Parameters:

    x – batch of complex or real values.

  Returns:

    the norm of `x`.

template<class T, class A>
inline complex_batch_type_t<batch<T, A>> proj(batch<T, A> const &z) noexcept

  Computes the projection of the batch `z`.

  Parameters:

    z – batch of complex or real values.

  Returns:

    the projection of `z`.

template<class T, class A>
inline real_batch_type_t<batch<T, A>> real(batch<T, A> const &z) noexcept

  Computes the real part of the batch `z`.

  Parameters:

    z – batch of complex or real values.

  Returns:

    the argument of `z`.

## XTL Complex Support

If the preprocessor token `XSIMD_ENABLE_XTL_COMPLEX` is defined, `xsimd` provides constructors of `xsimd::batch< std::complex< T >, A >` from `xtl::xcomplex`, similar to those for `std::complex`. This requires XTL to be installed.