feature. See also
. The project being documented here (as the example) is the Zig library itself.
sinh.sinh32
fn sinh32(z: Complex(f32)) Complex(f32)
File
Code
fn sinh32(z: Complex(f32)) Complex(f32) {
const x = z.re;
const y = z.im;
const hx = @as(u32, @bitCast(x));
const ix = hx & 0x7fffffff;
const hy = @as(u32, @bitCast(y));
const iy = hy & 0x7fffffff;
if (ix < 0x7f800000 and iy < 0x7f800000) {
if (iy == 0) {
return Complex(f32).init(math.sinh(x), y);
}
if (ix < 0x41100000) {
return Complex(f32).init(math.sinh(x) * @cos(y), math.cosh(x) * @sin(y));
}
if (ix < 0x42b17218) {
const h = @exp(@abs(x)) * 0.5;
return Complex(f32).init(math.copysign(h, x) * @cos(y), h * @sin(y));
}
else if (ix < 0x4340b1e7) {
const v = Complex(f32).init(@abs(x), y);
const r = ldexp_cexp(v, -1);
return Complex(f32).init(r.re * math.copysign(@as(f32, 1.0), x), r.im);
}
else {
const h = 0x1p127 * x;
return Complex(f32).init(h * @cos(y), h * h * @sin(y));
}
}
if (ix == 0 and iy >= 0x7f800000) {
return Complex(f32).init(math.copysign(@as(f32, 0.0), x * (y - y)), y - y);
}
if (iy == 0 and ix >= 0x7f800000) {
if (hx & 0x7fffff == 0) {
return Complex(f32).init(x, y);
}
return Complex(f32).init(x, math.copysign(@as(f32, 0.0), y));
}
if (ix < 0x7f800000 and iy >= 0x7f800000) {
return Complex(f32).init(y - y, x * (y - y));
}
if (ix >= 0x7f800000 and (hx & 0x7fffff) == 0) {
if (iy >= 0x7f800000) {
return Complex(f32).init(x * x, x * (y - y));
}
return Complex(f32).init(x * @cos(y), math.inf(f32) * @sin(y));
}
return Complex(f32).init((x * x) * (y - y), (x + x) * (y - y));
}