1 // Copyright ©2017 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.
10 "golang.org/x/exp/rand"
12 "gonum.org/v1/gonum/floats"
13 "gonum.org/v1/gonum/lapack"
16 type Dlapller interface {
18 Dlapll(n int, x []float64, incX int, y []float64, incY int) float64
21 func DlapllTest(t *testing.T, impl Dlapller) {
22 rnd := rand.New(rand.NewSource(1))
23 for i, m := range []int{5, 6, 9, 300, 400, 600} {
26 a := make([]float64, m*lda)
28 a[i] = rnd.NormFloat64()
31 aCopy := make([]float64, len(a))
34 got := impl.Dlapll(m, a[0:], 2, a[1:], 2)
36 s := make([]float64, min(m, n))
37 work := make([]float64, 1)
38 impl.Dgesvd(lapack.SVDNone, lapack.SVDNone, m, n, aCopy, lda, s, nil, 0, nil, 0, work, -1)
39 work = make([]float64, int(work[0]))
40 impl.Dgesvd(lapack.SVDNone, lapack.SVDNone, m, n, aCopy, lda, s, nil, 0, nil, 0, work, len(work))
43 if !floats.EqualWithinAbsOrRel(got, want, 1e-14, 1e-14) {
44 t.Errorf("unexpected ssmin for test %d: got:%f want:%f", i, got, want)