NaN(),
}
+// branch cut continuity checks
+// points on each axis at |z| > 1 are checked for one-sided continuity from both the positive and negative side
+// all possible branch cuts for the elementary functions are at one of these points
+
+var zero = 0.0
+var eps = 1.0 / (1 << 53)
+
+var branchPoints = [][2]complex128{
+ {complex(2.0, zero), complex(2.0, eps)},
+ {complex(2.0, -zero), complex(2.0, -eps)},
+ {complex(-2.0, zero), complex(-2.0, eps)},
+ {complex(-2.0, -zero), complex(-2.0, -eps)},
+ {complex(zero, 2.0), complex(eps, 2.0)},
+ {complex(-zero, 2.0), complex(-eps, 2.0)},
+ {complex(zero, -2.0), complex(eps, -2.0)},
+ {complex(-zero, -2.0), complex(-eps, -2.0)},
+}
+
// functions borrowed from pkg/math/all_test.go
func tolerance(a, b, e float64) bool {
d := a - b
t.Errorf("Acos(%g) = %g, want %g", vcAcosSC[i], f, acosSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Acos(pt[0]), Acos(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Acos(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestAcosh(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Acosh(%g) = %g, want %g", vcAcoshSC[i], f, acoshSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Acosh(pt[0]), Acosh(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Acosh(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestAsin(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Asin(%g) = %g, want %g", vcAsinSC[i], f, asinSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Asin(pt[0]), Asin(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Asin(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestAsinh(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Asinh(%g) = %g, want %g", vcAsinhSC[i], f, asinhSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Asinh(pt[0]), Asinh(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Asinh(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestAtan(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Atan(%g) = %g, want %g", vcAtanSC[i], f, atanSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Atan(pt[0]), Atan(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Atan(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestAtanh(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Atanh(%g) = %g, want %g", vcAtanhSC[i], f, atanhSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Atanh(pt[0]), Atanh(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Atanh(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestConj(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Log(%g) = %g, want %g", vcLogSC[i], f, logSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Log(pt[0]), Log(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Log(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestLog10(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Pow(%g, %g) = %g, want %g", vcPowSC[i][0], vcPowSC[i][0], f, powSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Pow(pt[0], 0.1), Pow(pt[1], 0.1); !cVeryclose(f0, f1) {
+ t.Errorf("Pow(%g, 0.1) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestRect(t *testing.T) {
for i := 0; i < len(vc); i++ {
t.Errorf("Sqrt(%g) = %g, want %g", vcSqrtSC[i], f, sqrtSC[i])
}
}
+ for _, pt := range branchPoints {
+ if f0, f1 := Sqrt(pt[0]), Sqrt(pt[1]); !cVeryclose(f0, f1) {
+ t.Errorf("Sqrt(%g) not continuous, got %g want %g", pt[0], f0, f1)
+ }
+ }
}
func TestTan(t *testing.T) {
for i := 0; i < len(vc); i++ {