Skip to content

Commit

Permalink
local copy of Dlapy2Test
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-ch committed Jul 13, 2023
1 parent 4a3a1ef commit 659f1b1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lapack/netlib/lapack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/lapack/testlapack"

testlpck "gonum.org/v1/netlib/lapack/netlib/testlapack"
)

var impl = Implementation{}
Expand Down Expand Up @@ -93,7 +95,7 @@ func TestDlapmt(t *testing.T) {
}

func TestDlapy2(t *testing.T) {
testlapack.Dlapy2Test(t, impl)
testlpck.Dlapy2Test(t, impl)
}

func TestDlarfx(t *testing.T) {
Expand Down
32 changes: 32 additions & 0 deletions lapack/netlib/testlapack/dlapy2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright ©2016 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"

"golang.org/x/exp/rand"

"gonum.org/v1/gonum/floats/scalar"
)

type Dlapy2er interface {
Dlapy2(float64, float64) float64
}

func Dlapy2Test(t *testing.T, impl Dlapy2er) {
t.Log("local test for Dlapy2")
rnd := rand.New(rand.NewSource(1))
for i := 0; i < 10; i++ {
x := math.Abs(1e200 * rnd.NormFloat64())
y := math.Abs(1e200 * rnd.NormFloat64())
got := impl.Dlapy2(x, y)
want := math.Hypot(x, y)
if !scalar.EqualWithinRel(got, want, 1e-15) {
t.Errorf("Dlapy2(%g, %g) = %g, want %g", x, y, got, want)
}
}
}

0 comments on commit 659f1b1

Please sign in to comment.