gpt4 book ai didi

c++ - 为什么 `std::conj(double d)`不返回 `double`而是 `std::complex`?

转载 作者:行者123 更新时间:2023-12-03 07:15:40 24 4
gpt4 key购买 nike

对我来说,std::conj(double d)仅返回d类型的double会更自然,因为结果肯定是真实的。

最佳答案

因为conj是对复数的运算。它匹配从doublestd::complex<double>的隐式转换,该转换将零初始化虚部。
来自cppreference:

Additional overloads are provided for float, double, long double, and all integer types, which are treated as complex numbers with zero imaginary component.

关于c++ - 为什么 `std::conj(double d)`不返回 `double`而是 `std::complex<double>`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64482415/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com