複素数に数学的なベッセル関数を使用できるようにするアルゴリズムを探していました。今、私は有望な結果を見つけました。(実数または複素数の引数と実数のベッセル関数 Jv と Yv に興味があります。)
私は Visual Studio 2010 Express C++ で作業していますが、そこに実装されている関数にアクセスしたいと考えています。それ、どうやったら出来るの?
Download this http://www.crbond.com/download/bessel.zip file and add the files to your visual studio project. To use the functions, you will need to #include "BESSEL.h"
to your source file.
I got it compile on Visual Studio by doing the following
_USE_MATH_DEFINES
to preprocessor definitions.#include <complex.h>
to #include <complex>
using namespace std;
to BESSEL.H
Example of how to call a function:
#include "BESSEL.H"
#include <iostream>
int main() {
double x, i0, i1, k0, k1, i0p, i1p, k0p, k1p;
x = 5.0;
i0 = 1.0;
i1 = 2.0;
k0 = 3.0;
k1 = 4.0;
i0p = 5.0;
i1p = 6.0;
k0p = 7.0;
k1p = 8.0;
bessik01a(x, i0, i1, k0, k1, i0p, i1p, k0p, k1p);
// Results are stored in the variables i0..k1p
cout << i0 << " " << i1 << " " << k0 << " " << k1;
return 0;
}
上記のリンク先のファイルをプロジェクトに追加します。
これらの .cpp ファイルと .h ファイルの古いヘッダー ファイルを編集する必要があることに注意してください。より具体的に: 変更
#include<complex.h>
に
#include<complex>
名前空間 std を使用します。にもmath.h
。上の図のように main.cpp に次のように記述します。
#include <iostream>
using namespace std;
#include "BESSEL.H"
int main ()
{
complex<double> z = 3;
complex<double> J0;
complex<double> J1;
complex<double> Y0;
complex<double> Y1;
complex<double> J0p;
complex<double> J1p;
complex<double> Y0p;
complex<double> Y1p;
cbessjy01(z,J0,J1,Y0,Y1,J0p,J1p,Y0p,Y1p);
cout<< "J0: " << J0 << "\n";
cout<< "J0p: " << J0p << "\n";
cout<< "J1: " << J1 << "\n";
cout<< "J1p: " << J1p << "\n";
cout<< "Y0: " << Y0 << "\n";
cout<< "Y0p: " << Y0p << "\n";
cout<< "Y1: " << Y1 << "\n";
cout<< "Y1p: " << Y1p << "\n";
cin.get();
return 0;
}
プログラムを実行してみます。z
ベッセル関数の引数です。
J0
、 、などはベッセル関数ですが、どれがどれであるかJ1
を決定する必要がある場合は、式の数値を試してみてください。たとえば、J0 がどの式の結果であるかを確認します。私はベッセル関数の専門家ではありません。しかし、使用する必要がある正確な式を教えていただければ、テストできます。