lapack: rename NormFrob to Frobenius

This commit is contained in:
Vladimir Chalupecky
2018-10-17 11:53:27 +02:00
committed by Vladimír Chalupecký
parent 696df21859
commit c0cf10d539
13 changed files with 24 additions and 24 deletions

View File

@@ -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. // Compute the Frobenius norm of matrices A and B.
anorm := impl.Dlange(lapack.NormFrob, m, n, a, lda, nil) anorm := impl.Dlange(lapack.Frobenius, m, n, a, lda, nil)
bnorm := impl.Dlange(lapack.NormFrob, p, n, b, ldb, nil) bnorm := impl.Dlange(lapack.Frobenius, p, n, b, ldb, nil)
// Get machine precision and set up threshold for determining // Get machine precision and set up threshold for determining
// the effective numerical rank of the matrices A and B. // the effective numerical rank of the matrices A and B.

View File

@@ -15,14 +15,14 @@ import (
// lapack.MaxAbs: the maximum absolute value of an element. // lapack.MaxAbs: the maximum absolute value of an element.
// lapack.MaxColumnSum: the maximum column sum of the absolute values of the entries. // 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.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. // 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. // 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 { 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. // TODO(btracey): These should probably be refactored to use BLAS calls.
checkMatrix(m, n, a, lda) checkMatrix(m, n, a, lda)
switch norm { switch norm {
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.NormFrob, lapack.MaxAbs: case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.Frobenius, lapack.MaxAbs:
default: default:
panic(badNorm) panic(badNorm)
} }
@@ -70,7 +70,7 @@ func (impl Implementation) Dlange(norm lapack.MatrixNorm, m, n int, a []float64,
} }
return value return value
} }
if norm == lapack.NormFrob { if norm == lapack.Frobenius {
var value float64 var value float64
scale := 0.0 scale := 0.0
sum := 1.0 sum := 1.0

View File

@@ -55,7 +55,7 @@ func (impl Implementation) Dlanst(norm lapack.MatrixNorm, n int, d, e []float64)
} }
} }
return anorm return anorm
case lapack.NormFrob: case lapack.Frobenius:
var scale float64 var scale float64
sum := 1.0 sum := 1.0
if n > 1 { if n > 1 {

View File

@@ -17,7 +17,7 @@ import (
func (impl Implementation) Dlansy(norm lapack.MatrixNorm, uplo blas.Uplo, n int, a []float64, lda int, work []float64) float64 { func (impl Implementation) Dlansy(norm lapack.MatrixNorm, uplo blas.Uplo, n int, a []float64, lda int, work []float64) float64 {
checkMatrix(n, n, a, lda) checkMatrix(n, n, a, lda)
switch norm { switch norm {
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.NormFrob, lapack.MaxAbs: case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.Frobenius, lapack.MaxAbs:
default: default:
panic(badNorm) panic(badNorm)
} }
@@ -98,7 +98,7 @@ func (impl Implementation) Dlansy(norm lapack.MatrixNorm, uplo blas.Uplo, n int,
} }
} }
return max return max
case lapack.NormFrob: case lapack.Frobenius:
if uplo == blas.Upper { if uplo == blas.Upper {
var sum float64 var sum float64
for i := 0; i < n; i++ { for i := 0; i < n; i++ {

View File

@@ -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 { 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) checkMatrix(m, n, a, lda)
switch norm { switch norm {
case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.NormFrob, lapack.MaxAbs: case lapack.MaxRowSum, lapack.MaxColumnSum, lapack.Frobenius, lapack.MaxAbs:
default: default:
panic(badNorm) panic(badNorm)
} }
@@ -211,7 +211,7 @@ func (impl Implementation) Dlantr(norm lapack.MatrixNorm, uplo blas.Uplo, diag b
return maxsum return maxsum
} }
} }
case lapack.NormFrob: case lapack.Frobenius:
var nrm float64 var nrm float64
if diag == blas.Unit { if diag == blas.Unit {
if uplo == blas.Upper { if uplo == blas.Upper {

View File

@@ -64,10 +64,10 @@ const (
type MatrixNorm byte type MatrixNorm byte
const ( const (
MaxAbs MatrixNorm = 'M' // max(abs(A(i,j))) ('M') MaxAbs MatrixNorm = 'M' // max(abs(A(i,j)))
MaxColumnSum MatrixNorm = 'O' // Maximum column sum (one norm) ('1', 'O') MaxColumnSum MatrixNorm = 'O' // Maximum absolute column sum (one norm)
MaxRowSum MatrixNorm = 'I' // Maximum row sum (infinity norm) ('I', 'i') MaxRowSum MatrixNorm = 'I' // Maximum absolute row sum (infinity norm)
NormFrob MatrixNorm = 'F' // Frobenius norm (sqrt of sum of squares) ('F', 'f', E, 'e') Frobenius MatrixNorm = 'F' // Frobenius norm (sqrt of sum of squares)
) )
// MatrixType represents the kind of matrix represented in the data. // MatrixType represents the kind of matrix represented in the data.

View File

@@ -73,8 +73,8 @@ func Dggsvp3Test(t *testing.T, impl Dggsvp3er) {
b := randomGeneral(p, n, ldb, rnd) b := randomGeneral(p, n, ldb, rnd)
bCopy := cloneGeneral(b) bCopy := cloneGeneral(b)
tola := float64(max(m, n)) * impl.Dlange(lapack.NormFrob, m, n, a.Data, a.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.NormFrob, p, n, b.Data, b.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) u := nanGeneral(m, m, ldu)
v := nanGeneral(p, p, ldv) v := nanGeneral(p, p, ldv)

View File

@@ -80,7 +80,7 @@ func DlangeTest(t *testing.T, impl Dlanger) {
} }
// Test Frobenius norm // 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 ans = 0
for i := 0; i < m; i++ { for i := 0; i < m; i++ {
sum := blas64.Nrm2(n, blas64.Vector{Inc: 1, Data: aCopy[i*lda:]}) 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) ans = math.Sqrt(ans)
if math.Abs(norm-ans) > 1e-14 { 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)
} }
} }
} }

View File

@@ -20,7 +20,7 @@ type Dlanster interface {
func DlanstTest(t *testing.T, impl Dlanster) { func DlanstTest(t *testing.T, impl Dlanster) {
rnd := rand.New(rand.NewSource(1)) 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 _, n := range []int{1, 3, 10, 100} {
for cas := 0; cas < 100; cas++ { for cas := 0; cas < 100; cas++ {
d := make([]float64, n) d := make([]float64, n)

View File

@@ -21,7 +21,7 @@ type Dlansyer interface {
func DlansyTest(t *testing.T, impl Dlansyer) { func DlansyTest(t *testing.T, impl Dlansyer) {
rnd := rand.New(rand.NewSource(1)) 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 _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
for _, test := range []struct { for _, test := range []struct {
n, lda int n, lda int

View File

@@ -21,7 +21,7 @@ type Dlantrer interface {
func DlantrTest(t *testing.T, impl Dlantrer) { func DlantrTest(t *testing.T, impl Dlantrer) {
rnd := rand.New(rand.NewSource(1)) 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 _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} { for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
for _, test := range []struct { for _, test := range []struct {

View File

@@ -77,8 +77,8 @@ func DtgsjaTest(t *testing.T, impl Dtgsjaer) {
b := blockedUpperTriGeneral(p, n, k, l, ldb, false, rnd) b := blockedUpperTriGeneral(p, n, k, l, ldb, false, rnd)
bCopy := cloneGeneral(b) bCopy := cloneGeneral(b)
tola := float64(max(m, n)) * impl.Dlange(lapack.NormFrob, m, n, a.Data, a.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.NormFrob, p, n, b.Data, b.Stride, nil) * dlamchE tolb := float64(max(p, n)) * impl.Dlange(lapack.Frobenius, p, n, b.Data, b.Stride, nil) * dlamchE
alpha := make([]float64, n) alpha := make([]float64, n)
beta := make([]float64, n) beta := make([]float64, n)

View File

@@ -762,7 +762,7 @@ func normLapack(norm float64, aTrans bool) lapack.MatrixNorm {
} }
return n return n
case 2: case 2:
return lapack.NormFrob return lapack.Frobenius
case math.Inf(1): case math.Inf(1):
n := lapack.MaxRowSum n := lapack.MaxRowSum
if aTrans { if aTrans {