首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::abs(std::complex)

Defined in header <complex>

template< class T > T abs( const complex<T>& z );

返回复数的大小。z...

参数

z

-

complex value

返回值

如果没有发生错误,则返回绝对值%28(也称为范数、模数或数量级%29)。z...

错误和特殊情况的处理方式就像函数是按照std::hypot(std::real(z), std::imag(z))...

实例

二次

代码语言:javascript
复制
#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";
}

二次

产出:

二次

代码语言:javascript
复制
(1,1) cartesian is rho = 1.41421 theta = 0.785398 polar

二次

另见

arg

returns the phase angle (function template)

polar

constructs a complex number from magnitude and phase angle (function template)

abs(int)labsllabs (C++11)

computes absolute value of an integral value (|x|) (function)

abs(float) fabs

absolute value of a floating point value (|x|) (function)

hypot (C++11)

computes square root of the sum of the squares of two given numbers (√x2+y2) (function)

abs(std::valarray)

applies the function std::abs to each element of valarray (function template)

C出租车文件

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券