複素数zの多ガンマ関数

C言語によるサンプルソースコード : 使用関数名:nag_complex_polygamma (s14afc)

ホーム > 製品 > nAG数値計算ライブラリ > サンプルソースコード集 > 複素数zの多ガンマ関数 (C言語/C++)

Keyword: 多ガンマ関数, ポリガンマ関数, 複素数

概要

本サンプルは複素数zの多ガンマ関数(プサイ関数の導関数)を求めるC言語によるサンプルプログラムです。 本サンプルは引数zを読み込み、zの各値について以下に示される多ガンマ関数を求めて出力します。

多ガンマ関数のデータ 

※本サンプルはnAG Cライブラリに含まれる関数 nag_complex_polygamma() のExampleコードです。本サンプル及び関数の詳細情報は nag_complex_polygamma のマニュアルページをご参照ください。
ご相談やお問い合わせはこちらまで

入力データ

(本関数の詳細はnag_complex_polygamma のマニュアルページを参照)
1
2
3
4
5
6

このデータをダウンロード
nag_complex_polygamma (s14afc) Example Program Data
(1.2,5.0)   0
(0.5,-0.2)  1
(-1.5,2.5)  1
(8.0,3.3)   3
(2.9,7.5)   4  : Values of z and k

  • 1行目はタイトル行で読み飛ばされます。
  • 2~6行目に引数zの値と導関数の階数(k)を指定しています。

出力結果

(本関数の詳細はnag_complex_polygamma のマニュアルページを参照)
1
2
3
4
5
6
7

この出力例をダウンロード
nag_complex_polygamma (s14afc) Example Program Results
       z            k         (d^k/dz^k)psi(z)
(  1.2,   5.0)      0 (   1.6176e+00,    1.4312e+00)
(  0.5,  -0.2)      1 (   3.4044e+00,    2.5394e+00)
( -1.5,   2.5)      1 (  -1.9737e-01,   -2.4271e-01)
(  8.0,   3.3)      3 (   1.1814e-03,   -3.4188e-03)
(  2.9,   7.5)      4 (  -5.0227e-04,   -1.4955e-03)

  • 3~7行目に引数zの値、導関数の階数、多ガンマ関数の値が出力されています。

ソースコード

(本関数の詳細はnag_complex_polygamma のマニュアルページを参照)

※本サンプルソースコードは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

このソースコードをダウンロード
/* nag_complex_polygamma (s14afc) Example Program.
 *
 * CLL6I261D/CLL6I261DL Version.
 *
 * Copyright 2017 Numerical Algorithms Group.
 *
 * nAG C Library
 *
 * Mark 26.1, 2017.
 */

#include <stdio.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nags.h>

int main(void)
{
  Complex y, z;
  Integer exit_status = 0, k;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n] ");
  printf("nag_complex_polygamma (s14afc) Example Program Results\n");
  printf("       z            k         (d^k/dz^k)psi(z)\n");
  while (scanf(" (%lf,%lf)%ld%*[^\n] ", &z.re, &z.im, &k) != EOF)
  {
    /* nag_complex_polygamma (s14afc).
     * Derivative of the psi function psi(z)
     */
    y = nag_complex_polygamma(z, k, &fail);
    if (fail.code == NE_NOERROR)
      printf("(%5.1f, %5.1f) %6ld (%13.4e, %13.4e)\n",
             z.re, z.im, k, y.re, y.im);
    else {
      printf("Error from nag_complex_polygamma (s14afc).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
  }
END:
  return exit_status;
}


関連情報
© 日本ニューメリカルアルゴリズムズグループ株式会社 2025
Privacy Policy  /  Trademarks