-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a3a1ef
commit 659f1b1
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |