请问complex.h怎么用

2019-07-27 16:11发布

我看好多介绍说自带的Complex.h在优化的时候更好,因为各种内联函数都准备好了,
我尝试着用了一下,编译通过了,但是debug的时候提示找不到
Can't find a source file at "/tmp/TI_MKLIBFPr8Yu/SRC/c99_complex.c"
请大大门指教。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
10条回答
zhangmangui
2019-07-27 19:33
#include <iostream>
#include <complex>
using namespace std;

int main(int argc, char *argv[])
{
    complex<double> a(1, 2), b(3, 4);

    cout << "a = " << a << ", b = " << b << endl;
    cout << "a + b = " << a + b << endl;
    cout << "a * b = " << a * b << endl;

    cout << " the real part of a is " << real(a) << endl;
    cout << "the imaginary part of b is " << imag(b) << endl;
    cout << "the magnitude of a is " << abs(a) << endl;

    cout << " e^a = " << exp(a) << endl;
    cout << "ln(b) = " << log(b) << endl;

    return 0;
}

一周热门 更多>