Cpp-standard-library-cpp-complex-norm

提供:Dev Guides
移動先:案内検索

C ++複雑なライブラリ-ノルム

説明

これは複素数のノルムであり、複素数xのノルム値を返します。 複素数のノルム値は、その2乗の大きさであり、その実数部と虚数部(虚数単位なし)の2乗の加算として定義されます。 これはabs(x)の二乗です。

宣言

以下は、std
normの宣言です。
template<class T> T norm (const complex<T>& x);

C 11

template<class T> T norm (const complex<T>& x);

パラメーター

*x* これは複雑な値です。

戻り値

複素数xのノルム値を返します。

例外

none

以下のstd
normの例。
#include <iostream>
#include <complex>

int main () {
   std::complex<double> mycomplex (1.0,5.0);
   std::cout << "The norm of " << mycomplex << " is " << std::norm(mycomplex)
      << '\n';
   return 0;
}

サンプル出力は次のようになります-

The norm of (1,5) is 26