Mercurial > octave
changeset 24910:b98755ef7572 stable
Style changes in sinint/cosint.
sinint.m: stylistic changes and a few minor typos.
cosint.m: stylistic changes and a few minor typos.
author | Colin Macdonald <cbm@m.fsf.org> |
---|---|
date | Tue, 23 Jan 2018 15:19:24 -0800 |
parents | 4a341330ee15 |
children | 8d6f3941a118 |
files | scripts/specfun/cosint.m scripts/specfun/sinint.m |
diffstat | 2 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/specfun/cosint.m Thu Sep 07 16:28:35 2017 +0200 +++ b/scripts/specfun/cosint.m Tue Jan 23 15:19:24 2018 -0800 @@ -82,20 +82,20 @@ i_miss = true (length (x), 1); - # Trivial values + ## special values y(x == 0) = - Inf; y(x == Inf) = 0; y(x == - Inf) = 1i * pi; i_miss = ((i_miss) & (x != 0) & (x != Inf) & (x != - Inf)); - # For values large in module and not in (-oo,0),we use the relation - # with expint + ## For values large in modulus and not in (-oo,0), we use the relation + ## with expint flag_large = (abs (x) > 2 & ((abs (imag (x)) > 1e-15) | real (x) > 0)); xx = x(flag_large); - # Abramowitz, relation 5.2.20 + ## Abramowitz, relation 5.2.20 ii_sw = (real (xx) <= 0 & imag (xx) <= 0); xx(ii_sw) = conj (xx(ii_sw)); ii_nw = (real (xx) < 0); @@ -105,8 +105,7 @@ yy(ii_sw) = conj (yy(ii_sw)); y(i_miss & flag_large) = yy; - # For values small in module we use the series expansion - + ## For values small in modulus, use the series expansion (also near (-oo, 0]) i_miss = ((i_miss) & (!flag_large)); xx = x(i_miss); ssum = - xx .^ 2 / 4; # First term of the series expansion @@ -128,9 +127,9 @@ endfunction + %!assert (cosint (1.1), 0.38487337742465081550, 2 * eps); - %!test %! x = [2, 3, pi; exp(1), 5, 6]; %! A = cosint (x); @@ -142,7 +141,7 @@ %!assert (cosint (inf), 0) %!assert (cosint (-inf), 1i * pi) -%%tests against maple +##tests against maple %!assert (cosint (1), 0.337403922900968135, -2*eps) %!assert (cosint (-1), 0.337403922900968135 + 3.14159265358979324*I, -2*eps) %!assert (cosint (pi), 0.0736679120464254860, -2*eps)
--- a/scripts/specfun/sinint.m Thu Sep 07 16:28:35 2017 +0200 +++ b/scripts/specfun/sinint.m Tue Jan 23 15:19:24 2018 -0800 @@ -61,14 +61,14 @@ i_miss = true (length (x), 1); - # Trivial values + ## Trivial values y(x == 0) = 0; y(x == Inf) = pi / 2; y(x == - Inf) = - pi / 2; i_miss = ((i_miss) & (x != 0) & (x != Inf) & (x != - Inf)); - # For values large in module we use the relation with expint + ## For values large in modulus we use the relation with expint flag_large = abs (x) > 2; xx = x(flag_large & i_miss); @@ -81,7 +81,7 @@ yy(ii_conj) = conj (yy(ii_conj)); y(i_miss & flag_large) = yy; - # For values small in module we use the series expansion + ## For values small in modulus we use the series expansion i_miss = ((i_miss) & (!flag_large)); xx = x(i_miss); @@ -103,6 +103,7 @@ endfunction + %!test %! x = 1.1; %! %y = sym(11)/10; @@ -124,7 +125,7 @@ %!assert (sinint (inf), pi/2) %!assert (sinint (-inf), -pi/2) -%%tests against maple +##tests against maple %!assert (sinint (1), 0.9460830703671830149414, -2*eps) %!assert (sinint (-1), -0.9460830703671830149414, -2*eps) %!assert (sinint (pi), 1.851937051982466170361, -2*eps) @@ -134,7 +135,7 @@ %!assert (sinint (20i), 1.2807826332028294459e7*1i, -2*eps) %!test -%! x = (0:4) '; +%! x = (0:4)'; %! y_ex = [0 %! 0.946083070367183015 %! 1.60541297680269485 @@ -143,7 +144,7 @@ %! assert (sinint (x), y_ex, -4*eps); %!test -%! x = -(0:4) '; +%! x = -(0:4)'; %! y_ex = - [0 %! 0.946083070367183015 %! 1.60541297680269485