Skip to content

Commit

Permalink
Merge 8a27667 into dd79751
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed May 26, 2017
2 parents dd79751 + 8a27667 commit bd1b16a
Show file tree
Hide file tree
Showing 119 changed files with 590 additions and 685 deletions.
2 changes: 1 addition & 1 deletion .travis/check-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

go generate gonum.org/v1/gonum/matrix
go generate gonum.org/v1/gonum/blas/native
go generate gonum.org/v1/gonum/lapack/native
go generate gonum.org/v1/gonum/lapack
if [ -n "$(git diff)" ]; then
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

// +build noasm appengine

package native
package lapack_test

func init() { appengine = true }
2 changes: 1 addition & 1 deletion lapack/native/bench_test.go → lapack/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// +build go1.7

package native
package lapack_test

import (
"testing"
Expand Down
31 changes: 15 additions & 16 deletions lapack/native/dbdsqr.go → lapack/dbdsqr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package native
package lapack

import (
"math"

"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
"gonum.org/v1/gonum/lapack"
)

// Dbdsqr performs a singular value decomposition of a real n×n bidiagonal matrix.
Expand Down Expand Up @@ -108,10 +107,10 @@ func (impl Implementation) Dbdsqr(uplo blas.Uplo, n, ncvt, nru, ncc int, d, e, v
work[nm1+i] = sn
}
if nru > 0 {
impl.Dlasr(blas.Right, lapack.Variable, lapack.Forward, nru, n, work, work[n-1:], u, ldu)
impl.Dlasr(blas.Right, Variable, Forward, nru, n, work, work[n-1:], u, ldu)
}
if ncc > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Forward, n, ncc, work, work[n-1:], c, ldc)
impl.Dlasr(blas.Left, Variable, Forward, n, ncc, work, work[n-1:], c, ldc)
}
}
// Compute singular values to a relative accuracy of tol. If tol is negative
Expand Down Expand Up @@ -313,13 +312,13 @@ func (impl Implementation) Dbdsqr(uplo blas.Uplo, n, ncvt, nru, ncc int, d, e, v
d[m-1] = h * oldcs
e[m-2] = h * oldsn
if ncvt > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Forward, m-l2, ncvt, work, work[n-1:], vt[l2*ldvt:], ldvt)
impl.Dlasr(blas.Left, Variable, Forward, m-l2, ncvt, work, work[n-1:], vt[l2*ldvt:], ldvt)
}
if nru > 0 {
impl.Dlasr(blas.Right, lapack.Variable, lapack.Forward, nru, m-l2, work[nm12:], work[nm13:], u[l2:], ldu)
impl.Dlasr(blas.Right, Variable, Forward, nru, m-l2, work[nm12:], work[nm13:], u[l2:], ldu)
}
if ncc > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Forward, m-l2, ncc, work[nm12:], work[nm13:], c[l2*ldc:], ldc)
impl.Dlasr(blas.Left, Variable, Forward, m-l2, ncc, work[nm12:], work[nm13:], c[l2*ldc:], ldc)
}
if math.Abs(e[m-2]) < thresh {
e[m-2] = 0
Expand All @@ -343,13 +342,13 @@ func (impl Implementation) Dbdsqr(uplo blas.Uplo, n, ncvt, nru, ncc int, d, e, v
d[l2] = h * oldcs
e[l2] = h * oldsn
if ncvt > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Backward, m-l2, ncvt, work[nm12:], work[nm13:], vt[l2*ldvt:], ldvt)
impl.Dlasr(blas.Left, Variable, Backward, m-l2, ncvt, work[nm12:], work[nm13:], vt[l2*ldvt:], ldvt)
}
if nru > 0 {
impl.Dlasr(blas.Right, lapack.Variable, lapack.Backward, nru, m-l2, work, work[n-1:], u[l2:], ldu)
impl.Dlasr(blas.Right, Variable, Backward, nru, m-l2, work, work[n-1:], u[l2:], ldu)
}
if ncc > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Backward, m-l2, ncc, work, work[n-1:], c[l2*ldc:], ldc)
impl.Dlasr(blas.Left, Variable, Backward, m-l2, ncc, work, work[n-1:], c[l2*ldc:], ldc)
}
if math.Abs(e[l2]) <= thresh {
e[l2] = 0
Expand Down Expand Up @@ -387,13 +386,13 @@ func (impl Implementation) Dbdsqr(uplo blas.Uplo, n, ncvt, nru, ncc int, d, e, v
}
e[m-2] = f
if ncvt > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Forward, m-l2, ncvt, work, work[n-1:], vt[l2*ldvt:], ldvt)
impl.Dlasr(blas.Left, Variable, Forward, m-l2, ncvt, work, work[n-1:], vt[l2*ldvt:], ldvt)
}
if nru > 0 {
impl.Dlasr(blas.Right, lapack.Variable, lapack.Forward, nru, m-l2, work[nm12:], work[nm13:], u[l2:], ldu)
impl.Dlasr(blas.Right, Variable, Forward, nru, m-l2, work[nm12:], work[nm13:], u[l2:], ldu)
}
if ncc > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Forward, m-l2, ncc, work[nm12:], work[nm13:], c[l2*ldc:], ldc)
impl.Dlasr(blas.Left, Variable, Forward, m-l2, ncc, work[nm12:], work[nm13:], c[l2*ldc:], ldc)
}
if math.Abs(e[m-2]) <= thresh {
e[m-2] = 0
Expand Down Expand Up @@ -430,13 +429,13 @@ func (impl Implementation) Dbdsqr(uplo blas.Uplo, n, ncvt, nru, ncc int, d, e, v
e[l2] = 0
}
if ncvt > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Backward, m-l2, ncvt, work[nm12:], work[nm13:], vt[l2*ldvt:], ldvt)
impl.Dlasr(blas.Left, Variable, Backward, m-l2, ncvt, work[nm12:], work[nm13:], vt[l2*ldvt:], ldvt)
}
if nru > 0 {
impl.Dlasr(blas.Right, lapack.Variable, lapack.Backward, nru, m-l2, work, work[n-1:], u[l2:], ldu)
impl.Dlasr(blas.Right, Variable, Backward, nru, m-l2, work, work[n-1:], u[l2:], ldu)
}
if ncc > 0 {
impl.Dlasr(blas.Left, lapack.Variable, lapack.Backward, m-l2, ncc, work, work[n-1:], c[l2*ldc:], ldc)
impl.Dlasr(blas.Left, Variable, Backward, m-l2, ncc, work, work[n-1:], c[l2*ldc:], ldc)
}
}
}
Expand Down
25 changes: 11 additions & 14 deletions lapack/native/dgebak.go → lapack/dgebak.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package native
package lapack

import (
"gonum.org/v1/gonum/blas/blas64"
"gonum.org/v1/gonum/lapack"
)
import "gonum.org/v1/gonum/blas/blas64"

// Dgebak updates an n×m matrix V as
// V = P D V, if side == lapack.RightEV,
// V = P D^{-1} V, if side == lapack.LeftEV,
// V = P D V, if side == RightEV,
// V = P D^{-1} V, if side == LeftEV,
// where P and D are n×n permutation and scaling matrices, respectively,
// implicitly represented by job, scale, ilo and ihi as returned by Dgebal.
//
Expand All @@ -20,16 +17,16 @@ import (
// the eigenvectors of the original matrix.
//
// Dgebak is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dgebak(job lapack.Job, side lapack.EVSide, n, ilo, ihi int, scale []float64, m int, v []float64, ldv int) {
func (impl Implementation) Dgebak(job Job, side EVSide, n, ilo, ihi int, scale []float64, m int, v []float64, ldv int) {
switch job {
default:
panic(badJob)
case lapack.None, lapack.Permute, lapack.Scale, lapack.PermuteScale:
case None, Permute, Scale, PermuteScale:
}
switch side {
default:
panic(badSide)
case lapack.LeftEV, lapack.RightEV:
case LeftEV, RightEV:
}
checkMatrix(n, m, v, ldv)
switch {
Expand All @@ -40,14 +37,14 @@ func (impl Implementation) Dgebak(job lapack.Job, side lapack.EVSide, n, ilo, ih
}

// Quick return if possible.
if n == 0 || m == 0 || job == lapack.None {
if n == 0 || m == 0 || job == None {
return
}

bi := blas64.Implementation()
if ilo != ihi && job != lapack.Permute {
if ilo != ihi && job != Permute {
// Backward balance.
if side == lapack.RightEV {
if side == RightEV {
for i := ilo; i <= ihi; i++ {
bi.Dscal(m, scale[i], v[i*ldv:], 1)
}
Expand All @@ -57,7 +54,7 @@ func (impl Implementation) Dgebak(job lapack.Job, side lapack.EVSide, n, ilo, ih
}
}
}
if job == lapack.Scale {
if job == Scale {
return
}
// Backward permutation.
Expand Down
25 changes: 12 additions & 13 deletions lapack/native/dgebal.go → lapack/dgebal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package native
package lapack

import (
"math"

"gonum.org/v1/gonum/blas/blas64"
"gonum.org/v1/gonum/lapack"
)

// Dgebal balances an n×n matrix A. Balancing consists of two stages, permuting
Expand All @@ -35,14 +34,14 @@ import (
// the computed eigenvalues and/or eigenvectors.
//
// job specifies the operations that will be performed on A.
// If job is lapack.None, Dgebal sets scale[i] = 1 for all i and returns ilo=0, ihi=n-1.
// If job is lapack.Permute, only permuting will be done.
// If job is lapack.Scale, only scaling will be done.
// If job is lapack.PermuteScale, both permuting and scaling will be done.
// If job is None, Dgebal sets scale[i] = 1 for all i and returns ilo=0, ihi=n-1.
// If job is Permute, only permuting will be done.
// If job is Scale, only scaling will be done.
// If job is PermuteScale, both permuting and scaling will be done.
//
// On return, if job is lapack.Permute or lapack.PermuteScale, it will hold that
// On return, if job is Permute or PermuteScale, it will hold that
// A[i,j] == 0, for i > j and j ∈ {0, ..., ilo-1, ihi+1, ..., n-1}.
// If job is lapack.None or lapack.Scale, or if n == 0, it will hold that
// If job is None or Scale, or if n == 0, it will hold that
// ilo == 0 and ihi == n-1.
//
// On return, scale will contain information about the permutations and scaling
Expand All @@ -54,11 +53,11 @@ import (
// scale must have length equal to n, otherwise Dgebal will panic.
//
// Dgebal is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dgebal(job lapack.Job, n int, a []float64, lda int, scale []float64) (ilo, ihi int) {
func (impl Implementation) Dgebal(job Job, n int, a []float64, lda int, scale []float64) (ilo, ihi int) {
switch job {
default:
panic(badJob)
case lapack.None, lapack.Permute, lapack.Scale, lapack.PermuteScale:
case None, Permute, Scale, PermuteScale:
}
checkMatrix(n, n, a, lda)
if len(scale) != n {
Expand All @@ -68,7 +67,7 @@ func (impl Implementation) Dgebal(job lapack.Job, n int, a []float64, lda int, s
ilo = 0
ihi = n - 1

if n == 0 || job == lapack.None {
if n == 0 || job == None {
for i := range scale {
scale[i] = 1
}
Expand All @@ -78,7 +77,7 @@ func (impl Implementation) Dgebal(job lapack.Job, n int, a []float64, lda int, s
bi := blas64.Implementation()
swapped := true

if job == lapack.Scale {
if job == Scale {
goto scaling
}

Expand Down Expand Up @@ -145,7 +144,7 @@ scaling:
scale[i] = 1
}

if job == lapack.Permute {
if job == Permute {
return ilo, ihi
}

Expand Down
2 changes: 1 addition & 1 deletion lapack/native/dgebd2.go → lapack/dgebd2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package native
package lapack

import "gonum.org/v1/gonum/blas"

Expand Down
2 changes: 1 addition & 1 deletion lapack/native/dgebrd.go → lapack/dgebrd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package native
package lapack

import (
"gonum.org/v1/gonum/blas"
Expand Down
9 changes: 4 additions & 5 deletions lapack/native/dgecon.go → lapack/dgecon.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package native
package lapack

import (
"math"

"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
"gonum.org/v1/gonum/lapack"
)

// Dgecon estimates the reciprocal of the condition number of the n×n matrix A
Expand All @@ -23,9 +22,9 @@ import (
// work is a temporary data slice of length at least 4*n and Dgecon will panic otherwise.
//
// iwork is a temporary data slice of length at least n and Dgecon will panic otherwise.
func (impl Implementation) Dgecon(norm lapack.MatrixNorm, n int, a []float64, lda int, anorm float64, work []float64, iwork []int) float64 {
func (impl Implementation) Dgecon(norm MatrixNorm, n int, a []float64, lda int, anorm float64, work []float64, iwork []int) float64 {
checkMatrix(n, n, a, lda)
if norm != lapack.MaxColumnSum && norm != lapack.MaxRowSum {
if norm != MaxColumnSum && norm != MaxRowSum {
panic(badNorm)
}
if len(work) < 4*n {
Expand All @@ -46,7 +45,7 @@ func (impl Implementation) Dgecon(norm lapack.MatrixNorm, n int, a []float64, ld
var kase int
var normin bool
isave := new([3]int)
onenrm := norm == lapack.MaxColumnSum
onenrm := norm == MaxColumnSum
smlnum := dlamchS
kase1 := 2
if onenrm {
Expand Down
Loading

0 comments on commit bd1b16a

Please sign in to comment.