Fle*_*exo 18
我想你正在寻找#include <complex>
例如:
std::complex<double> num(0,1);
Run Code Online (Sandbox Code Playgroud)
您实际上可以使用std::sqrt
此complex
类型来计算sqrt(-1)
:
#include <complex>
#include <iostream>
int main() {
const std::complex<double> result = std::sqrt(std::complex<double>(-1,0));
std::cout << result << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
对于wn=exp((2*pi*i)/n)
你可以这样做:
const double pi = std::acos(-1.0);
const std::complex<double> i(0,1);
std::complex<double> wn = std::exp((2*pi*i)/double(n));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3146 次 |
最近记录: |