Mercurial > hg > octave-nkf
annotate scripts/specfun/ellipke.m @ 19794:db92e7e28e1f
strip trailing whitespace from most source files
* NEWS, doc/interpreter/contributors.in, doc/interpreter/func.txi,
doc/interpreter/genpropdoc.m, doc/interpreter/octave_logo.eps,
doc/interpreter/plot.txi, doc/interpreter/stmt.txi,
examples/data/Makefile.am, libinterp/corefcn/data.cc,
libinterp/corefcn/debug.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/load-path.cc, libinterp/corefcn/pr-output.cc,
libinterp/corefcn/pt-jit.cc, libinterp/corefcn/strfind.cc,
libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h,
libinterp/corefcn/urlwrite.cc, libinterp/corefcn/variables.cc,
libinterp/octave-value/ov-classdef.cc,
libinterp/octave-value/ov-classdef.h, libinterp/octave.cc,
libinterp/parse-tree/lex.h, libinterp/parse-tree/oct-parse.in.yy,
libinterp/parse-tree/pt-classdef.h, liboctave/system/file-ops.cc,
liboctave/system/oct-env.cc, m4/acinclude.m4,
scripts/deprecated/finite.m, scripts/deprecated/fmod.m,
scripts/deprecated/fnmatch.m, scripts/deprecated/luinc.m,
scripts/deprecated/octave_tmp_file_name.m, scripts/deprecated/syl.m,
scripts/deprecated/usage.m, scripts/general/inputParser.m,
scripts/general/interp1.m, scripts/general/interp2.m,
scripts/general/interp3.m, scripts/general/isequal.m,
scripts/general/private/__isequal__.m, scripts/geometry/voronoi.m,
scripts/image/image.m, scripts/image/imshow.m,
scripts/image/ind2rgb.m, scripts/linear-algebra/bandwidth.m,
scripts/linear-algebra/isbanded.m, scripts/miscellaneous/bzip2.m,
scripts/miscellaneous/cast.m, scripts/miscellaneous/copyfile.m,
scripts/miscellaneous/delete.m, scripts/miscellaneous/fullfile.m,
scripts/miscellaneous/getappdata.m, scripts/miscellaneous/gunzip.m,
scripts/miscellaneous/isappdata.m, scripts/miscellaneous/ls.m,
scripts/miscellaneous/mex.m, scripts/miscellaneous/movefile.m,
scripts/miscellaneous/orderfields.m, scripts/miscellaneous/recycle.m,
scripts/miscellaneous/rmappdata.m, scripts/miscellaneous/setfield.m,
scripts/miscellaneous/symvar.m, scripts/miscellaneous/tar.m,
scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m,
scripts/miscellaneous/ver.m, scripts/miscellaneous/what.m,
scripts/miscellaneous/xor.m, scripts/miscellaneous/zip.m,
scripts/optimization/fminbnd.m, scripts/optimization/sqp.m,
scripts/path/private/getsavepath.m, scripts/path/savepath.m,
scripts/pkg/pkg.m, scripts/pkg/private/installed_packages.m,
scripts/plot/draw/plotyy.m, scripts/plot/draw/polar.m,
scripts/plot/draw/private/__quiver__.m,
scripts/plot/draw/private/__scatter__.m,
scripts/plot/draw/private/__stem__.m, scripts/plot/draw/surface.m,
scripts/plot/draw/surfnorm.m, scripts/plot/util/copyobj.m,
scripts/plot/util/hgload.m, scripts/plot/util/hgsave.m,
scripts/plot/util/isprop.m, scripts/plot/util/linkprop.m,
scripts/plot/util/private/__go_draw_axes__.m, scripts/set/setdiff.m,
scripts/set/union.m, scripts/signal/periodogram.m,
scripts/sparse/eigs.m, scripts/sparse/ilu.m, scripts/sparse/qmr.m,
scripts/sparse/sprand.m, scripts/sparse/sprandn.m,
scripts/specfun/beta.m, scripts/specfun/ellipke.m,
scripts/specfun/isprime.m, scripts/statistics/base/lscov.m,
scripts/testfun/__run_test_suite__.m, scripts/testfun/test.m:
Strip trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 10:29:54 -0500 |
parents | 4cf81bccaf1c |
children | 507ccf8f10ed |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17371
diff
changeset
|
1 ## Copyright (C) 2001, 2013 David Billinghurst |
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17371
diff
changeset
|
2 ## Copyright (C) 2001, 2013 Paul Kienzle |
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17371
diff
changeset
|
3 ## Copyright (C) 2003, 2013 Jaakko Ruohio |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
4 ## |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
5 ## This file is part of Octave. |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
6 ## |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
7 ## Octave is free software; you can redistribute it and/or modify it |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
8 ## under the terms of the GNU General Public License as published by |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
9 ## the Free Software Foundation; either version 3 of the License, or (at |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
10 ## your option) any later version. |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
11 ## |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
12 ## Octave is distributed in the hope that it will be useful, but |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
15 ## General Public License for more details. |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
16 ## |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
17 ## You should have received a copy of the GNU General Public License |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
18 ## along with Octave; see the file COPYING. If not, see |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
19 ## <http://www.gnu.org/licenses/>. |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
20 |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
21 ## -*- texinfo -*- |
17370
c7c0dad2f9ac
doc: Use Octave citation style for references in ellipj, ellipke.
Rik <rik@octave.org>
parents:
17336
diff
changeset
|
22 ## @deftypefn {Function File} {@var{k} =} ellipke (@var{m}) |
c7c0dad2f9ac
doc: Use Octave citation style for references in ellipj, ellipke.
Rik <rik@octave.org>
parents:
17336
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{k} =} ellipke (@var{m}, @var{tol}) |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
24 ## @deftypefnx {Function File} {[@var{k}, @var{e}] =} ellipke (@dots{}) |
17370
c7c0dad2f9ac
doc: Use Octave citation style for references in ellipj, ellipke.
Rik <rik@octave.org>
parents:
17336
diff
changeset
|
25 ## Compute complete elliptic integrals of the first K(@var{m}) and second |
16587
a3fdd6041e64
Fix ellipj, ellipke, and expint docstrings
Mike Miller <mtmiller@ieee.org>
parents:
16586
diff
changeset
|
26 ## E(@var{m}) kind. |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
27 ## |
17371 | 28 ## @var{m} must be a scalar or real array with -Inf @leq{} @var{m} @leq{} 1. |
17370
c7c0dad2f9ac
doc: Use Octave citation style for references in ellipj, ellipke.
Rik <rik@octave.org>
parents:
17336
diff
changeset
|
29 ## |
19287 | 30 ## The optional input @var{tol} controls the stopping tolerance of the |
31 ## algorithm and defaults to @code{eps (class (@var{m}))}. The tolerance can | |
32 ## be increased to compute a faster, less accurate approximation. | |
33 ## | |
34 ## When called with one output only elliptic integrals of the first kind are | |
35 ## returned. | |
36 ## | |
37 ## Mathematical Note: | |
38 ## | |
39 ## Elliptic integrals of the first kind are defined as | |
40 ## | |
41 ## @tex | |
42 ## $$ | |
43 ## {\rm K} (m) = \int_0^1 {dt \over \sqrt{(1 - t^2) (1 - m^2 t^2)}} | |
44 ## $$ | |
45 ## @end tex | |
46 ## @ifnottex | |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
47 ## |
19287 | 48 ## @example |
49 ## @group | |
50 ## 1 | |
51 ## / dt | |
52 ## K (m) = | ------------------------------ | |
53 ## / sqrt ((1 - t^2)*(1 - m^2*t^2)) | |
54 ## 0 | |
55 ## @end group | |
56 ## @end example | |
57 ## | |
58 ## @end ifnottex | |
59 ## | |
60 ## Elliptic integrals of the second kind are defined as | |
61 ## | |
62 ## @tex | |
63 ## $$ | |
64 ## {\rm E} (m) = \int_0^1 {\sqrt{1 - m^2 t^2} \over \sqrt{1 - t^2}} dt | |
65 ## $$ | |
66 ## @end tex | |
67 ## @ifnottex | |
68 ## | |
69 ## @example | |
70 ## @group | |
71 ## 1 | |
72 ## / sqrt (1 - m^2*t^2) | |
73 ## E (m) = | ------------------ dt | |
74 ## / sqrt (1 - t^2) | |
75 ## 0 | |
76 ## @end group | |
77 ## @end example | |
78 ## | |
79 ## @end ifnottex | |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
80 ## |
19232
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 ## Reference: Milton @nospell{Abramowitz} and Irene A. @nospell{Stegun}, |
17370
c7c0dad2f9ac
doc: Use Octave citation style for references in ellipj, ellipke.
Rik <rik@octave.org>
parents:
17336
diff
changeset
|
82 ## @cite{Handbook of Mathematical Functions}, Chapter 17, Dover, 1965. |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
83 ## @seealso{ellipj} |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
84 ## @end deftypefn |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
85 |
16768 | 86 ## Author: David Billinghurst <David.Billinghurst@riotinto.com> |
87 ## Author: Paul Kienzle <pkienzle@users.sf.net> | |
88 ## Author: Jaakko Ruohio | |
89 | |
19287 | 90 function [k, e] = ellipke (m, tol = []) |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
91 |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
92 if (nargin < 1 || nargin > 2) |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
93 print_usage (); |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
94 endif |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
95 |
19287 | 96 sz = size (m); |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
97 m = m(:); |
17371 | 98 if (! isreal (m)) |
99 error ("ellipke: M must be real"); | |
100 elseif (any (m > 1)) | |
101 error ("ellipke: M must be <= 1"); | |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
102 endif |
19794
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19287
diff
changeset
|
103 |
19287 | 104 if (isempty (tol)) |
105 tol = eps (class (m)); | |
106 elseif (! (isreal (tol) && isscalar (tol) && tol > 0)) | |
107 error ("ellipke: TOL must be a real scalar > 0") | |
108 endif | |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
109 |
19287 | 110 k = e = zeros (sz); |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
111 |
17371 | 112 ## Handle extreme values |
113 idx_1 = (m == 1); | |
114 k(idx_1) = Inf; | |
115 e(idx_1) = 1; | |
116 | |
117 idx_neginf = (m == -Inf); | |
118 k(idx_neginf) = 0; | |
119 e(idx_neginf) = Inf; | |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
120 |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
121 ## Arithmetic-Geometric Mean (AGM) algorithm |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
122 ## ( Abramowitz and Stegun, Section 17.6 ) |
17371 | 123 Nmax = 16; |
124 idx = !idx_1 & !idx_neginf; | |
125 if (any (idx)) | |
126 idx_neg = find (m < 0 & !idx_neginf); | |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
127 mult_k = 1./sqrt (1 - m(idx_neg)); |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
128 mult_e = sqrt (1 - m(idx_neg)); |
17371 | 129 m(idx_neg) = -m(idx_neg) ./ (1 - m(idx_neg)); |
130 a = ones (sum (idx), 1); | |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
131 b = sqrt (1 - m(idx)); |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
132 c = sqrt (m(idx)); |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
133 f = 0.5; |
17371 | 134 sum = f*c.^2; |
135 n = 2; | |
136 do | |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
137 t = (a + b)/2; |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
138 c = (a - b)/2; |
19287 | 139 b = sqrt (a .* b); |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
140 a = t; |
17371 | 141 f *= 2; |
142 sum += f*c.^2; | |
19287 | 143 until (all (c./a < tol) || (++n > Nmax)) |
17371 | 144 if (n >= Nmax) |
145 error ("ellipke: algorithm did not converge in %d iterations", Nmax); | |
146 endif | |
147 k(idx) = 0.5*pi ./ a; | |
148 e(idx) = 0.5*pi*(1 - sum) ./ a; | |
149 k(idx_neg) = mult_k .* k(idx_neg); | |
150 e(idx_neg) = mult_e .* e(idx_neg); | |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
151 endif |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
152 |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
153 endfunction |
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
154 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
155 |
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
156 ## Test complete elliptic functions of first and second kind |
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
157 ## against "exact" solution from Mathematica 3.0 |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
158 %!test |
19287 | 159 %! m = [0.0, 0.01; 0.1, 0.5; 0.9, 0.99; 1.0, 0.0]; |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
160 %! [k,e] = ellipke (m); |
16584
2f766ceeb03e
Add ellipj, ellipke, and expint functions from Octave Forge
Mike Miller <mtmiller@ieee.org>
parents:
diff
changeset
|
161 %! |
19287 | 162 %! k_exp = [1.5707963267948966192, 1.5747455615173559527 |
163 %! 1.6124413487202193982, 1.8540746773013719184 | |
164 %! 2.5780921133481731882, 3.6956373629898746778 | |
165 %! Inf , 1.5707963267948966192 ]; | |
166 %! e_exp = [1.5707963267948966192, 1.5668619420216682912 | |
167 %! 1.5307576368977632025, 1.3506438810476755025 | |
168 %! 1.1047747327040733261, 1.0159935450252239356 | |
169 %! 1.0 , 1.5707963267948966192 ]; | |
16586
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
170 %! assert (k, k_exp, 8*eps); |
f423873d3275
Style fixes for ellipj.cc, ellipke.m, and expint.m
Mike Miller <mtmiller@ieee.org>
parents:
16585
diff
changeset
|
171 %! assert (e, e_exp, 8*eps); |
16585
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
172 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
173 ## Test against A&S Table 17.1 |
16585
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
174 %!test |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
175 %! m = [0:5:50]'/100; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
176 %! k_exp = [1.570796326794897; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
177 %! 1.591003453790792; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
178 %! 1.612441348720219; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
179 %! 1.635256732264580; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
180 %! 1.659623598610528; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
181 %! 1.685750354812596; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
182 %! 1.713889448178791; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
183 %! 1.744350597225613; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
184 %! 1.777519371491253; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
185 %! 1.813883936816983; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
186 %! 1.854074677301372 ]; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
187 %! e_exp = [1.570796327; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
188 %! 1.550973352; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
189 %! 1.530757637; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
190 %! 1.510121831; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
191 %! 1.489035058; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
192 %! 1.467462209; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
193 %! 1.445363064; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
194 %! 1.422691133; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
195 %! 1.399392139; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
196 %! 1.375401972; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
197 %! 1.350643881 ]; |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
198 %! [k,e] = ellipke (m); |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
199 %! assert (k, k_exp, 1e-15); |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
200 %! assert (e, e_exp, 1e-8); |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
201 |
17371 | 202 ## Test negative values against "exact" solution from Mathematica. |
203 %! m = [-0.01; -1; -5; -100; -1000; -Inf]; | |
204 %! [k,e] = ellipke (m); | |
205 %! | |
206 %! k_exp = [1.5668912730681963584; | |
207 %! 1.3110287771460599052; | |
208 %! 0.9555039270640439337; | |
209 %! 0.3682192486091410329; | |
210 %! 0.1530293349884987857; | |
211 %! 0]; | |
212 %! e_exp = [1.5747159850169884130; | |
213 %! 1.9100988945138560089; | |
214 %! 2.8301982463458773125; | |
215 %! 10.209260919814572009; | |
216 %! 31.707204053711259719; | |
217 %! Inf ]; | |
218 %! assert (k, k_exp, 8*eps); | |
219 %! assert (e, e_exp, 8*eps (e_exp)); | |
220 | |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
221 ## Test input validation |
16585
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
222 %!error ellipke () |
1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
Mike Miller <mtmiller@ieee.org>
parents:
16584
diff
changeset
|
223 %!error ellipke (1,2,3) |
19287 | 224 %!error <M must be real> ellipke (1i) |
225 %!error <M must be .= 1> ellipke (2) | |
226 %!error <TOL must be a real scalar . 0> ellipke (1, i) | |
227 %!error <TOL must be a real scalar . 0> ellipke (1, [1 1]) | |
228 %!error <TOL must be a real scalar . 0> ellipke (1, -1) | |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
229 |