Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 2.48 KB

File metadata and controls

81 lines (59 loc) · 2.48 KB

log2

  • 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> log2(const V& x); // 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を底とする対数を求める。各要素に<cmath>log2を要素ごとに適用したものである。

制約math-floating-pointは、Vが浮動小数点数型を要素とするbasic_vecであることを表す説明専用のコンセプトである。deduced-vec-t<V>Vから導出されるbasic_vec型(通常はV自身)を表す。

戻り値

各要素i0以上V::size()未満)について、x[i]<cmath>log2を適用した結果に要素ごとに等しいbasic_vecオブジェクトを返す。

ある要素iについて定義域エラー・極エラー・値域エラーが発生する場合、その要素の値は未規定である。

備考

errnoにアクセスするか否かは未規定である。

#include <simd>
#include <print>

namespace simd = std::simd;

int main()
{
  simd::vec<float, 4> v{[](int i) {
    float table[] = {1.0f, 2.0f, 4.0f, 8.0f};
    return table[i];
  }};

  // 各要素の2を底とする対数を求める
  simd::vec<float, 4> r = simd::log2(v);

  for (std::size_t i = 0; i < r.size(); ++i)
    std::print("{} ", r[i]);
  std::println("");
}
  • simd::log2[color ff0000]

出力例

0 1 2 3 

バージョン

言語

  • C++26

処理系

関連項目

参照