3 Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail)
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
23 test bessel_polynomial.h and other related headers
25 gcc -W -Wall -Wextra -ansi pedantic
28 reduced precisions for ansi c
32 #include "custom_math.h"
33 #include "bessel_polynomial.h"
34 #include "durand_kerner.h"
38 register cmath_uint16_t i
= 0;
39 register cmath_int16_t diff
= 0;
41 cmath_uint32_t in_order
= _BESSEL_MAX_ORDER
+ 1;
43 const cmath_uint16_t reverse
= 1;
45 cmath_std_int_t coeff
[_BESSEL_MAX_ORDER
+ 1];
47 cnum_t dk_coeff
[_BESSEL_MAX_ORDER
+ 1];
48 cnum_s dk_roots
[_BESSEL_MAX_ORDER
];
52 puts("\n\nansi c is: on");
54 puts("\n\nansi c is: off");
58 while (in_order
> _BESSEL_MAX_ORDER
)
60 printf("\nenter order of bessel polynomial (0 - %d): ", _BESSEL_MAX_ORDER
);
61 scanf("%u", &in_order
);
64 order
= (cmath_uint16_t
)in_order
;
65 bessel_polynomial(coeff
, order
, reverse
);
67 printf("\norder [N]: %d", order
);
68 printf("\nreversed bessel: %d\n\n", reverse
);
69 printf("list of coefficients:\n");
72 printf("order[%2d]: ", (order
- i
));
73 printf("%"_CMATH_PR_STD_INT
"\n", coeff
[i
]);
76 puts("\npolynomial:");
82 diff
= (cmath_int16_t
)(order
- i
);
86 printf("%"_CMATH_PR_STD_INT
, coeff
[i
]);
88 printf("*x^%d + ", diff
);
93 printf("x^%d + ", diff
);
95 printf("%"_CMATH_PR_STD_INT
"", coeff
[i
]);
100 puts("\n\nlist roots:");
104 dk_coeff
[i
] = (cnum_t
)coeff
[i
];
108 durand_kerner(dk_coeff
, dk_roots
, order
);
113 printf("root[%2d]: %.15f \t % .15f*i\n",
114 i
+1, (double)dk_roots
[i
].r
, (double)dk_roots
[i
].i
);