Intel xvec
Experimental C++ simd class library
Loading...
Searching...
No Matches
std_complex.hpp
1//===----------------------------------------------------------------------===//
2//
3// Copyright (C) 2021 Intel Corporation
4//
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include <complex>
12
13#include <xvec/detail/config.hpp>
14#include <xvec/detail/utilities.hpp>
15
16namespace _XVEC_NAMESPACE::simd
17{
18
26
31template<vec_complex _Vc> constexpr _Vc conj(const _Vc& value) { return detail::conj(target, value); }
32
37template<vec_complex _Vc> constexpr auto real(const _Vc& value) { return value.real(); }
38
43template<vec_complex _Vc> constexpr auto imag(const _Vc& value) { return value.imag(); }
44
49template<vec_complex _Vc> constexpr auto norm(const _Vc& value) { return (value * conj(value)).real(); }
50
55template<vec_complex _Vc> constexpr auto abs(const _Vc& value) { return sqrt(norm(value)); }
56
58
61
66template<vec_complex _Vc> inline _Vc ceil(const _Vc& value)
68
73template<vec_complex _Vc> inline _Vc floor(const _Vc& value)
75
80template<vec_complex _Vc> inline _Vc trunc(const _Vc& value)
82
87template<vec_complex _Vc> inline _Vc round(const _Vc& value)
89
91
93
94} // namespace _XVEC_NAMESPACE::simd
95
96namespace _XVEC_NAMESPACE {
97 // When implemented, arg, proj, polar, exp, etc.
98 using simd::conj;
99 using simd::imag;
100 using simd::real;
101 using simd::norm;
102}
constexpr auto norm(const _Vc &value)
Compute the squared magnitude of each complex element.
Definition std_complex.hpp:49
constexpr auto real(const _Vc &value)
Extract the real component of each complex element.
Definition std_complex.hpp:37
constexpr auto abs(const _Vc &value)
Compute the magnitude of each complex element.
Definition std_complex.hpp:55
constexpr auto imag(const _Vc &value)
Extract the imaginary component of each complex element.
Definition std_complex.hpp:43
constexpr _Vc conj(const _Vc &value)
Compute the conjugate of each complex element.
Definition std_complex.hpp:31
constexpr detail::deduced_vec_t< _Vp > sqrt(const _Vp &v)
Compute the square root of each element.
Definition std_math.hpp:102
_Vc floor(const _Vc &value)
Round the real and imaginary components of each element downward.
Definition std_complex.hpp:73
_Vc round(const _Vc &value)
Apply round independently to the real and imaginary components.
Definition std_complex.hpp:87
_Vc trunc(const _Vc &value)
Truncate the real and imaginary components of each element.
Definition std_complex.hpp:80
_Vc ceil(const _Vc &value)
Round the real and imaginary components of each element upward.
Definition std_complex.hpp:66
constexpr auto simd_bit_cast(const _From &v) noexcept
A simd-generic version of simd_bit_cast which directly invokes std::bit_cast.
Definition core.hpp:585