- simd[meta header]
- std::simd[meta namespace]
- function template[meta id-type]
- cpp26[meta cpp]
namespace std::simd {
template<math-floating-point V>
constexpr deduced-vec-t<V>
atan2(const V& y, const V& x); // (1) C++26
template<math-floating-point V>
constexpr deduced-vec-t<V>
atan2(const deduced-vec-t<V>& x, const V& y); // (2) C++26
template<math-floating-point V>
constexpr deduced-vec-t<V>
atan2(const V& x, const deduced-vec-t<V>& y); // (3) C++26
}- deduced-vec-t[link /reference/simd/deduced-vec-t.md]
- math-floating-point[link /reference/simd/math-floating-point.md]
要素型が浮動小数点数のbasic_vec、またはスカラーの浮動小数点数の2つの引数y・xについて、各要素の逆正接(y/xのアークタンジェント)を、両引数の符号から適切な象限を選択して求める。
- (1) : 両引数を
Vとして受け取る。 - (2), (3) : 一方の引数をスカラー値(または対応する
basic_vec)で受け取れるようにするオーバーロードである。
制約math-floating-pointは、Vが浮動小数点数の「vectorizable type」を要素とするbasic_vec、またはスカラーの浮動小数点数であることを表す説明専用のコンセプトである。deduced-vec-t<V>は、Vに対応するbasic_vec型(decltype(x + x))である。
各要素iについて、対応する各要素に<cmath>のatan2を適用した結果を要素とするbasic_vecオブジェクトを返す。
ある要素iについて定義域エラー・極エラー・値域エラーが発生する場合、その要素の値は未規定である。
errnoにアクセスするか否かは未規定である。
#include <simd>
#include <print>
namespace simd = std::simd;
int main()
{
simd::vec<float, 4> y = 1.0f; // {1, 1, 1, 1}
simd::vec<float, 4> x([](int i) { return i + 1.0f; }); // {1, 2, 3, 4}
// 各要素の逆正接を求める
simd::vec<float, 4> r = simd::atan2(y, x);
for (std::size_t i = 0; i < r.size(); ++i) {
std::print("{} ", r[i]);
}
std::println("");
}- simd::atan2[color ff0000]
0.785398 0.463648 0.321751 0.244979
- C++26
- Clang: 22 [mark noimpl]
- GCC: 16.1 [mark noimpl]
- Visual C++: 2026 Update 2 [mark noimpl]
- P1928R15 std::simd — merge data-parallel types from the Parallelism TS 2
- C++26で
std::simdライブラリが追加された
- C++26で
- P3844R4 Reword simd.math for consteval conversions
<cmath>関数と同様に引数の変換を呼び出し側で行うよう、<simd>の数学関数が複数のオーバーロードとして再規定された(比較関数の戻り値型の修正・不足していたオーバーロードの追加を含む)