34 error (
"ellipj: expecting scalar or matrix as %s argument", arg);
39 @deftypefn {Built-in Function} {[@var{sn}, @var{cn}, @var{dn}, @var{err}] =} ellipj (@var{u}, @var{m})\n\
40 @deftypefnx {Built-in Function} {[@var{sn}, @var{cn}, @var{dn}, @var{err}] =} ellipj (@var{u}, @var{m}, @var{tol})\n\
41 Compute the Jacobi elliptic functions @var{sn}, @var{cn}, and @var{dn}\n\
42 of complex argument @var{u} and real parameter @var{m}.\n\
44 If @var{m} is a scalar, the results are the same size as @var{u}.\n\
45 If @var{u} is a scalar, the results are the same size as @var{m}.\n\
46 If @var{u} is a column vector and @var{m} is a row vector, the\n\
47 results are matrices with @code{length (@var{u})} rows and\n\
48 @code{length (@var{m})} columns. Otherwise, @var{u} and\n\
49 @var{m} must conform in size and the results will be the same size as the\n\
52 The value of @var{u} may be complex.\n\
53 The value of @var{m} must be 0 @leq{} @var{m} @leq{} 1.\n\
55 The optional input @var{tol} is currently ignored (@sc{matlab} uses this to\n\
56 allow faster, less accurate approximation).\n\
58 If requested, @var{err} contains the following status information\n\
59 and is the same size as the result.\n\
66 Error---no computation, algorithm termination condition not met,\n\
70 Reference: Milton Abramowitz and Irene A Stegun,\n\
71 @cite{Handbook of Mathematical Functions}, Chapter 16 (Sections 16.4, 16.13,\n\
72 and 16.15), Dover, 1965.\n\
79 int nargin = args.
length ();
81 if (nargin < 2 || nargin > 3)
92 double m = args(1).double_value ();
105 double u = args(0).double_value ();
116 ellipj (u, m, sn, cn, dn, err);
138 ellipj (u, m, sn, cn, dn, err);
164 Complex *psn = sn.fortran_vec ();
165 Complex *pcn = cn.fortran_vec ();
171 ellipj (pu[i], m, psn[i], pcn[i], pdn[i], perr[i]);
182 NDArray m = args(1).array_value ();
206 NDArray sn (sz_m), cn (sz_m), dn (sz_m);
209 const double *pm = m.
data ();
210 double *psn = sn.fortran_vec ();
211 double *pcn = cn.fortran_vec ();
217 ellipj (u, pm[i], psn[i], pcn[i], pdn[i], perr[i]);
239 const double *pm = m.
data ();
240 Complex *psn = sn.fortran_vec ();
241 Complex *pcn = cn.fortran_vec ();
247 ellipj (u, pm[i], psn[i], pcn[i], pdn[i], perr[i]);
273 && sz_u(1) == 1 && sz_m(0) == 1)
280 NDArray sn (sz_out), cn (sz_out), dn (sz_out);
283 const double *pu = u.
data ();
284 const double *pm = m.
data ();
288 ellipj (pu[i], pm[j], sn(i,j), cn(i,j), dn(i,j),
297 else if (sz_m == sz_u)
299 NDArray sn (sz_m), cn (sz_m), dn (sz_m);
302 const double *pu = u.
data ();
303 const double *pm = m.
data ();
304 double *psn = sn.fortran_vec ();
305 double *pcn = cn.fortran_vec ();
311 ellipj (pu[i], pm[i], psn[i], pcn[i], pdn[i], perr[i]);
320 error (
"ellipj: Invalid size combination for U and M");
336 && sz_u(1) == 1 && sz_m(0) == 1)
347 const double *pm = m.
data ();
351 ellipj (pu[i], pm[j], sn(i,j), cn(i,j), dn(i,j),
360 else if (sz_m == sz_u)
366 const double *pm = m.
data ();
367 Complex *psn = sn.fortran_vec ();
368 Complex *pcn = cn.fortran_vec ();
374 ellipj (pu[i], pm[i], psn[i], pcn[i], pdn[i], perr[i]);
383 error (
"ellipj: Invalid size combination for U and M");