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

Commit

Permalink
Add tests and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
btracey committed Oct 6, 2015
1 parent c1b013f commit 5aed243
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cgo/lapack.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const (
badIpiv = "lapack: insufficient permutation length"
badLdA = "lapack: index of a out of range"
badNorm = "lapack: bad norm"
badPivot = "lapack: bad pivot"
badSide = "lapack: bad side"
badSlice = "lapack: bad input slice length"
badStore = "lapack: bad store"
badTau = "lapack: tau has insufficient length"
badTrans = "lapack: bad trans"
Expand Down
33 changes: 32 additions & 1 deletion native/dlasr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,40 @@ import (
"github.com/gonum/lapack"
)

// Dlasr applies a sequence of plane rotations to a matrix.
// Dlasr applies a sequence of plane rotations to the m×n matrix A. P(k) is a 2×2
// rotation matrix defined by s[k] and c[k]. If direct == lapack.Forward, the
// rotation matrices are applied as P = P(z-1) * ... * P(2) * P(1), while if
// direct == lapack.Backward they are applied as P = P(1) * P(2) * ... * P(n).
// If side == lapack.Left, A = P * A, while if side == lapack.Right, A = A * P^T.
// If pivot == lapack.Variable, the rotation is performed for the (k, k+1) plane,
// if pivot == lapack.Top, the rotation is performed for the (1, k+1) plane,
// and if pivot == lapack.Bottom, the rotation is performed for the (k, z) plane.
func (impl Implementation) Dlasr(side blas.Side, pivot lapack.Pivot, direct lapack.Direct, m, n int, c, s, a []float64, lda int) {
checkMatrix(m, n, a, lda)
if side != blas.Left && side != blas.Right {
panic(badSide)
}
if pivot != lapack.Variable && pivot != lapack.Top && pivot != lapack.Bottom {
panic(badPivot)
}
if direct != lapack.Forward && direct != lapack.Backward {
panic(badDirect)
}
if side == blas.Left {
if len(c) < m-1 {
panic(badSlice)
}
if len(s) < m-1 {
panic(badSlice)
}
} else {
if len(c) < n-1 {
panic(badSlice)
}
if len(s) < n-1 {
panic(badSlice)
}
}
if m == 0 || n == 0 {
return
}
Expand Down
2 changes: 2 additions & 0 deletions native/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const (
badIpiv = "lapack: insufficient permutation length"
badLdA = "lapack: index of a out of range"
badNorm = "lapack: bad norm"
badPivot = "lapack: bad pivot"
badSide = "lapack: bad side"
badSlice = "lapack: bad input slice length"
badStore = "lapack: bad store"
badTau = "lapack: tau has insufficient length"
badTrans = "lapack: bad trans"
Expand Down

0 comments on commit 5aed243

Please sign in to comment.