⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complex.cpp

📁 数值计算工具库,C语言编写的,可以直接调用.
💻 CPP
字号:
/*
 * Complex arrays example
 */

#include <blitz/array.h>
#include <iostream.h>

BZ_USING_NAMESPACE(blitz)

const double pi = 3.14159265358979323846264338327950288;

#ifndef BZ_HAVE_COMPLEX
int main()
{
    cout << "Complex number support is required to compile this example."
         << endl;
    return 0;
}

#else

int main()
{
    const int N = 16;

    Array<complex<float>,1> A(N);
    Array<float,1> theta(N);

    BZ_USING_NAMESPACE(blitz::tensor);

    // Fill the theta array with angles from 0..2 Pi, evenly spaced
    theta = (2 * pi * i) / N;

    // Set A[i] = cos(theta[i]) + _I * sin(theta[i])
    A = zip(cos(theta), sin(theta), complex<float>());

    cout << A << endl;

#ifdef BZ_HAVE_COMPLEX_MATH1
    // Here's another way of doing it, which eliminates the need for
    // the theta array:
    // Set A[i] = exp(Pi i _I / N)
    A = exp(zip(0, (2 * pi * i) / N, complex<float>()));

    cout << A << endl;
#endif

    return 0;
}
#endif // BZ_HAVE_COMPLEX

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -