mirror of
https://github.com/gonum/gonum.git
synced 2025-10-05 23:26:52 +08:00
lapack: rename NormFrob to Frobenius
This commit is contained in:

committed by
Vladimír Chalupecký

parent
696df21859
commit
c0cf10d539
@@ -167,8 +167,8 @@ func (impl Implementation) Dggsvd3(jobU, jobV, jobQ lapack.GSVDJob, m, n, p int,
|
||||
}
|
||||
|
||||
// Compute the Frobenius norm of matrices A and B.
|
||||
anorm := impl.Dlange(lapack.NormFrob, m, n, a, lda, nil)
|
||||
bnorm := impl.Dlange(lapack.NormFrob, p, n, b, ldb, nil)
|
||||
anorm := impl.Dlange(lapack.Frobenius, m, n, a, lda, nil)
|
||||
bnorm := impl.Dlange(lapack.Frobenius, p, n, b, ldb, nil)
|
||||
|
||||
// Get machine precision and set up threshold for determining
|
||||
// the effective numerical rank of the matrices A and B.
|
||||
|
@@ -15,14 +15,14 @@ import (
|
||||
// lapack.MaxAbs: the maximum absolute value of an element.
|
||||
// lapack.MaxColumnSum: the maximum column sum of the absolute values of the entries.
|
||||
// lapack.MaxRowSum: the maximum row sum of the absolute values of the entries.
|
||||
// lapack.NormFrob: the square root of the sum of the squares of the entries.
|
||||
// lapack.Frobenius: the square root of the sum of the squares of the entries.
|
||||
// If norm == lapack.MaxColumnSum, work must be of length n, and this function will panic otherwise.
|
||||
// There are no restrictions on work for the other matrix norms.
|
||||
func (impl Implementation) Dlange(norm lapack.MatrixNorm, m, n int, a []float64, lda int, work []float64) float64 {
|
||||
// TODO(btracey): These should probably be refactored to use BLAS calls.
|
||||
checkMatrix(m, n, a, lda)
|
||||
switch norm {
|
||||
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.NormFrob, lapack.MaxAbs:
|
||||
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.Frobenius, lapack.MaxAbs:
|
||||
default:
|
||||
panic(badNorm)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (impl Implementation) Dlange(norm lapack.MatrixNorm, m, n int, a []float64,
|
||||
}
|
||||
return value
|
||||
}
|
||||
if norm == lapack.NormFrob {
|
||||
if norm == lapack.Frobenius {
|
||||
var value float64
|
||||
scale := 0.0
|
||||
sum := 1.0
|
||||
|
@@ -55,7 +55,7 @@ func (impl Implementation) Dlanst(norm lapack.MatrixNorm, n int, d, e []float64)
|
||||
}
|
||||
}
|
||||
return anorm
|
||||
case lapack.NormFrob:
|
||||
case lapack.Frobenius:
|
||||
var scale float64
|
||||
sum := 1.0
|
||||
if n > 1 {
|
||||
|
@@ -17,7 +17,7 @@ import (
|
||||
func (impl Implementation) Dlansy(norm lapack.MatrixNorm, uplo blas.Uplo, n int, a []float64, lda int, work []float64) float64 {
|
||||
checkMatrix(n, n, a, lda)
|
||||
switch norm {
|
||||
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.NormFrob, lapack.MaxAbs:
|
||||
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.Frobenius, lapack.MaxAbs:
|
||||
default:
|
||||
panic(badNorm)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func (impl Implementation) Dlansy(norm lapack.MatrixNorm, uplo blas.Uplo, n int,
|
||||
}
|
||||
}
|
||||
return max
|
||||
case lapack.NormFrob:
|
||||
case lapack.Frobenius:
|
||||
if uplo == blas.Upper {
|
||||
var sum float64
|
||||
for i := 0; i < n; i++ {
|
||||
|
@@ -17,7 +17,7 @@ import (
|
||||
func (impl Implementation) Dlantr(norm lapack.MatrixNorm, uplo blas.Uplo, diag blas.Diag, m, n int, a []float64, lda int, work []float64) float64 {
|
||||
checkMatrix(m, n, a, lda)
|
||||
switch norm {
|
||||
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.NormFrob, lapack.MaxAbs:
|
||||
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.Frobenius, lapack.MaxAbs:
|
||||
default:
|
||||
panic(badNorm)
|
||||
}
|
||||
@@ -211,7 +211,7 @@ func (impl Implementation) Dlantr(norm lapack.MatrixNorm, uplo blas.Uplo, diag b
|
||||
return maxsum
|
||||
}
|
||||
}
|
||||
case lapack.NormFrob:
|
||||
case lapack.Frobenius:
|
||||
var nrm float64
|
||||
if diag == blas.Unit {
|
||||
if uplo == blas.Upper {
|
||||
|
@@ -64,10 +64,10 @@ const (
|
||||
type MatrixNorm byte
|
||||
|
||||
const (
|
||||
MaxAbs MatrixNorm = 'M' // max(abs(A(i,j))) ('M')
|
||||
MaxColumnSum MatrixNorm = 'O' // Maximum column sum (one norm) ('1', 'O')
|
||||
MaxRowSum MatrixNorm = 'I' // Maximum row sum (infinity norm) ('I', 'i')
|
||||
NormFrob MatrixNorm = 'F' // Frobenius norm (sqrt of sum of squares) ('F', 'f', E, 'e')
|
||||
MaxAbs MatrixNorm = 'M' // max(abs(A(i,j)))
|
||||
MaxColumnSum MatrixNorm = 'O' // Maximum absolute column sum (one norm)
|
||||
MaxRowSum MatrixNorm = 'I' // Maximum absolute row sum (infinity norm)
|
||||
Frobenius MatrixNorm = 'F' // Frobenius norm (sqrt of sum of squares)
|
||||
)
|
||||
|
||||
// MatrixType represents the kind of matrix represented in the data.
|
||||
|
@@ -73,8 +73,8 @@ func Dggsvp3Test(t *testing.T, impl Dggsvp3er) {
|
||||
b := randomGeneral(p, n, ldb, rnd)
|
||||
bCopy := cloneGeneral(b)
|
||||
|
||||
tola := float64(max(m, n)) * impl.Dlange(lapack.NormFrob, m, n, a.Data, a.Stride, nil) * dlamchE
|
||||
tolb := float64(max(p, n)) * impl.Dlange(lapack.NormFrob, p, n, b.Data, b.Stride, nil) * dlamchE
|
||||
tola := float64(max(m, n)) * impl.Dlange(lapack.Frobenius, m, n, a.Data, a.Stride, nil) * dlamchE
|
||||
tolb := float64(max(p, n)) * impl.Dlange(lapack.Frobenius, p, n, b.Data, b.Stride, nil) * dlamchE
|
||||
|
||||
u := nanGeneral(m, m, ldu)
|
||||
v := nanGeneral(p, p, ldv)
|
||||
|
@@ -80,7 +80,7 @@ func DlangeTest(t *testing.T, impl Dlanger) {
|
||||
}
|
||||
|
||||
// Test Frobenius norm
|
||||
norm = impl.Dlange(lapack.NormFrob, m, n, a, lda, work)
|
||||
norm = impl.Dlange(lapack.Frobenius, m, n, a, lda, work)
|
||||
ans = 0
|
||||
for i := 0; i < m; i++ {
|
||||
sum := blas64.Nrm2(n, blas64.Vector{Inc: 1, Data: aCopy[i*lda:]})
|
||||
@@ -88,7 +88,7 @@ func DlangeTest(t *testing.T, impl Dlanger) {
|
||||
}
|
||||
ans = math.Sqrt(ans)
|
||||
if math.Abs(norm-ans) > 1e-14 {
|
||||
t.Errorf("NormFrob mismatch. Want %v, got %v.", ans, norm)
|
||||
t.Errorf("Frobenius norm mismatch. Want %v, got %v.", ans, norm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ type Dlanster interface {
|
||||
|
||||
func DlanstTest(t *testing.T, impl Dlanster) {
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.Frobenius} {
|
||||
for _, n := range []int{1, 3, 10, 100} {
|
||||
for cas := 0; cas < 100; cas++ {
|
||||
d := make([]float64, n)
|
||||
|
@@ -21,7 +21,7 @@ type Dlansyer interface {
|
||||
|
||||
func DlansyTest(t *testing.T, impl Dlansyer) {
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.Frobenius} {
|
||||
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
||||
for _, test := range []struct {
|
||||
n, lda int
|
||||
|
@@ -21,7 +21,7 @@ type Dlantrer interface {
|
||||
|
||||
func DlantrTest(t *testing.T, impl Dlantrer) {
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.Frobenius} {
|
||||
for _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
|
||||
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
||||
for _, test := range []struct {
|
||||
|
@@ -77,8 +77,8 @@ func DtgsjaTest(t *testing.T, impl Dtgsjaer) {
|
||||
b := blockedUpperTriGeneral(p, n, k, l, ldb, false, rnd)
|
||||
bCopy := cloneGeneral(b)
|
||||
|
||||
tola := float64(max(m, n)) * impl.Dlange(lapack.NormFrob, m, n, a.Data, a.Stride, nil) * dlamchE
|
||||
tolb := float64(max(p, n)) * impl.Dlange(lapack.NormFrob, p, n, b.Data, b.Stride, nil) * dlamchE
|
||||
tola := float64(max(m, n)) * impl.Dlange(lapack.Frobenius, m, n, a.Data, a.Stride, nil) * dlamchE
|
||||
tolb := float64(max(p, n)) * impl.Dlange(lapack.Frobenius, p, n, b.Data, b.Stride, nil) * dlamchE
|
||||
|
||||
alpha := make([]float64, n)
|
||||
beta := make([]float64, n)
|
||||
|
@@ -762,7 +762,7 @@ func normLapack(norm float64, aTrans bool) lapack.MatrixNorm {
|
||||
}
|
||||
return n
|
||||
case 2:
|
||||
return lapack.NormFrob
|
||||
return lapack.Frobenius
|
||||
case math.Inf(1):
|
||||
n := lapack.MaxRowSum
|
||||
if aTrans {
|
||||
|
Reference in New Issue
Block a user