@@ -822,7 +822,6 @@ Complex!(CommonType!(T, U)) fromPolar(T, U)(T modulus, U argument)
822822*/
823823Complex! T sin (T)(Complex! T z) @safe pure nothrow @nogc
824824{
825- import std.math : expi, coshisinh;
826825 auto cs = expi(z.re);
827826 auto csh = coshisinh(z.im);
828827 return typeof (return )(cs.im * csh.re, cs.re * csh.im);
@@ -840,7 +839,6 @@ Complex!T sin(T)(Complex!T z) @safe pure nothrow @nogc
840839// / ditto
841840Complex! T cos (T)(Complex! T z) @safe pure nothrow @nogc
842841{
843- import std.math : expi, coshisinh;
844842 auto cs = expi(z.re);
845843 auto csh = coshisinh(z.im);
846844 return typeof (return )(cs.re * csh.re, - cs.im * csh.im);
@@ -886,6 +884,39 @@ Complex!real expi(real y) @trusted pure nothrow @nogc
886884}
887885
888886
887+ /**
888+ Params: y = A real number.
889+ Returns: The value of cosh(y) + i sinh(y)
890+
891+ Note:
892+ $(D coshisinh) is included here for convenience and for easy migration of code
893+ that uses $(REF _coshisinh, std,math).
894+ */
895+ Complex! real coshisinh (real y) @safe pure nothrow @nogc
896+ {
897+ static import std.math ;
898+ if (std.math.fabs (z) <= 0.5 )
899+ return Complex! real (std.math.cosh (z), std.math.sinh (z));
900+ else
901+ {
902+ auto z = std.math.exp (z);
903+ auto zi = 0.5 / z;
904+ z = 0.5 * z;
905+ return Complex! real (z + zi, z - zi);
906+ }
907+ }
908+
909+ @safe pure nothrow @nogc unittest
910+ {
911+ static import std.math ;
912+
913+ assert (coshisinh(3.0L ) == complex(std.math.cosh (3.0L ), std.math.sinh (3.0L )));
914+ auto z1 = coshisinh(1.234 );
915+ auto z2 = std.math.coshisinh (1.234 );
916+ assert (z1.re == z2.re && z1.im == z2.im);
917+ }
918+
919+
889920/**
890921 Params: z = A complex number.
891922 Returns: The square root of `z`.
0 commit comments