std::abs(std::complex)
| Defined in header <complex>
|
||
| template< class T > T abs( const complex<T>& z ); |
||
Returns the magnitude of the complex number z.
Contents |
[edit] Parameters
| z | - | complex value |
[edit] Return value
If no errors occur, returns the absolute value (also known as norm, modulus, or magnitude) of z.
Errors and special cases are handled as if the function is implemented as std::hypot(std::real(z), std::imag(z))
[edit] Examples
#include <iostream> #include <complex> int main() { std::complex<double> z(1, 1); std::cout << z << " cartesian is rho = " << std::abs(z) << " theta = " << std::arg(z) << " polar\n"; }
Output:
(1,1) cartesian is rho = 1.41421 theta = 0.785398 polar
[edit] See also
| returns the phase angle (function template) | |
| constructs a complex number from magnitude and phase angle (function template) | |
| (C++11) |
computes absolute value of an integral value (|x|) (function) |
| (C++11)(C++11) |
absolute value of a floating point value (|x|) (function) |
| (C++11)(C++11)(C++11) |
computes square root of the sum of the squares of two or three (C++17) given numbers (√x2 +y2 ), (√x2 +y2 +z2 ) (function) |
| applies the function abs to each element of valarray (function template) | |
| C documentation for cabs
| |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
