File: dlas2.go

package info (click to toggle)
golang-gonum-v1-gonum 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,792 kB
  • sloc: asm: 6,252; fortran: 5,271; sh: 377; ruby: 211; makefile: 98
file content (34 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright ©2015 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package testlapack

import (
	"math"
	"testing"
)

type Dlas2er interface {
	Dlas2(f, g, h float64) (min, max float64)
}

func Dlas2Test(t *testing.T, impl Dlas2er) {
	for i, test := range []struct {
		f, g, h, ssmin, ssmax float64
	}{
		// Singular values computed from Octave.
		{10, 30, 12, 3.567778859365365, 33.634371616111189},
		{10, 30, -12, 3.567778859365365, 33.634371616111189},
		{2, 30, -12, 0.741557056404952, 32.364333658088754},
		{-2, 5, 12, 1.842864429909778, 13.023204317408728},
	} {
		ssmin, ssmax := impl.Dlas2(test.f, test.g, test.h)
		if math.Abs(ssmin-test.ssmin) > 1e-12 {
			t.Errorf("Case %d, minimal singular value mismatch. Want %v, got %v", i, test.ssmin, ssmin)
		}
		if math.Abs(ssmax-test.ssmax) > 1e-12 {
			t.Errorf("Case %d, minimal singular value mismatch. Want %v, got %v", i, test.ssmin, ssmin)
		}
	}
}