Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FreeBSD x86 reals #7689

Merged
merged 4 commits into from
Nov 13, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
std.complex: Relax unittests for FreeBSD x86 53-bit precision reals
  • Loading branch information
ibuclaw committed Nov 9, 2020
commit c9557739742f7328f1ae54c9e2531e9150cfb021
34 changes: 19 additions & 15 deletions std/complex.d
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,17 @@ Complex!(CommonType!(T, U)) fromPolar(T, U)(const T modulus, const U argument)
assert(approxEqual(z.im, 1.0L, real.epsilon));
}

version (StdUnittest)
{
// Helper function for comparing two Complex numbers.
int ceqrel(T)(const Complex!T x, const Complex!T y) @safe pure nothrow @nogc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you just moved it, nvm

{
import std.math : feqrel;
const r = feqrel(x.re, y.re);
const i = feqrel(x.im, y.im);
return r < i ? r : i;
}
}

/**
Trigonometric functions on complex numbers.
Expand All @@ -920,9 +931,13 @@ Complex!T sin(T)(Complex!T z) @safe pure nothrow @nogc
{
static import std.math;
assert(sin(complex(0.0)) == 0.0);
assert(sin(complex(2.0L, 0)) == std.math.sin(2.0L));
assert(sin(complex(2.0, 0)) == std.math.sin(2.0));
}

@safe pure nothrow unittest
{
assert(ceqrel(sin(complex(2.0L, 0)), std.math.sin(2.0L)) >= real.mant_dig - 1);
}

/// ditto
Complex!T cos(T)(Complex!T z) @safe pure nothrow @nogc
Expand All @@ -937,26 +952,15 @@ Complex!T cos(T)(Complex!T z) @safe pure nothrow @nogc
{
static import std.math;
assert(cos(complex(0.0)) == 1.0);
assert(cos(complex(1.3L, 0.0)) == std.math.cos(1.3L));
assert(cos(complex(0.0L, 5.2L)) == std.math.cosh(5.2L));
}

version (StdUnittest)
{
int ceqrel(T)(const Complex!T x, const Complex!T y) @safe pure nothrow @nogc
{
import std.math : feqrel;
const r = feqrel(x.re, y.re);
const i = feqrel(x.im, y.im);
return r < i ? r : i;
}
assert(cos(complex(1.3, 0.0)) == std.math.cos(1.3));
assert(cos(complex(0.0, 5.2)) == std.math.cosh(5.2));
}

@safe pure nothrow unittest
{
static import std.math;
assert(ceqrel(cos(complex(0, 5.2L)), complex(std.math.cosh(5.2L), 0.0L)) >= real.mant_dig - 1);
assert(cos(complex(1.3L)) == std.math.cos(1.3L));
assert(ceqrel(cos(complex(1.3L)), complex(std.math.cos(1.3L))) >= real.mant_dig - 1);
}

/// ditto
Expand Down