GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::norm - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. complex
  3. complex
  4. norm

最終更新日時: 2026年09月11日 13時06分31秒 (JST)
Akira Takahashi が更新

履歴 編集

function template
<complex>

std::norm

namespace std {
  template <class T>
  T
    norm(const complex<T>& x); // (1) C++98
  template <class T>
  constexpr T
    norm(const complex<T>& x); // (1) C++20

  Promoted
    norm(Arithmetic x);        // (2) C++11
  constexpr Promoted
    norm(Arithmetic x);        // (2) C++26
}

概要

複素数体のノルム(field norm。絶対値の 2 乗)を得る。

  • (1) : complex<T>に対するオーバーロード
  • (2) : 算術型に対する追加のオーバーロード

(2)は、以下のように振る舞う:

  • 実引数の型が浮動小数点数型 T の場合、complex<T> にキャストされているかのように振る舞う
  • そうでなくて、実引数が整数型の場合、complex<double> にキャストされているかのように振る舞う (C++23)

また、これらの追加のオーバーロードが関数テンプレートなのか否か、あるいは、引数が参照型なのか否かなどについては、規格では何も言及されていない。

戻り値

引数 x のノルム

備考

  • ここで言う「ノルム」は複素数を体として実数体の拡大体と見た際のノルム(x * conj(x))である。
    複素数を複素平面上の点と見たときの原点との距離(絶対値:abs)ではないことに注意。

例

#include <iostream>
#include <complex>

int main()
{
  std::complex<double> c(1.0, 2.0);

  double result = std::norm(c);
  std::cout << "norm( " << c << " ) = " << result << std::endl;
}

出力

norm( (1,2) ) = 5

バージョン

言語

  • C++98(追加のオーバーロードは C++11 から)

処理系

  • Clang: 3.0 ✅, 3.1 ✅, 3.2 ✅, 3.3 ✅, 3.4(追加のオーバーロード含む) ✅
  • GCC: 4.3.6 ✅, 4.4.7 ✅, 4.5.4 ✅, 4.6.4 ✅, 4.7.3 ✅, 4.8.1 ✅, 4.8.2 ✅, 4.9.0(追加のオーバーロード以外) ✅
  • GCC: 4.3.6 ✅, 4.4.7 ✅, 4.5.4 ✅, 4.6.4 ✅, 4.7.3 ✅, 4.8.1 ✅, 4.8.2 ✅, 4.9.0(追加のオーバーロード含む) ✅
  • Visual C++: ??

関連項目

名前 説明
real 複素数の実部を得る。
imag 複素数の虚部を得る。
abs 複素数の絶対値を得る。
arg 複素数の偏角を得る。
conj 共役複素数を得る。
proj リーマン球面への射影を得る。
polar 指定した絶対値と偏角の複素数値を得る。

参照

  • ノルム (体論) - Wikipedia
  • ノルム - Wikipedia
  • P0415R1 Constexpr for std::complex
  • P1467R9 Extended floating-point types and standard names
    • C++23で拡張浮動小数点数型への対応が行われ、整数型も考慮されるようになった
  • P1383R2 More constexpr for <cmath> and <complex>
    • C++26で(2)がconstexpr対応した
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.