?? complex-test.cpp
字號:
/* * Complex arrays example */#include <blitz/array.h>BZ_USING_NAMESPACE(blitz)const double pi = 3.14159265358979323846264338327950288;#ifndef BZ_HAVE_COMPLEXint main(){ cout << "Complex number support is required to compile this example." << endl; return 0;}#elseint 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 + -