mirror of
https://github.com/gonum/gonum.git
synced 2025-10-04 14:52:57 +08:00
testlapack: adjust some tolerances (#1224)
This commit is contained in:

committed by
GitHub

parent
86e8186781
commit
a84dbb2e4f
@@ -285,6 +285,7 @@ func DgeevTest(t *testing.T, impl Dgeever) {
|
||||
a: Gear(4).Matrix(),
|
||||
evWant: Gear(4).Eigenvalues(),
|
||||
valTol: 1e-7,
|
||||
vecTol: 1e-11,
|
||||
},
|
||||
{
|
||||
a: Gear(5).Matrix(),
|
||||
@@ -294,6 +295,7 @@ func DgeevTest(t *testing.T, impl Dgeever) {
|
||||
a: Gear(10).Matrix(),
|
||||
evWant: Gear(10).Eigenvalues(),
|
||||
valTol: 1e-8,
|
||||
vecTol: 1e-11,
|
||||
},
|
||||
{
|
||||
a: Gear(15).Matrix(),
|
||||
@@ -303,11 +305,13 @@ func DgeevTest(t *testing.T, impl Dgeever) {
|
||||
a: Gear(30).Matrix(),
|
||||
evWant: Gear(30).Eigenvalues(),
|
||||
valTol: 1e-8,
|
||||
vecTol: 1e-11,
|
||||
},
|
||||
{
|
||||
a: Gear(50).Matrix(),
|
||||
evWant: Gear(50).Eigenvalues(),
|
||||
valTol: 1e-8,
|
||||
vecTol: 1e-11,
|
||||
},
|
||||
{
|
||||
a: Gear(101).Matrix(),
|
||||
@@ -317,6 +321,7 @@ func DgeevTest(t *testing.T, impl Dgeever) {
|
||||
a: Gear(150).Matrix(),
|
||||
evWant: Gear(150).Eigenvalues(),
|
||||
valTol: 1e-8,
|
||||
vecTol: 1e-11,
|
||||
},
|
||||
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ func Dlaln2Test(t *testing.T, impl Dlaln2er) {
|
||||
}
|
||||
|
||||
func testDlaln2(t *testing.T, impl Dlaln2er, trans bool, na, nw, extra int, rnd *rand.Rand) {
|
||||
const tol = 1e-12
|
||||
const tol = 1e-11
|
||||
|
||||
// Generate random input scalars.
|
||||
ca := rnd.NormFloat64()
|
||||
|
@@ -121,7 +121,7 @@ func dlansbTest(t *testing.T, impl Dlansber, rnd *rand.Rand, uplo blas.Uplo, n,
|
||||
case lapack.Frobenius:
|
||||
normWant = frobWant
|
||||
}
|
||||
if math.Abs(normGot-normWant) >= tol {
|
||||
if math.Abs(normGot-normWant) > tol*float64(n) {
|
||||
t.Errorf("%v: unexpected result; got %v, want %v", name, normGot, normWant)
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ type Dlascler interface {
|
||||
}
|
||||
|
||||
func DlasclTest(t *testing.T, impl Dlascler) {
|
||||
const tol = 1e-16
|
||||
const tol = 1e-15
|
||||
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
for ti, test := range []struct {
|
||||
@@ -56,14 +56,44 @@ func DlasclTest(t *testing.T, impl Dlascler) {
|
||||
t.Errorf("%v: out-of-range write to A", prefix)
|
||||
}
|
||||
switch kind {
|
||||
case lapack.UpperTri:
|
||||
var mod bool
|
||||
loopLower:
|
||||
for i := 0; i < m; i++ {
|
||||
for j := 0; j < min(i, n); j++ {
|
||||
if a.Data[i*a.Stride+j] != aCopy.Data[i*aCopy.Stride+j] {
|
||||
mod = true
|
||||
break loopLower
|
||||
}
|
||||
}
|
||||
}
|
||||
if mod {
|
||||
t.Errorf("%v: unexpected modification in lower triangle of A", prefix)
|
||||
}
|
||||
case lapack.LowerTri:
|
||||
var mod bool
|
||||
loopUpper:
|
||||
for i := 0; i < m; i++ {
|
||||
for j := i + 1; j < n; j++ {
|
||||
if a.Data[i*a.Stride+j] != aCopy.Data[i*aCopy.Stride+j] {
|
||||
mod = true
|
||||
break loopUpper
|
||||
}
|
||||
}
|
||||
}
|
||||
if mod {
|
||||
t.Errorf("%v: unexpected modification in upper triangle of A", prefix)
|
||||
}
|
||||
}
|
||||
|
||||
var resid float64
|
||||
switch kind {
|
||||
case lapack.General:
|
||||
for i := 0; i < m; i++ {
|
||||
for j := 0; j < n; j++ {
|
||||
want := scale * aCopy.Data[i*aCopy.Stride+j]
|
||||
got := a.Data[i*a.Stride+j]
|
||||
if math.Abs(want-got) > tol {
|
||||
t.Errorf("%v: unexpected A[%v,%v]=%v, want %v", prefix, i, j, got, want)
|
||||
}
|
||||
resid = math.Max(resid, math.Abs(want-got))
|
||||
}
|
||||
}
|
||||
case lapack.UpperTri:
|
||||
@@ -71,16 +101,7 @@ func DlasclTest(t *testing.T, impl Dlascler) {
|
||||
for j := i; j < n; j++ {
|
||||
want := scale * aCopy.Data[i*aCopy.Stride+j]
|
||||
got := a.Data[i*a.Stride+j]
|
||||
if math.Abs(want-got) > tol {
|
||||
t.Errorf("%v: unexpected A[%v,%v]=%v, want %v", prefix, i, j, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := 0; i < m; i++ {
|
||||
for j := 0; j < min(i, n); j++ {
|
||||
if a.Data[i*a.Stride+j] != aCopy.Data[i*aCopy.Stride+j] {
|
||||
t.Errorf("%v: unexpected modification in lower triangle of A", prefix)
|
||||
}
|
||||
resid = math.Max(resid, math.Abs(want-got))
|
||||
}
|
||||
}
|
||||
case lapack.LowerTri:
|
||||
@@ -88,19 +109,13 @@ func DlasclTest(t *testing.T, impl Dlascler) {
|
||||
for j := 0; j <= min(i, n-1); j++ {
|
||||
want := scale * aCopy.Data[i*aCopy.Stride+j]
|
||||
got := a.Data[i*a.Stride+j]
|
||||
if math.Abs(want-got) > tol {
|
||||
t.Errorf("%v: unexpected A[%v,%v]=%v, want %v", prefix, i, j, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := 0; i < m; i++ {
|
||||
for j := i + 1; j < n; j++ {
|
||||
if a.Data[i*a.Stride+j] != aCopy.Data[i*aCopy.Stride+j] {
|
||||
t.Errorf("%v: unexpected modification in upper triangle of A", prefix)
|
||||
}
|
||||
resid = math.Max(resid, math.Abs(want-got))
|
||||
}
|
||||
}
|
||||
}
|
||||
if resid > tol*float64(max(m, n)) {
|
||||
t.Errorf("%v: unexpected result; residual=%v, want<=%v", prefix, resid, tol*float64(max(m, n)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user