46 #define DO_BESSEL(type, alpha, x, scaled, ierr, result) \
52 result = besselj (alpha, x, scaled, ierr); \
56 result = bessely (alpha, x, scaled, ierr); \
60 result = besseli (alpha, x, scaled, ierr); \
64 result = besselk (alpha, x, scaled, ierr); \
68 result = besselh1 (alpha, x, scaled, ierr); \
72 result = besselh2 (alpha, x, scaled, ierr); \
84 error (
"%s: expecting scalar or matrix as %s argument", fn, arg);
93 int nargin = args.
length ();
95 if (nargin == 2 || nargin == 3)
97 bool scaled = (nargin == 3);
106 float alpha = args(0).float_value ();
119 DO_BESSEL (type, alpha, x, scaled, ierr, result);
122 retval(1) =
static_cast<float> (
ierr);
139 DO_BESSEL (type, alpha, x, scaled, ierr, result);
158 bool args0_is_row_vector = (dv0 (1) == dv0.
numel ());
159 bool args1_is_col_vector = (dv1 (0) == dv1.
numel ());
161 if (args0_is_row_vector && args1_is_col_vector)
175 DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
203 DO_BESSEL (type, alpha, x, scaled, ierr, result);
223 DO_BESSEL (type, alpha, x, scaled, ierr, result);
243 double alpha = args(0).double_value ();
256 DO_BESSEL (type, alpha, x, scaled, ierr, result);
259 retval(1) =
static_cast<double> (
ierr);
275 DO_BESSEL (type, alpha, x, scaled, ierr, result);
294 bool args0_is_row_vector = (dv0 (1) == dv0.
numel ());
295 bool args1_is_col_vector = (dv1 (0) == dv1.
numel ());
297 if (args0_is_row_vector && args1_is_col_vector)
299 RowVector ralpha = args(0).row_vector_value ();
311 DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
339 DO_BESSEL (type, alpha, x, scaled, ierr, result);
358 DO_BESSEL (type, alpha, x, scaled, ierr, result);
383 @deftypefn {Built-in Function} {[@var{j}, @var{ierr}] =} besselj (@var{alpha}, @var{x}, @var{opt})\n\
384 @deftypefnx {Built-in Function} {[@var{y}, @var{ierr}] =} bessely (@var{alpha}, @var{x}, @var{opt})\n\
385 @deftypefnx {Built-in Function} {[@var{i}, @var{ierr}] =} besseli (@var{alpha}, @var{x}, @var{opt})\n\
386 @deftypefnx {Built-in Function} {[@var{k}, @var{ierr}] =} besselk (@var{alpha}, @var{x}, @var{opt})\n\
387 @deftypefnx {Built-in Function} {[@var{h}, @var{ierr}] =} besselh (@var{alpha}, @var{k}, @var{x}, @var{opt})\n\
388 Compute Bessel or Hankel functions of various kinds:\n\
392 Bessel functions of the first kind. If the argument @var{opt} is supplied,\n\
393 the result is multiplied by @code{exp (-abs (imag (@var{x})))}.\n\
396 Bessel functions of the second kind. If the argument @var{opt} is supplied,\n\
397 the result is multiplied by @code{exp (-abs (imag (@var{x})))}.\n\
401 Modified Bessel functions of the first kind. If the argument @var{opt} is\n\
402 supplied, the result is multiplied by @code{exp (-abs (real (@var{x})))}.\n\
406 Modified Bessel functions of the second kind. If the argument @var{opt} is\n\
407 supplied, the result is multiplied by @code{exp (@var{x})}.\n\
410 Compute Hankel functions of the first (@var{k} = 1) or second (@var{k}\n\
411 = 2) kind. If the argument @var{opt} is supplied, the result is multiplied\n\
412 by @code{exp (-I*@var{x})} for @var{k} = 1 or @code{exp (I*@var{x})} for\n\
416 If @var{alpha} is a scalar, the result is the same size as @var{x}.\n\
417 If @var{x} is a scalar, the result is the same size as @var{alpha}.\n\
418 If @var{alpha} is a row vector and @var{x} is a column vector, the\n\
419 result is a matrix with @code{length (@var{x})} rows and\n\
420 @code{length (@var{alpha})} columns. Otherwise, @var{alpha} and\n\
421 @var{x} must conform and the result will be the same size.\n\
423 The value of @var{alpha} must be real. The value of @var{x} may be\n\
426 If requested, @var{ierr} contains the following status information\n\
427 and is the same size as the result.\n\
434 Input error, return @code{NaN}.\n\
437 Overflow, return @code{Inf}.\n\
440 Loss of significance by argument reduction results in less than\n\
441 half of machine accuracy.\n\
444 Complete loss of significance by argument reduction, return @code{NaN}.\n\
447 Error---no computation, algorithm termination condition not met,\n\
448 return @code{NaN}.\n\
457 @deftypefn {Built-in Function} {[@var{y}, @var{ierr}] =} bessely (@var{alpha}, @var{x}, @var{opt})\n\
466 @deftypefn {Built-in Function} {[@var{i}, @var{ierr}] =} besseli (@var{alpha}, @var{x}, @var{opt})\n\
475 @deftypefn {Built-in Function} {[@var{k}, @var{ierr}] =} besselk (@var{alpha}, @var{x}, @var{opt})\n\
482 DEFUN (besselh, args, nargout,
484 @deftypefn {Built-in Function} {[@var{h}, @var{ierr}] =} besselh (@var{alpha}, @var{k}, @var{x}, @var{opt})\n\
490 int nargin = args.
length ();
496 else if (nargin == 3 || nargin == 4)
505 tmp_args(2) = args(3);
507 tmp_args(1) = args(2);
508 tmp_args(0) = args(0);
515 error (
"besselh: expecting K = 1 or 2");
518 error (
"besselh: invalid value of K");
528 @deftypefn {Built-in Function} {[@var{a}, @var{ierr}] =} airy (@var{k}, @var{z}, @var{opt})\n\
529 Compute Airy functions of the first and second kind, and their\n\
534 K Function Scale factor (if \"opt\" is supplied)\n\
535 --- -------- ---------------------------------------\n\
536 0 Ai (Z) exp ((2/3) * Z * sqrt (Z))\n\
537 1 dAi(Z)/dZ exp ((2/3) * Z * sqrt (Z))\n\
538 2 Bi (Z) exp (-abs (real ((2/3) * Z * sqrt (Z))))\n\
539 3 dBi(Z)/dZ exp (-abs (real ((2/3) * Z * sqrt (Z))))\n\
543 The function call @code{airy (@var{z})} is equivalent to\n\
544 @code{airy (0, @var{z})}.\n\
546 The result is the same size as @var{z}.\n\
548 If requested, @var{ierr} contains the following status information and\n\
549 is the same size as the result.\n\
556 Input error, return @code{NaN}.\n\
559 Overflow, return @code{Inf}.\n\
562 Loss of significance by argument reduction results in less than half\n\
563 of machine accuracy.\n\
566 Complete loss of significance by argument reduction, return @code{NaN}.\n\
569 Error---no computation, algorithm termination condition not met,\n\
570 return @code{NaN}.\n\
576 int nargin = args.
length ();
578 if (nargin > 0 && nargin < 4)
580 bool scale = (nargin == 3);
586 kind = args(0).int_value ();
590 if (kind < 0 || kind > 3)
591 error (
"airy: expecting K = 0, 1, 2, or 3");
594 error (
"airy: K must be an integer value");
599 int idx = nargin == 1 ? 0 : 1;
601 if (args (idx).is_single_type ())
611 result =
biry (z, kind == 3, scale, ierr);
613 result =
airy (z, kind == 1, scale, ierr);
621 error (
"airy: Z must be a complex matrix");
633 result =
biry (z, kind == 3, scale, ierr);
635 result =
airy (z, kind == 1, scale, ierr);
643 error (
"airy: Z must be a complex matrix");