26 #if defined (HAVE_CONFIG_H)
34 DEFUN (__betainc__, args, ,
40 int nargin = args.length ();
45 bool is_single = (args(0).is_single_type () || args(1).is_single_type ()
46 || args(2).is_single_type ());
49 int numel_x = args(0).numel ();
50 int numel_a = args(1).numel ();
51 int numel_b = args(2).numel ();
68 x = args(0).float_array_value ();
72 a =
FloatNDArray (output_dv, args(1).float_scalar_value ());
74 a = args(1).float_array_value ();
77 b =
FloatNDArray (output_dv, args(2).float_scalar_value ());
79 b = args(2).float_array_value ();
83 static const float eps = std::numeric_limits<float>::epsilon ();
84 float xj, x2, y, Cj, Dj, aj, bj, Deltaj, alpha_j, beta_j;
103 beta_j = aj - (aj * (aj + bj)) / (aj + 1) * xj;
108 while ((
std::abs ((Deltaj - 1)) >
eps) && (j < maxit))
110 Dj = beta_j + alpha_j * Dj;
113 Cj = beta_j + alpha_j / Cj;
119 alpha_j = ((aj + j - 1) * (aj + bj + j -1) * (bj - j) * j)
120 / ((aj + 2 * j - 1) * (aj + 2 * j - 1)) * x2;
121 beta_j = aj + 2 * j + ((j * (bj - j)) / (aj + 2 * j - 1)
122 - ((aj + j) * (aj + bj + j)) / (aj + 2 * j + 1)) * xj;
138 x =
NDArray (output_dv, args(0).scalar_value ());
140 x = args(0).array_value ();
143 a =
NDArray (output_dv, args(1).scalar_value ());
145 a = args(1).array_value ();
148 b =
NDArray (output_dv, args(2).scalar_value ());
150 b = args(2).array_value ();
154 static const double eps = std::numeric_limits<double>::epsilon ();
155 double xj, x2, y, Cj, Dj, aj, bj, Deltaj, alpha_j, beta_j;
174 beta_j = aj - (aj * (aj + bj)) / (aj + 1) * xj;
179 while ((
std::abs ((Deltaj - 1)) >
eps) && (j < maxit))
181 Dj = beta_j + alpha_j * Dj;
184 Cj = beta_j + alpha_j / Cj;
190 alpha_j = ((aj + j - 1) * (aj + bj + j - 1) * (bj - j) * j)
191 / ((aj + 2 * j - 1) * (aj + 2 * j - 1)) * x2;
192 beta_j = aj + 2 * j + ((j * (bj - j)) / (aj + 2 * j - 1)
193 - ((aj + j) * (aj + bj + j)) / (aj + 2 * j + 1)) * xj;
charNDArray max(char d, const charNDArray &m)
Vector representing the dimensions (size) of an Array.
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
F77_RET_T const F77_DBLE * x
octave_value::octave_value(const Array< char > &chm, char type) return retval