mirror of
https://github.com/gonum/gonum.git
synced 2025-10-08 16:40:06 +08:00
mat: add SymBandDense.Norm
This commit is contained in:

committed by
Vladimír Chalupecký

parent
06f3d524c3
commit
dd45c215c4
@@ -7,6 +7,8 @@ package mat
|
||||
import (
|
||||
"gonum.org/v1/gonum/blas"
|
||||
"gonum.org/v1/gonum/blas/blas64"
|
||||
"gonum.org/v1/gonum/lapack"
|
||||
"gonum.org/v1/gonum/lapack/lapack64"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -242,6 +244,25 @@ func (s *SymBandDense) DoColNonZero(j int, fn func(i, j int, v float64)) {
|
||||
}
|
||||
}
|
||||
|
||||
// Norm returns the specified norm of the receiver. Valid norms are:
|
||||
// 1 - The maximum absolute column sum
|
||||
// 2 - The Frobenius norm, the square root of the sum of the squares of the elements
|
||||
// Inf - The maximum absolute row sum
|
||||
//
|
||||
// Norm will panic with ErrNormOrder if an illegal norm is specified.
|
||||
func (s *SymBandDense) Norm(norm float64) float64 {
|
||||
if s.IsEmpty() {
|
||||
panic(ErrZeroLength)
|
||||
}
|
||||
lnorm := normLapack(norm, false)
|
||||
if lnorm == lapack.MaxColumnSum || lnorm == lapack.MaxRowSum {
|
||||
work := getFloats(s.mat.N, false)
|
||||
defer putFloats(work)
|
||||
return lapack64.Lansb(lnorm, s.mat, work)
|
||||
}
|
||||
return lapack64.Lansb(lnorm, s.mat, nil)
|
||||
}
|
||||
|
||||
// Trace returns the trace.
|
||||
func (s *SymBandDense) Trace() float64 {
|
||||
rb := s.RawSymBand()
|
||||
|
Reference in New Issue
Block a user