How to use complex number “i” in C++

后端 未结 6 848
暗喜
暗喜 2021-02-06 08:19

I am coding a simple DFT algorithm now and I want to use the complex number i in complex exponential. I saw somebody use #include and #include&

6条回答
  •  心在旅途
    2021-02-06 08:47

    You can find details here

    A simple approach would be

    #include 
    
    using std::complex;
    const double pi = 3.1415;
    void foo()
    {
        complex val(polar(1, pi/2.0); Create a complex from its olar representation
    }
    

提交回复
热议问题