Skip to content

Commit 80a599a

Browse files
committed
local copy of Dlapy2Test
1 parent 4a3a1ef commit 80a599a

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lapack/netlib/lapack_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
"gonum.org/v1/gonum/blas"
1111
"gonum.org/v1/gonum/lapack/testlapack"
12+
13+
testlpck "gonum.org/v1/netlib/lapack/netlib/testlapack"
1214
)
1315

1416
var impl = Implementation{}
@@ -93,7 +95,7 @@ func TestDlapmt(t *testing.T) {
9395
}
9496

9597
func TestDlapy2(t *testing.T) {
96-
testlapack.Dlapy2Test(t, impl)
98+
testlpck.Dlapy2Test(t, impl)
9799
}
98100

99101
func TestDlarfx(t *testing.T) {

lapack/netlib/testlapack/dlapy2.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright ©2016 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.
4+
5+
package testlapack
6+
7+
import (
8+
"math"
9+
"testing"
10+
11+
"golang.org/x/exp/rand"
12+
13+
"gonum.org/v1/gonum/floats/scalar"
14+
)
15+
16+
type Dlapy2er interface {
17+
Dlapy2(float64, float64) float64
18+
}
19+
20+
func Dlapy2Test(t *testing.T, impl Dlapy2er) {
21+
t.Log("local test for Dlapy2")
22+
rnd := rand.New(rand.NewSource(1))
23+
for i := 0; i < 10; i++ {
24+
x := math.Abs(1e200 * rnd.NormFloat64())
25+
y := math.Abs(1e200 * rnd.NormFloat64())
26+
got := impl.Dlapy2(x, y)
27+
want := math.Hypot(x, y)
28+
if !scalar.EqualWithinRel(got, want, 1e-16) {
29+
t.Errorf("Dlapy2(%g, %g) = %g, want %g", x, y, got, want)
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)