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

Commit

Permalink
Remove blas.Float64 nil checks from calls
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Jan 1, 2015
1 parent ee734bf commit af21049
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
13 changes: 6 additions & 7 deletions mat64/dense.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import (
// Set the default BLAS implementation.
var blasEngine blas.Float64 = goblas.Blas{}

func Register(b blas.Float64) { blasEngine = b }
func Register(b blas.Float64) {
if b == nil {
panic("mat64: cannot register nil blas.Float64")
}
blasEngine = b
}

func Registered() blas.Float64 { return blasEngine }

Expand Down Expand Up @@ -104,9 +109,6 @@ func (m *Dense) Col(dst []float64, j int) []float64 {
dst = make([]float64, m.mat.Rows)
}
dst = dst[:min(len(dst), m.mat.Rows)]
if blasEngine == nil {
panic(ErrNoEngine)
}
blasEngine.Dcopy(len(dst), m.mat.Data[j:], m.mat.Stride, dst, 1)

return dst
Expand All @@ -117,9 +119,6 @@ func (m *Dense) SetCol(j int, src []float64) int {
panic(ErrIndexOutOfRange)
}

if blasEngine == nil {
panic(ErrNoEngine)
}
blasEngine.Dcopy(min(len(src), m.mat.Rows), src, 1, m.mat.Data[j:], m.mat.Stride)

return min(len(src), m.mat.Rows)
Expand Down
12 changes: 0 additions & 12 deletions mat64/dense_arithmetic.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,6 @@ func (m *Dense) Mul(a, b Matrix) {
if a, ok := a.(RawMatrixer); ok {
if b, ok := b.(RawMatrixer); ok {
amat, bmat := a.RawMatrix(), b.RawMatrix()
if blasEngine == nil {
panic(ErrNoEngine)
}
blasEngine.Dgemm(
blas.NoTrans, blas.NoTrans,
ar, bc, ac,
Expand All @@ -405,9 +402,6 @@ func (m *Dense) Mul(a, b Matrix) {
if b, ok := b.(Vectorer); ok {
row := make([]float64, ac)
col := make([]float64, br)
if blasEngine == nil {
panic(ErrNoEngine)
}
for r := 0; r < ar; r++ {
for c := 0; c < bc; c++ {
w.mat.Data[r*w.mat.Stride+c] = blasEngine.Ddot(ac, a.Row(row, r), 1, b.Col(col, c), 1)
Expand Down Expand Up @@ -482,9 +476,6 @@ func (m *Dense) MulTrans(a Matrix, aTrans bool, b Matrix, bTrans bool) {
}

amat, bmat := a.RawMatrix(), b.RawMatrix()
if blasEngine == nil {
panic(ErrNoEngine)
}
blasEngine.Dgemm(
aOp, bOp,
ar, bc, ac,
Expand All @@ -502,9 +493,6 @@ func (m *Dense) MulTrans(a Matrix, aTrans bool, b Matrix, bTrans bool) {
if b, ok := b.(Vectorer); ok {
row := make([]float64, ac)
col := make([]float64, br)
if blasEngine == nil {
panic(ErrNoEngine)
}
if aTrans {
if bTrans {
for r := 0; r < ar; r++ {
Expand Down
1 change: 0 additions & 1 deletion mat64/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ const (
ErrShape = Error("mat64: dimension mismatch")
ErrIllegalStride = Error("mat64: illegal stride")
ErrPivot = Error("mat64: malformed pivot list")
ErrNoEngine = Error("mat64: no blas engine registered: call Register()")
)

func min(a, b int) int {
Expand Down

0 comments on commit af21049

Please sign in to comment.