authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-24 21:14:12-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-24 21:14:12-04:00
log1d998d5dce73d8d500dee5e41a3dca92a7f9b03e
tree4fac84336118ea7cdc221f76be5c7ff3797d0cd9
parentd5e99cc05ea05d701adffce55defc512d75e10d1

clean up complex math tests


16 files changed, 46 insertions(+), 112 deletions(-)

std/math/complex/acos.zig+2-5
......@@ -16,9 +16,6 @@ test "complex.cacos" {
1616 const a = Complex(f32).new(5, 3);
1717 const c = acos(a);
1818
19 const re = c.re;
20 const im = c.im;
21
22 debug.assert(math.approxEq(f32, re, 0.546975, epsilon));
23 debug.assert(math.approxEq(f32, im, -2.452914, epsilon));
19 debug.assert(math.approxEq(f32, c.re, 0.546975, epsilon));
20 debug.assert(math.approxEq(f32, c.im, -2.452914, epsilon));
2421}
std/math/complex/acosh.zig+2-5
......@@ -16,9 +16,6 @@ test "complex.cacosh" {
1616 const a = Complex(f32).new(5, 3);
1717 const c = acosh(a);
1818
19 const re = c.re;
20 const im = c.im;
21
22 debug.assert(math.approxEq(f32, re, 2.452914, epsilon));
23 debug.assert(math.approxEq(f32, im, 0.546975, epsilon));
19 debug.assert(math.approxEq(f32, c.re, 2.452914, epsilon));
20 debug.assert(math.approxEq(f32, c.im, 0.546975, epsilon));
2421}
std/math/complex/asin.zig+2-5
......@@ -22,9 +22,6 @@ test "complex.casin" {
2222 const a = Complex(f32).new(5, 3);
2323 const c = asin(a);
2424
25 const re = c.re;
26 const im = c.im;
27
28 debug.assert(math.approxEq(f32, re, 1.023822, epsilon));
29 debug.assert(math.approxEq(f32, im, 2.452914, epsilon));
25 debug.assert(math.approxEq(f32, c.re, 1.023822, epsilon));
26 debug.assert(math.approxEq(f32, c.im, 2.452914, epsilon));
3027}
std/math/complex/asinh.zig+2-5
......@@ -17,9 +17,6 @@ test "complex.casinh" {
1717 const a = Complex(f32).new(5, 3);
1818 const c = asinh(a);
1919
20 const re = c.re;
21 const im = c.im;
22
23 debug.assert(math.approxEq(f32, re, 2.459831, epsilon));
24 debug.assert(math.approxEq(f32, im, 0.533999, epsilon));
20 debug.assert(math.approxEq(f32, c.re, 2.459831, epsilon));
21 debug.assert(math.approxEq(f32, c.im, 0.533999, epsilon));
2522}
std/math/complex/atan.zig+6-12
......@@ -113,24 +113,18 @@ fn atan64(z: &const Complex(f64)) Complex(f64) {
113113
114114const epsilon = 0.0001;
115115
116test "complex.ctan32" {
116test "complex.catan32" {
117117 const a = Complex(f32).new(5, 3);
118118 const c = atan(a);
119119
120 const re = c.re;
121 const im = c.im;
122
123 debug.assert(math.approxEq(f32, re, 1.423679, epsilon));
124 debug.assert(math.approxEq(f32, im, 0.086569, epsilon));
120 debug.assert(math.approxEq(f32, c.re, 1.423679, epsilon));
121 debug.assert(math.approxEq(f32, c.im, 0.086569, epsilon));
125122}
126123
127test "complex.ctan64" {
124test "complex.catan64" {
128125 const a = Complex(f64).new(5, 3);
129126 const c = atan(a);
130127
131 const re = c.re;
132 const im = c.im;
133
134 debug.assert(math.approxEq(f64, re, 1.423679, epsilon));
135 debug.assert(math.approxEq(f64, im, 0.086569, epsilon));
128 debug.assert(math.approxEq(f64, c.re, 1.423679, epsilon));
129 debug.assert(math.approxEq(f64, c.im, 0.086569, epsilon));
136130}
std/math/complex/atanh.zig+2-5
......@@ -17,9 +17,6 @@ test "complex.catanh" {
1717 const a = Complex(f32).new(5, 3);
1818 const c = atanh(a);
1919
20 const re = c.re;
21 const im = c.im;
22
23 debug.assert(math.approxEq(f32, re, 0.146947, epsilon));
24 debug.assert(math.approxEq(f32, im, 1.480870, epsilon));
20 debug.assert(math.approxEq(f32, c.re, 0.146947, epsilon));
21 debug.assert(math.approxEq(f32, c.im, 1.480870, epsilon));
2522}
std/math/complex/cos.zig+2-5
......@@ -16,9 +16,6 @@ test "complex.ccos" {
1616 const a = Complex(f32).new(5, 3);
1717 const c = cos(a);
1818
19 const re = c.re;
20 const im = c.im;
21
22 debug.assert(math.approxEq(f32, re, 2.855815, epsilon));
23 debug.assert(math.approxEq(f32, im, 9.606383, epsilon));
19 debug.assert(math.approxEq(f32, c.re, 2.855815, epsilon));
20 debug.assert(math.approxEq(f32, c.im, 9.606383, epsilon));
2421}
std/math/complex/cosh.zig+4-10
......@@ -152,20 +152,14 @@ test "complex.ccosh32" {
152152 const a = Complex(f32).new(5, 3);
153153 const c = cosh(a);
154154
155 const re = c.re;
156 const im = c.im;
157
158 debug.assert(math.approxEq(f32, re, -73.467300, epsilon));
159 debug.assert(math.approxEq(f32, im, 10.471557, epsilon));
155 debug.assert(math.approxEq(f32, c.re, -73.467300, epsilon));
156 debug.assert(math.approxEq(f32, c.im, 10.471557, epsilon));
160157}
161158
162159test "complex.ccosh64" {
163160 const a = Complex(f64).new(5, 3);
164161 const c = cosh(a);
165162
166 const re = c.re;
167 const im = c.im;
168
169 debug.assert(math.approxEq(f64, re, -73.467300, epsilon));
170 debug.assert(math.approxEq(f64, im, 10.471557, epsilon));
163 debug.assert(math.approxEq(f64, c.re, -73.467300, epsilon));
164 debug.assert(math.approxEq(f64, c.im, 10.471557, epsilon));
171165}
std/math/complex/exp.zig+4-10
......@@ -127,20 +127,14 @@ test "complex.cexp32" {
127127 const a = Complex(f32).new(5, 3);
128128 const c = exp(a);
129129
130 const re = c.re;
131 const im = c.im;
132
133 debug.assert(math.approxEq(f32, re, -146.927917, epsilon));
134 debug.assert(math.approxEq(f32, im, 20.944065, epsilon));
130 debug.assert(math.approxEq(f32, c.re, -146.927917, epsilon));
131 debug.assert(math.approxEq(f32, c.im, 20.944065, epsilon));
135132}
136133
137134test "complex.cexp64" {
138135 const a = Complex(f32).new(5, 3);
139136 const c = exp(a);
140137
141 const re = c.re;
142 const im = c.im;
143
144 debug.assert(math.approxEq(f64, re, -146.927917, epsilon));
145 debug.assert(math.approxEq(f64, im, 20.944065, epsilon));
138 debug.assert(math.approxEq(f64, c.re, -146.927917, epsilon));
139 debug.assert(math.approxEq(f64, c.im, 20.944065, epsilon));
146140}
std/math/complex/log.zig+2-5
......@@ -18,9 +18,6 @@ test "complex.clog" {
1818 const a = Complex(f32).new(5, 3);
1919 const c = log(a);
2020
21 const re = c.re;
22 const im = c.im;
23
24 debug.assert(math.approxEq(f32, re, 1.763180, epsilon));
25 debug.assert(math.approxEq(f32, im, 0.540419, epsilon));
21 debug.assert(math.approxEq(f32, c.re, 1.763180, epsilon));
22 debug.assert(math.approxEq(f32, c.im, 0.540419, epsilon));
2623}
std/math/complex/pow.zig+2-5
......@@ -17,9 +17,6 @@ test "complex.cpow" {
1717 const b = Complex(f32).new(2.3, -1.3);
1818 const c = pow(Complex(f32), a, b);
1919
20 const re = c.re;
21 const im = c.im;
22
23 debug.assert(math.approxEq(f32, re, 58.049110, epsilon));
24 debug.assert(math.approxEq(f32, im, -101.003433, epsilon));
20 debug.assert(math.approxEq(f32, c.re, 58.049110, epsilon));
21 debug.assert(math.approxEq(f32, c.im, -101.003433, epsilon));
2522}
std/math/complex/sin.zig+2-5
......@@ -17,9 +17,6 @@ test "complex.csin" {
1717 const a = Complex(f32).new(5, 3);
1818 const c = sin(a);
1919
20 const re = c.re;
21 const im = c.im;
22
23 debug.assert(math.approxEq(f32, re, -9.654126, epsilon));
24 debug.assert(math.approxEq(f32, im, 2.841692, epsilon));
20 debug.assert(math.approxEq(f32, c.re, -9.654126, epsilon));
21 debug.assert(math.approxEq(f32, c.im, 2.841692, epsilon));
2522}
std/math/complex/sinh.zig+4-10
......@@ -151,20 +151,14 @@ test "complex.csinh32" {
151151 const a = Complex(f32).new(5, 3);
152152 const c = sinh(a);
153153
154 const re = c.re;
155 const im = c.im;
156
157 debug.assert(math.approxEq(f32, re, -73.460617, epsilon));
158 debug.assert(math.approxEq(f32, im, 10.472508, epsilon));
154 debug.assert(math.approxEq(f32, c.re, -73.460617, epsilon));
155 debug.assert(math.approxEq(f32, c.im, 10.472508, epsilon));
159156}
160157
161158test "complex.csinh64" {
162159 const a = Complex(f64).new(5, 3);
163160 const c = sinh(a);
164161
165 const re = c.re;
166 const im = c.im;
167
168 debug.assert(math.approxEq(f64, re, -73.460617, epsilon));
169 debug.assert(math.approxEq(f64, im, 10.472508, epsilon));
162 debug.assert(math.approxEq(f64, c.re, -73.460617, epsilon));
163 debug.assert(math.approxEq(f64, c.im, 10.472508, epsilon));
170164}
std/math/complex/sqrt.zig+4-10
......@@ -121,20 +121,14 @@ test "complex.csqrt32" {
121121 const a = Complex(f32).new(5, 3);
122122 const c = sqrt(a);
123123
124 const re = c.re;
125 const im = c.im;
126
127 debug.assert(math.approxEq(f32, re, 2.327117, epsilon));
128 debug.assert(math.approxEq(f32, im, 0.644574, epsilon));
124 debug.assert(math.approxEq(f32, c.re, 2.327117, epsilon));
125 debug.assert(math.approxEq(f32, c.im, 0.644574, epsilon));
129126}
130127
131128test "complex.csqrt64" {
132129 const a = Complex(f64).new(5, 3);
133130 const c = sqrt(a);
134131
135 const re = c.re;
136 const im = c.im;
137
138 debug.assert(math.approxEq(f64, re, 2.3271175190399496, epsilon));
139 debug.assert(math.approxEq(f64, im, 0.6445742373246469, epsilon));
132 debug.assert(math.approxEq(f64, c.re, 2.3271175190399496, epsilon));
133 debug.assert(math.approxEq(f64, c.im, 0.6445742373246469, epsilon));
140134}
std/math/complex/tan.zig+2-5
......@@ -17,9 +17,6 @@ test "complex.ctan" {
1717 const a = Complex(f32).new(5, 3);
1818 const c = tan(a);
1919
20 const re = c.re;
21 const im = c.im;
22
23 debug.assert(math.approxEq(f32, re, -0.002708233, epsilon));
24 debug.assert(math.approxEq(f32, im, 1.004165, epsilon));
20 debug.assert(math.approxEq(f32, c.re, -0.002708233, epsilon));
21 debug.assert(math.approxEq(f32, c.im, 1.004165, epsilon));
2522}
std/math/complex/tanh.zig+4-10
......@@ -98,20 +98,14 @@ test "complex.ctanh32" {
9898 const a = Complex(f32).new(5, 3);
9999 const c = tanh(a);
100100
101 const re = c.re;
102 const im = c.im;
103
104 debug.assert(math.approxEq(f32, re, 0.999913, epsilon));
105 debug.assert(math.approxEq(f32, im, -0.000025, epsilon));
101 debug.assert(math.approxEq(f32, c.re, 0.999913, epsilon));
102 debug.assert(math.approxEq(f32, c.im, -0.000025, epsilon));
106103}
107104
108105test "complex.ctanh64" {
109106 const a = Complex(f64).new(5, 3);
110107 const c = tanh(a);
111108
112 const re = c.re;
113 const im = c.im;
114
115 debug.assert(math.approxEq(f64, re, 0.999913, epsilon));
116 debug.assert(math.approxEq(f64, im, -0.000025, epsilon));
109 debug.assert(math.approxEq(f64, c.re, 0.999913, epsilon));
110 debug.assert(math.approxEq(f64, c.im, -0.000025, epsilon));
117111}