tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
arg.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_COMPLEX_ARG_HPP
5#define TETL_COMPLEX_ARG_HPP
6
7#include <etl/_cmath/atan2.hpp>
8#include <etl/_complex/complex.hpp>
9#include <etl/_concepts/floating_point.hpp>
10#include <etl/_concepts/integral.hpp>
11
12namespace etl {
13
14/// \ingroup complex
15template <typename T>
16[[nodiscard]] constexpr auto arg(complex<T> const& z) noexcept -> T
17{
18 return etl::atan2(z.imag(), z.real());
19}
20
21/// \ingroup complex
22template <floating_point Float>
23[[nodiscard]] constexpr auto arg(Float f) noexcept -> complex<Float>
24{
25 return etl::arg(etl::complex<Float>(f));
26}
27
28/// \ingroup complex
29template <integral Integer>
30[[nodiscard]] constexpr auto arg(Integer i) noexcept -> complex<double>
31{
32 return etl::arg(etl::complex<double>(i));
33}
34
35} // namespace etl
36
37#endif // TETL_COMPLEX_ARG_HPP
constexpr auto arg(complex< T > const &z) noexcept -> T
Definition arg.hpp:16
constexpr auto arg(Float f) noexcept -> complex< Float >
Definition arg.hpp:23
constexpr auto arg(Integer i) noexcept -> complex< double >
Definition arg.hpp:30
Definition adjacent_find.hpp:9
A complex number.
Definition complex.hpp:20