Keyword: ハンケル関数, 複素数
概要
本サンプルは複素数zのハンケル関数を求めるC言語によるサンプルプログラムです。 本サンプルは複素数の引数zを読み込み、zの各値についてハンケル関数あるいは
を求めて出力します。
※本サンプルはnAG Cライブラリに含まれる関数 nag_complex_hankel() のExampleコードです。本サンプル及び関数の詳細情報は nag_complex_hankel のマニュアルページをご参照ください。
ご相談やお問い合わせはこちらまで
入力データ
(本関数の詳細はnag_complex_hankel のマニュアルページを参照)1 2 3 4 5 6
このデータをダウンロード |
nag_complex_hankel (s17dlc) Example Program Data 1 0.00 ( 0.3, 0.4) Nag_UnscaleRes 1 2.30 ( 2.0, 0.0) Nag_UnscaleRes 1 2.12 (-1.0, 0.0) Nag_UnscaleRes 2 6.00 ( 3.1, -1.6) Nag_UnscaleRes 2 6.00 ( 3.1, -1.6) Nag_ScaleRes - Values of m, fnu, z and scal
- 1行目はタイトル行で読み飛ばされます。
- 2~6行目に、関数の種類(m)、ハンケル関数の関数列の最初の関数の次数(fnu)、引数zの複素数の値(z.re,z.im)、スケーリングオプション(scal)を指定しています。関数の種類の"1"は
を意味し、"2"は
を意味します。"Nag_UnscaleRes"はスケーリングされないことを意味し、 "Nag_ScaleRes"はスケーリングされることを意味します。
出力結果
(本関数の詳細はnag_complex_hankel のマニュアルページを参照)1 2 3 4 5 6 7 8
この出力例をダウンロード |
nag_complex_hankel (s17dlc) Example Program Results Calling with n = 2 m fnu z scal cy[0] cy[1] nz 1 0.0000 ( 0.300, 0.400) Nag_UnscaleRes ( 0.347, -0.559) ( -0.791, -0.818) 0 1 2.3000 ( 2.000, 0.000) Nag_UnscaleRes ( 0.272, -0.740) ( 0.089, -1.412) 0 1 2.1200 ( -1.000, 0.000) Nag_UnscaleRes ( -0.772, -1.693) ( 2.601, 6.527) 0 2 6.0000 ( 3.100, -1.600) Nag_UnscaleRes ( -1.371, -1.280) ( -1.491, -5.993) 0 2 6.0000 ( 3.100, -1.600) Nag_ScaleRes ( 7.050, 6.052) ( 8.614, 29.352) 0
- 3~8行目に関数の種類、ハンケル関数の関数列の最初の関数の次数、引数zの値、スケーリングオプション、ハンケル関数の値、アンダーフローによりゼロにセットされたハンケル関数の値の数が出力されています。
ソースコード
(本関数の詳細はnag_complex_hankel のマニュアルページを参照)
※本サンプルソースコードはnAG数値計算ライブラリ(Windows, Linux, MAC等に対応)の関数を呼び出します。
サンプルのコンパイル及び実行方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
このソースコードをダウンロード |
/* nag_complex_hankel (s17dlc) Example Program. * * CLL6I261D/CLL6I261DL Version. * * Copyright 2017 Numerical Algorithms Group. * * Mark 26.1, 2017. */ #include <nag.h> #include <stdio.h> #include <nag_stdlib.h> #include <nags.h> int main(void) { Integer exit_status = 0; Complex z, cy[2]; double fnu; const Integer n = 2; Integer m, nz; char nag_enum_arg[40]; Nag_ScaleResType scal; NagError fail; INIT_FAIL(fail); /* Skip heading in data file */ scanf("%*[^\n]"); printf("nag_complex_hankel (s17dlc) Example Program Results\n"); printf("Calling with n = %ld\n", n); printf("m fnu z scal cy[0]" " cy[1] nz\n"); while (scanf(" %ld %lf (%lf,%lf) %39s%*[^\n] ", &m, &fnu, &z.re, &z.im, nag_enum_arg) != EOF) { /* nag_enum_name_to_value (x04nac). * Converts nAG enum member name to value */ scal = (Nag_ScaleResType) nag_enum_name_to_value(nag_enum_arg); /* nag_complex_hankel (s17dlc). * Hankel functions H_(nu+a)^(j)(z), j = 1,2, real a >= 0, * complex z, nu = 0,1,2,... */ nag_complex_hankel(m, fnu, z, n, scal, cy, &nz, &fail); if (fail.code != NE_NOERROR) { printf("Error from nag_complex_hankel (s17dlc).\n%s\n", fail.message); exit_status = 1; goto END; } if (fail.code == NE_NOERROR) printf("%ld %7.4f (%7.3f,%7.3f) %-14s (%7.3f,%7.3f) " "(%7.3f,%7.3f) %ld\n", m, fnu, z.re, z.im, nag_enum_arg, cy[0].re, cy[0].im, cy[1].re, cy[1].im, nz); else { printf("Error from nag_complex_hankel (s17dlc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: return exit_status; }