1 // Copyright ©2015 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 type Dlas2er interface {
13 Dlas2(f, g, h float64) (min, max float64)
16 func Dlas2Test(t *testing.T, impl Dlas2er) {
17 for i, test := range []struct {
18 f, g, h, ssmin, ssmax float64
20 // Singular values computed from Octave.
21 {10, 30, 12, 3.567778859365365, 33.634371616111189},
22 {10, 30, -12, 3.567778859365365, 33.634371616111189},
23 {2, 30, -12, 0.741557056404952, 32.364333658088754},
24 {-2, 5, 12, 1.842864429909778, 13.023204317408728},
26 ssmin, ssmax := impl.Dlas2(test.f, test.g, test.h)
27 if math.Abs(ssmin-test.ssmin) > 1e-12 {
28 t.Errorf("Case %d, minimal singular value mismatch. Want %v, got %v", i, test.ssmin, ssmin)
30 if math.Abs(ssmax-test.ssmax) > 1e-12 {
31 t.Errorf("Case %d, minimal singular value mismatch. Want %v, got %v", i, test.ssmin, ssmin)