Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Add special case for *Vector in mat64.Norm
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-ch committed Oct 7, 2015
1 parent 5fe328e commit b75cdca
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mat64/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,26 @@ func Norm(a Matrix, norm float64) float64 {
work = make([]float64, rm.N)
}
return lapack64.Lansy(n, rm, work)
case *Vector:
rv := rma.RawVector()
switch norm {
default:
panic("unreachable")
case 1:
if aTrans {
imax := blas64.Iamax(rma.n, rv)
return math.Abs(rma.At(imax, 0))
}
return blas64.Asum(rma.n, rv)
case 2:
return blas64.Nrm2(rma.n, rv)
case math.Inf(1):
if aTrans {
return blas64.Asum(rma.n, rv)
}
imax := blas64.Iamax(rma.n, rv)
return math.Abs(rma.At(imax, 0))
}
}
switch norm {
default:
Expand Down

0 comments on commit b75cdca

Please sign in to comment.