26 #if defined (HAVE_CONFIG_H)
73 int nargin = args.length ();
75 if (nargin < 1 || nargin > 2)
78 const octave_value oct_z = (nargin == 1) ? args(0) : args(1);
79 const octave_idx_type k = (nargin == 1) ? 0 : args(0).xidx_type_value (
"psi: K must be an integer");
81 error (
"psi: K must be non-negative");
87 #define FLOAT_BRANCH(T, A, M, E) \
88 if (oct_z.is_ ## T ##_type ()) \
90 const A ## NDArray z = oct_z.M ## array_value (); \
91 A ## NDArray psi_z (z.dims ()); \
93 const E *zv = z.data (); \
94 E *psi_zv = psi_z.fortran_vec (); \
95 const octave_idx_type n = z.numel (); \
96 for (octave_idx_type i = 0; i < n; i++) \
97 *psi_zv++ = octave::math::psi (*zv++); \
107 error (
"psi: Z must be a floating point");
114 error (
"psi: Z must be a floating point");
122 error (
"psi: Z must be real value for polygamma (K > 0)");
124 #define FLOAT_BRANCH(T, A, M, E) \
125 if (oct_z.is_ ## T ##_type ()) \
127 const A ## NDArray z = oct_z.M ## array_value (); \
128 A ## NDArray psi_z (z.dims ()); \
130 const E *zv = z.data (); \
131 E *psi_zv = psi_z.fortran_vec (); \
132 const octave_idx_type n = z.numel (); \
133 for (octave_idx_type i = 0; i < n; i++) \
136 error ("psi: Z must be non-negative for polygamma (K > 0)"); \
138 *psi_zv++ = octave::math::psi (k, *zv++); \
146 error (
"psi: Z must be a floating point for polygamma (K > 0)");
bool iscomplex(void) const
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
std::complex< double > Complex
std::complex< float > FloatComplex
octave_value::octave_value(const Array< char > &chm, char type) return retval
#define FLOAT_BRANCH(T, A, M, E)