mirror of
https://github.com/gonum/gonum.git
synced 2025-10-20 13:55:20 +08:00
testlapack: make tests independent
This commit is contained in:
@@ -20,6 +20,7 @@ type Dbdsqrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DbdsqrTest(t *testing.T, impl Dbdsqrer) {
|
func DbdsqrTest(t *testing.T, impl Dbdsqrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
_ = bi
|
_ = bi
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
||||||
@@ -58,11 +59,11 @@ func DbdsqrTest(t *testing.T, impl Dbdsqrer) {
|
|||||||
|
|
||||||
d := make([]float64, n)
|
d := make([]float64, n)
|
||||||
for i := range d {
|
for i := range d {
|
||||||
d[i] = rand.NormFloat64()
|
d[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
e := make([]float64, n-1)
|
e := make([]float64, n-1)
|
||||||
for i := range e {
|
for i := range e {
|
||||||
e[i] = rand.NormFloat64()
|
e[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
dCopy := make([]float64, len(d))
|
dCopy := make([]float64, len(d))
|
||||||
copy(dCopy, d)
|
copy(dCopy, d)
|
||||||
@@ -70,7 +71,7 @@ func DbdsqrTest(t *testing.T, impl Dbdsqrer) {
|
|||||||
copy(eCopy, e)
|
copy(eCopy, e)
|
||||||
work := make([]float64, 4*n)
|
work := make([]float64, 4*n)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.NormFloat64()
|
work[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// First test the decomposition of the bidiagonal matrix. Set
|
// First test the decomposition of the bidiagonal matrix. Set
|
||||||
@@ -141,19 +142,19 @@ func DbdsqrTest(t *testing.T, impl Dbdsqrer) {
|
|||||||
|
|
||||||
u := make([]float64, nru*ldu)
|
u := make([]float64, nru*ldu)
|
||||||
for i := range u {
|
for i := range u {
|
||||||
u[i] = rand.NormFloat64()
|
u[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
uCopy := make([]float64, len(u))
|
uCopy := make([]float64, len(u))
|
||||||
copy(uCopy, u)
|
copy(uCopy, u)
|
||||||
vt := make([]float64, n*ldvt)
|
vt := make([]float64, n*ldvt)
|
||||||
for i := range vt {
|
for i := range vt {
|
||||||
vt[i] = rand.NormFloat64()
|
vt[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
vtCopy := make([]float64, len(vt))
|
vtCopy := make([]float64, len(vt))
|
||||||
copy(vtCopy, vt)
|
copy(vtCopy, vt)
|
||||||
c := make([]float64, n*ldc)
|
c := make([]float64, n*ldc)
|
||||||
for i := range c {
|
for i := range c {
|
||||||
c[i] = rand.NormFloat64()
|
c[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
cCopy := make([]float64, len(c))
|
cCopy := make([]float64, len(c))
|
||||||
copy(cCopy, c)
|
copy(cCopy, c)
|
||||||
|
@@ -14,6 +14,7 @@ type Dgebd2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dgebd2Test(t *testing.T, impl Dgebd2er) {
|
func Dgebd2Test(t *testing.T, impl Dgebd2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -31,7 +32,7 @@ func Dgebd2Test(t *testing.T, impl Dgebd2er) {
|
|||||||
nb := min(m, n) // 'nb' name parallel with Dlabrd code.
|
nb := min(m, n) // 'nb' name parallel with Dlabrd code.
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
d := nanSlice(nb)
|
d := nanSlice(nb)
|
||||||
e := nanSlice(nb - 1)
|
e := nanSlice(nb - 1)
|
||||||
|
@@ -18,6 +18,7 @@ type Dgebrder interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgebrdTest(t *testing.T, impl Dgebrder) {
|
func DgebrdTest(t *testing.T, impl Dgebrder) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -44,7 +45,7 @@ func DgebrdTest(t *testing.T, impl Dgebrder) {
|
|||||||
minmn := min(m, n)
|
minmn := min(m, n)
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
d := make([]float64, minmn)
|
d := make([]float64, minmn)
|
||||||
|
@@ -19,6 +19,7 @@ type Dgelq2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dgelq2Test(t *testing.T, impl Dgelq2er) {
|
func Dgelq2Test(t *testing.T, impl Dgelq2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for c, test := range []struct {
|
for c, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -52,15 +53,15 @@ func Dgelq2Test(t *testing.T, impl Dgelq2er) {
|
|||||||
k := min(m, n)
|
k := min(m, n)
|
||||||
tau := make([]float64, k)
|
tau := make([]float64, k)
|
||||||
for i := range tau {
|
for i := range tau {
|
||||||
tau[i] = rand.Float64()
|
tau[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
work := make([]float64, m)
|
work := make([]float64, m)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := 0; i < m*lda; i++ {
|
for i := 0; i < m*lda; i++ {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -17,6 +17,7 @@ type Dgelqfer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgelqfTest(t *testing.T, impl Dgelqfer) {
|
func DgelqfTest(t *testing.T, impl Dgelqfer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for c, test := range []struct {
|
for c, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -50,12 +51,12 @@ func DgelqfTest(t *testing.T, impl Dgelqfer) {
|
|||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := 0; i < m; i++ {
|
for i := 0; i < m; i++ {
|
||||||
for j := 0; j < n; j++ {
|
for j := 0; j < n; j++ {
|
||||||
a[i*lda+j] = rand.Float64()
|
a[i*lda+j] = rnd.Float64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tau := make([]float64, n)
|
tau := make([]float64, n)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
tau[i] = rand.Float64()
|
tau[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
@@ -63,7 +64,7 @@ func DgelqfTest(t *testing.T, impl Dgelqfer) {
|
|||||||
copy(ans, a)
|
copy(ans, a)
|
||||||
work := make([]float64, m)
|
work := make([]float64, m)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
// Compute unblocked QR.
|
// Compute unblocked QR.
|
||||||
impl.Dgelq2(m, n, ans, lda, tau, work)
|
impl.Dgelq2(m, n, ans, lda, tau, work)
|
||||||
|
@@ -18,6 +18,7 @@ type Dgelser interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgelsTest(t *testing.T, impl Dgelser) {
|
func DgelsTest(t *testing.T, impl Dgelser) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, nrhs, lda, ldb int
|
m, n, nrhs, lda, ldb int
|
||||||
@@ -69,7 +70,7 @@ func DgelsTest(t *testing.T, impl Dgelser) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
@@ -84,7 +85,7 @@ func DgelsTest(t *testing.T, impl Dgelser) {
|
|||||||
}
|
}
|
||||||
b := make([]float64, mb*ldb)
|
b := make([]float64, mb*ldb)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = rand.Float64()
|
b[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
bCopy := make([]float64, len(b))
|
bCopy := make([]float64, len(b))
|
||||||
copy(bCopy, b)
|
copy(bCopy, b)
|
||||||
@@ -97,7 +98,7 @@ func DgelsTest(t *testing.T, impl Dgelser) {
|
|||||||
work = make([]float64, int(work[0]))
|
work = make([]float64, int(work[0]))
|
||||||
lwork := len(work)
|
lwork := len(work)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
impl.Dgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork)
|
impl.Dgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork)
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ type Dgeql2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dgeql2Test(t *testing.T, impl Dgeql2er) {
|
func Dgeql2Test(t *testing.T, impl Dgeql2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// TODO(btracey): Add tests for m < n.
|
// TODO(btracey): Add tests for m < n.
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
@@ -34,7 +35,7 @@ func Dgeql2Test(t *testing.T, impl Dgeql2er) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
tau := nanSlice(min(m, n))
|
tau := nanSlice(min(m, n))
|
||||||
work := nanSlice(n)
|
work := nanSlice(n)
|
||||||
|
@@ -19,6 +19,7 @@ type Dgeqr2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dgeqr2Test(t *testing.T, impl Dgeqr2er) {
|
func Dgeqr2Test(t *testing.T, impl Dgeqr2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for c, test := range []struct {
|
for c, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -51,17 +52,17 @@ func Dgeqr2Test(t *testing.T, impl Dgeqr2er) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
k := min(m, n)
|
k := min(m, n)
|
||||||
tau := make([]float64, k)
|
tau := make([]float64, k)
|
||||||
for i := range tau {
|
for i := range tau {
|
||||||
tau[i] = rand.Float64()
|
tau[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
work := make([]float64, n)
|
work := make([]float64, n)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
impl.Dgeqr2(m, n, a, lda, tau, work)
|
impl.Dgeqr2(m, n, a, lda, tau, work)
|
||||||
|
@@ -17,6 +17,7 @@ type Dgeqrfer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgeqrfTest(t *testing.T, impl Dgeqrfer) {
|
func DgeqrfTest(t *testing.T, impl Dgeqrfer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for c, test := range []struct {
|
for c, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -50,12 +51,12 @@ func DgeqrfTest(t *testing.T, impl Dgeqrfer) {
|
|||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := 0; i < m; i++ {
|
for i := 0; i < m; i++ {
|
||||||
for j := 0; j < n; j++ {
|
for j := 0; j < n; j++ {
|
||||||
a[i*lda+j] = rand.Float64()
|
a[i*lda+j] = rnd.Float64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tau := make([]float64, n)
|
tau := make([]float64, n)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
tau[i] = rand.Float64()
|
tau[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -20,6 +20,7 @@ type Dgesvder interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgesvdTest(t *testing.T, impl Dgesvder) {
|
func DgesvdTest(t *testing.T, impl Dgesvder) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// TODO(btracey): Add tests for all of the cases when the SVD implementation
|
// TODO(btracey): Add tests for all of the cases when the SVD implementation
|
||||||
// is finished.
|
// is finished.
|
||||||
// TODO(btracey): Add tests for m > mnthr and n > mnthr when other SVD
|
// TODO(btracey): Add tests for m > mnthr and n > mnthr when other SVD
|
||||||
@@ -73,17 +74,17 @@ func DgesvdTest(t *testing.T, impl Dgesvder) {
|
|||||||
|
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
u := make([]float64, m*ldu)
|
u := make([]float64, m*ldu)
|
||||||
for i := range u {
|
for i := range u {
|
||||||
u[i] = rand.NormFloat64()
|
u[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
vt := make([]float64, n*ldvt)
|
vt := make([]float64, n*ldvt)
|
||||||
for i := range vt {
|
for i := range vt {
|
||||||
vt[i] = rand.NormFloat64()
|
vt[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
uAllOrig := make([]float64, len(u))
|
uAllOrig := make([]float64, len(u))
|
||||||
@@ -125,6 +126,7 @@ func DgesvdTest(t *testing.T, impl Dgesvder) {
|
|||||||
// svdCheckPartial checks that the singular values and vectors are computed when
|
// svdCheckPartial checks that the singular values and vectors are computed when
|
||||||
// not all of them are computed.
|
// not all of them are computed.
|
||||||
func svdCheckPartial(t *testing.T, impl Dgesvder, job lapack.SVDJob, errStr string, uAllOrig, vtAllOrig, aCopy []float64, m, n int, a []float64, lda int, s, u []float64, ldu int, vt []float64, ldvt int, work []float64, shortWork bool) {
|
func svdCheckPartial(t *testing.T, impl Dgesvder, job lapack.SVDJob, errStr string, uAllOrig, vtAllOrig, aCopy []float64, m, n int, a []float64, lda int, s, u []float64, ldu int, vt []float64, ldvt int, work []float64, shortWork bool) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
jobU := job
|
jobU := job
|
||||||
jobVT := job
|
jobVT := job
|
||||||
// Compare the singular values when computed with {SVDNone, SVDNone.}
|
// Compare the singular values when computed with {SVDNone, SVDNone.}
|
||||||
@@ -132,7 +134,7 @@ func svdCheckPartial(t *testing.T, impl Dgesvder, job lapack.SVDJob, errStr stri
|
|||||||
copy(sCopy, s)
|
copy(sCopy, s)
|
||||||
copy(a, aCopy)
|
copy(a, aCopy)
|
||||||
for i := range s {
|
for i := range s {
|
||||||
s[i] = rand.Float64()
|
s[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
tmp1 := make([]float64, 1)
|
tmp1 := make([]float64, 1)
|
||||||
tmp2 := make([]float64, 1)
|
tmp2 := make([]float64, 1)
|
||||||
@@ -167,7 +169,7 @@ func svdCheckPartial(t *testing.T, impl Dgesvder, job lapack.SVDJob, errStr stri
|
|||||||
jobVT = lapack.SVDNone
|
jobVT = lapack.SVDNone
|
||||||
copy(a, aCopy)
|
copy(a, aCopy)
|
||||||
for i := range s {
|
for i := range s {
|
||||||
s[i] = rand.Float64()
|
s[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
impl.Dgesvd(jobU, jobVT, m, n, a, lda, s, u, ldu, tmp2, ldvt, work, -1)
|
impl.Dgesvd(jobU, jobVT, m, n, a, lda, s, u, ldu, tmp2, ldvt, work, -1)
|
||||||
work = make([]float64, int(work[0]))
|
work = make([]float64, int(work[0]))
|
||||||
@@ -186,7 +188,7 @@ func svdCheckPartial(t *testing.T, impl Dgesvder, job lapack.SVDJob, errStr stri
|
|||||||
jobVT = job
|
jobVT = job
|
||||||
copy(a, aCopy)
|
copy(a, aCopy)
|
||||||
for i := range s {
|
for i := range s {
|
||||||
s[i] = rand.Float64()
|
s[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
impl.Dgesvd(jobU, jobVT, m, n, a, lda, s, tmp1, ldu, vt, ldvt, work, -1)
|
impl.Dgesvd(jobU, jobVT, m, n, a, lda, s, tmp1, ldu, vt, ldvt, work, -1)
|
||||||
work = make([]float64, int(work[0]))
|
work = make([]float64, int(work[0]))
|
||||||
@@ -281,5 +283,4 @@ func svdCheck(t *testing.T, thin bool, errStr string, m, n int, s, a, u []float6
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@ type Dgetf2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dgetf2Test(t *testing.T, impl Dgetf2er) {
|
func Dgetf2Test(t *testing.T, impl Dgetf2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -33,7 +34,7 @@ func Dgetf2Test(t *testing.T, impl Dgetf2er) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
@@ -41,7 +42,7 @@ func Dgetf2Test(t *testing.T, impl Dgetf2er) {
|
|||||||
mn := min(m, n)
|
mn := min(m, n)
|
||||||
ipiv := make([]int, mn)
|
ipiv := make([]int, mn)
|
||||||
for i := range ipiv {
|
for i := range ipiv {
|
||||||
ipiv[i] = rand.Int()
|
ipiv[i] = rnd.Int()
|
||||||
}
|
}
|
||||||
ok := impl.Dgetf2(m, n, a, lda, ipiv)
|
ok := impl.Dgetf2(m, n, a, lda, ipiv)
|
||||||
checkPLU(t, ok, m, n, lda, ipiv, a, aCopy, 1e-14, true)
|
checkPLU(t, ok, m, n, lda, ipiv, a, aCopy, 1e-14, true)
|
||||||
|
@@ -10,6 +10,7 @@ type Dgetrfer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgetrfTest(t *testing.T, impl Dgetrfer) {
|
func DgetrfTest(t *testing.T, impl Dgetrfer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -42,12 +43,12 @@ func DgetrfTest(t *testing.T, impl Dgetrfer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
mn := min(m, n)
|
mn := min(m, n)
|
||||||
ipiv := make([]int, mn)
|
ipiv := make([]int, mn)
|
||||||
for i := range ipiv {
|
for i := range ipiv {
|
||||||
ipiv[i] = rand.Int()
|
ipiv[i] = rnd.Int()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cannot compare the outputs of Dgetrf and Dgetf2 because the pivoting may
|
// Cannot compare the outputs of Dgetrf and Dgetf2 because the pivoting may
|
||||||
|
@@ -15,6 +15,7 @@ type Dgetrier interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgetriTest(t *testing.T, impl Dgetrier) {
|
func DgetriTest(t *testing.T, impl Dgetrier) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
n, lda int
|
n, lda int
|
||||||
@@ -34,13 +35,13 @@ func DgetriTest(t *testing.T, impl Dgetrier) {
|
|||||||
lda = n
|
lda = n
|
||||||
}
|
}
|
||||||
// Generate a random well conditioned matrix
|
// Generate a random well conditioned matrix
|
||||||
perm := rand.Perm(n)
|
perm := rnd.Perm(n)
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
a[i*lda+perm[i]] = 1
|
a[i*lda+perm[i]] = 1
|
||||||
}
|
}
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] += 0.01 * rand.Float64()
|
a[i] += 0.01 * rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -15,6 +15,7 @@ type Dgetrser interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DgetrsTest(t *testing.T, impl Dgetrser) {
|
func DgetrsTest(t *testing.T, impl Dgetrser) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// TODO(btracey): Put more thought into creating more regularized matrices
|
// TODO(btracey): Put more thought into creating more regularized matrices
|
||||||
// and what correct tolerances should be. Consider also seeding the random
|
// and what correct tolerances should be. Consider also seeding the random
|
||||||
// number in this test to make it more robust to code changes in other
|
// number in this test to make it more robust to code changes in other
|
||||||
@@ -52,11 +53,11 @@ func DgetrsTest(t *testing.T, impl Dgetrser) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
b := make([]float64, n*ldb)
|
b := make([]float64, n*ldb)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = rand.Float64()
|
b[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
@@ -65,7 +66,7 @@ func DgetrsTest(t *testing.T, impl Dgetrser) {
|
|||||||
|
|
||||||
ipiv := make([]int, n)
|
ipiv := make([]int, n)
|
||||||
for i := range ipiv {
|
for i := range ipiv {
|
||||||
ipiv[i] = rand.Int()
|
ipiv[i] = rnd.Int()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the LU factorization.
|
// Compute the LU factorization.
|
||||||
|
@@ -15,6 +15,7 @@ type Dlabrder interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlabrdTest(t *testing.T, impl Dlabrder) {
|
func DlabrdTest(t *testing.T, impl Dlabrder) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, nb, lda, ldx, ldy int
|
m, n, nb, lda, ldx, ldy int
|
||||||
}{
|
}{
|
||||||
@@ -63,7 +64,7 @@ func DlabrdTest(t *testing.T, impl Dlabrder) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
d := make([]float64, nb)
|
d := make([]float64, nb)
|
||||||
for i := range d {
|
for i := range d {
|
||||||
@@ -83,11 +84,11 @@ func DlabrdTest(t *testing.T, impl Dlabrder) {
|
|||||||
}
|
}
|
||||||
x := make([]float64, m*ldx)
|
x := make([]float64, m*ldx)
|
||||||
for i := range x {
|
for i := range x {
|
||||||
x[i] = rand.NormFloat64()
|
x[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
y := make([]float64, n*ldy)
|
y := make([]float64, n*ldy)
|
||||||
for i := range y {
|
for i := range y {
|
||||||
y[i] = rand.NormFloat64()
|
y[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -13,6 +13,7 @@ type Dlacpyer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlacpyTest(t *testing.T, impl Dlacpyer) {
|
func DlacpyTest(t *testing.T, impl Dlacpyer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower, blas.All} {
|
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower, blas.All} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda, ldb int
|
m, n, lda, ldb int
|
||||||
@@ -37,11 +38,11 @@ func DlacpyTest(t *testing.T, impl Dlacpyer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
b := make([]float64, m*ldb)
|
b := make([]float64, m*ldb)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = rand.Float64()
|
b[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
impl.Dlacpy(uplo, m, n, a, lda, b, ldb)
|
impl.Dlacpy(uplo, m, n, a, lda, b, ldb)
|
||||||
equal := true
|
equal := true
|
||||||
|
@@ -11,10 +11,11 @@ type Dlaev2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dlaev2Test(t *testing.T, impl Dlaev2er) {
|
func Dlaev2Test(t *testing.T, impl Dlaev2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for trial := 0; trial < 100; trial++ {
|
for trial := 0; trial < 100; trial++ {
|
||||||
a := rand.NormFloat64()
|
a := rnd.NormFloat64()
|
||||||
b := rand.NormFloat64()
|
b := rnd.NormFloat64()
|
||||||
c := rand.NormFloat64()
|
c := rnd.NormFloat64()
|
||||||
|
|
||||||
rt1, rt2, cs1, sn1 := impl.Dlaev2(a, b, c)
|
rt1, rt2, cs1, sn1 := impl.Dlaev2(a, b, c)
|
||||||
tmp := mul2by2([2][2]float64{{cs1, sn1}, {-sn1, cs1}}, [2][2]float64{{a, b}, {b, c}})
|
tmp := mul2by2([2][2]float64{{cs1, sn1}, {-sn1, cs1}}, [2][2]float64{{a, b}, {b, c}})
|
||||||
|
@@ -18,6 +18,7 @@ type Dlanger interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlangeTest(t *testing.T, impl Dlanger) {
|
func DlangeTest(t *testing.T, impl Dlanger) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -34,11 +35,11 @@ func DlangeTest(t *testing.T, impl Dlanger) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = (rand.Float64() - 0.5)
|
a[i] = rnd.Float64() - 0.5
|
||||||
}
|
}
|
||||||
work := make([]float64, n)
|
work := make([]float64, n)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -18,16 +18,17 @@ type Dlanster interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlanstTest(t *testing.T, impl Dlanster) {
|
func DlanstTest(t *testing.T, impl Dlanster) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
||||||
for _, n := range []int{1, 3, 10, 100} {
|
for _, n := range []int{1, 3, 10, 100} {
|
||||||
for cas := 0; cas < 100; cas++ {
|
for cas := 0; cas < 100; cas++ {
|
||||||
d := make([]float64, n)
|
d := make([]float64, n)
|
||||||
for i := range d {
|
for i := range d {
|
||||||
d[i] = rand.NormFloat64()
|
d[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
e := make([]float64, n-1)
|
e := make([]float64, n-1)
|
||||||
for i := range e {
|
for i := range e {
|
||||||
e[i] = rand.NormFloat64()
|
e[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
m := n
|
m := n
|
||||||
|
@@ -15,6 +15,7 @@ type Dlansyer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlansyTest(t *testing.T, impl Dlansyer) {
|
func DlansyTest(t *testing.T, impl Dlansyer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
||||||
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
@@ -39,7 +40,7 @@ func DlansyTest(t *testing.T, impl Dlansyer) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ type Dlantrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlantrTest(t *testing.T, impl Dlantrer) {
|
func DlantrTest(t *testing.T, impl Dlantrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
for _, norm := range []lapack.MatrixNorm{lapack.MaxAbs, lapack.MaxColumnSum, lapack.MaxRowSum, lapack.NormFrob} {
|
||||||
for _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
|
for _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
|
||||||
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
||||||
@@ -44,7 +45,7 @@ func DlantrTest(t *testing.T, impl Dlantrer) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aDense := make([]float64, len(a))
|
aDense := make([]float64, len(a))
|
||||||
@@ -68,7 +69,7 @@ func DlantrTest(t *testing.T, impl Dlantrer) {
|
|||||||
}
|
}
|
||||||
work := make([]float64, n+6)
|
work := make([]float64, n+6)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
got := impl.Dlantr(norm, uplo, diag, m, n, a, lda, work)
|
got := impl.Dlantr(norm, uplo, diag, m, n, a, lda, work)
|
||||||
want := impl.Dlange(norm, m, n, aDense, lda, work)
|
want := impl.Dlange(norm, m, n, aDense, lda, work)
|
||||||
|
@@ -18,6 +18,7 @@ type Dlarfer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlarfTest(t *testing.T, impl Dlarfer) {
|
func DlarfTest(t *testing.T, impl Dlarfer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
m, n, ldc int
|
m, n, ldc int
|
||||||
incv, lastv int
|
incv, lastv int
|
||||||
@@ -94,7 +95,7 @@ func DlarfTest(t *testing.T, impl Dlarfer) {
|
|||||||
c := make([]float64, test.ldc*test.m)
|
c := make([]float64, test.ldc*test.m)
|
||||||
for i := 0; i <= test.lastr; i++ {
|
for i := 0; i <= test.lastr; i++ {
|
||||||
for j := 0; j <= test.lastc; j++ {
|
for j := 0; j <= test.lastc; j++ {
|
||||||
c[i*test.ldc+j] = rand.Float64()
|
c[i*test.ldc+j] = rnd.Float64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cCopy := make([]float64, len(c))
|
cCopy := make([]float64, len(c))
|
||||||
@@ -107,7 +108,7 @@ func DlarfTest(t *testing.T, impl Dlarfer) {
|
|||||||
v := make([]float64, test.incv*sz+1)
|
v := make([]float64, test.incv*sz+1)
|
||||||
// Fill with nonzero entries up until lastv.
|
// Fill with nonzero entries up until lastv.
|
||||||
for i := 0; i <= test.lastv; i++ {
|
for i := 0; i <= test.lastv; i++ {
|
||||||
v[i*test.incv] = rand.Float64()
|
v[i*test.incv] = rnd.Float64()
|
||||||
}
|
}
|
||||||
// Construct h explicitly to compare.
|
// Construct h explicitly to compare.
|
||||||
h := make([]float64, test.n*test.n)
|
h := make([]float64, test.n*test.n)
|
||||||
|
@@ -22,6 +22,7 @@ type Dlarfber interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlarfbTest(t *testing.T, impl Dlarfber) {
|
func DlarfbTest(t *testing.T, impl Dlarfber) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, store := range []lapack.StoreV{lapack.ColumnWise, lapack.RowWise} {
|
for _, store := range []lapack.StoreV{lapack.ColumnWise, lapack.RowWise} {
|
||||||
for _, direct := range []lapack.Direct{lapack.Forward, lapack.Backward} {
|
for _, direct := range []lapack.Direct{lapack.Forward, lapack.Backward} {
|
||||||
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
||||||
@@ -61,7 +62,7 @@ func DlarfbTest(t *testing.T, impl Dlarfber) {
|
|||||||
a := make([]float64, ma*lda)
|
a := make([]float64, ma*lda)
|
||||||
for i := 0; i < ma; i++ {
|
for i := 0; i < ma; i++ {
|
||||||
for j := 0; j < lda; j++ {
|
for j := 0; j < lda; j++ {
|
||||||
a[i*lda+j] = rand.Float64()
|
a[i*lda+j] = rnd.Float64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
k := min(ma, na)
|
k := min(ma, na)
|
||||||
@@ -109,7 +110,7 @@ func DlarfbTest(t *testing.T, impl Dlarfber) {
|
|||||||
c := make([]float64, m*ldc)
|
c := make([]float64, m*ldc)
|
||||||
for i := 0; i < m; i++ {
|
for i := 0; i < m; i++ {
|
||||||
for j := 0; j < ldc; j++ {
|
for j := 0; j < ldc; j++ {
|
||||||
c[i*ldc+j] = rand.Float64()
|
c[i*ldc+j] = rnd.Float64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cCopy := make([]float64, len(c))
|
cCopy := make([]float64, len(c))
|
||||||
|
@@ -18,6 +18,7 @@ type Dlarfger interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlarfgTest(t *testing.T, impl Dlarfger) {
|
func DlarfgTest(t *testing.T, impl Dlarfger) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
alpha float64
|
alpha float64
|
||||||
n int
|
n int
|
||||||
@@ -51,7 +52,7 @@ func DlarfgTest(t *testing.T, impl Dlarfger) {
|
|||||||
if test.x == nil {
|
if test.x == nil {
|
||||||
x = make([]float64, n-1)
|
x = make([]float64, n-1)
|
||||||
for i := range x {
|
for i := range x {
|
||||||
x[i] = rand.Float64()
|
x[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
x = make([]float64, n-1)
|
x = make([]float64, n-1)
|
||||||
|
@@ -20,6 +20,7 @@ type Dlarfter interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlarftTest(t *testing.T, impl Dlarfter) {
|
func DlarftTest(t *testing.T, impl Dlarfter) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, store := range []lapack.StoreV{lapack.ColumnWise, lapack.RowWise} {
|
for _, store := range []lapack.StoreV{lapack.ColumnWise, lapack.RowWise} {
|
||||||
for _, direct := range []lapack.Direct{lapack.Forward, lapack.Backward} {
|
for _, direct := range []lapack.Direct{lapack.Forward, lapack.Backward} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
@@ -46,7 +47,7 @@ func DlarftTest(t *testing.T, impl Dlarfter) {
|
|||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := 0; i < m; i++ {
|
for i := 0; i < m; i++ {
|
||||||
for j := 0; j < lda; j++ {
|
for j := 0; j < lda; j++ {
|
||||||
a[i*lda+j] = rand.Float64()
|
a[i*lda+j] = rnd.Float64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use dgeqr2 to find the v vectors
|
// Use dgeqr2 to find the v vectors
|
||||||
@@ -70,7 +71,7 @@ func DlarftTest(t *testing.T, impl Dlarfter) {
|
|||||||
// Find T from the actual function
|
// Find T from the actual function
|
||||||
tm := make([]float64, k*ldt)
|
tm := make([]float64, k*ldt)
|
||||||
for i := range tm {
|
for i := range tm {
|
||||||
tm[i] = 100 + rand.Float64()
|
tm[i] = 100 + rnd.Float64()
|
||||||
}
|
}
|
||||||
// The v data has been put into a.
|
// The v data has been put into a.
|
||||||
impl.Dlarft(direct, store, m, k, v, ldv, tau, tm, ldt)
|
impl.Dlarft(direct, store, m, k, v, ldv, tau, tm, ldt)
|
||||||
|
@@ -15,9 +15,10 @@ type Dlartger interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlartgTest(t *testing.T, impl Dlartger) {
|
func DlartgTest(t *testing.T, impl Dlartger) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
f := rand.NormFloat64()
|
f := rnd.NormFloat64()
|
||||||
g := rand.NormFloat64()
|
g := rnd.NormFloat64()
|
||||||
cs, sn, r := impl.Dlartg(f, g)
|
cs, sn, r := impl.Dlartg(f, g)
|
||||||
|
|
||||||
rTest := cs*f + sn*g
|
rTest := cs*f + sn*g
|
||||||
|
@@ -28,6 +28,7 @@ type Dlasq1er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dlasq1Test(t *testing.T, impl Dlasq1er) {
|
func Dlasq1Test(t *testing.T, impl Dlasq1er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
// TODO(btracey): Increase the size of this test when we have a more numerically
|
// TODO(btracey): Increase the size of this test when we have a more numerically
|
||||||
// stable way to test the singular values.
|
// stable way to test the singular values.
|
||||||
@@ -37,13 +38,13 @@ func Dlasq1Test(t *testing.T, impl Dlasq1er) {
|
|||||||
e := make([]float64, n-1)
|
e := make([]float64, n-1)
|
||||||
for cas := 0; cas < 1; cas++ {
|
for cas := 0; cas < 1; cas++ {
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
for i := range d {
|
for i := range d {
|
||||||
d[i] = rand.NormFloat64() + 10
|
d[i] = rnd.NormFloat64() + 10
|
||||||
}
|
}
|
||||||
for i := range e {
|
for i := range e {
|
||||||
e[i] = rand.NormFloat64()
|
e[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
ldm := n
|
ldm := n
|
||||||
m := make([]float64, n*ldm)
|
m := make([]float64, n*ldm)
|
||||||
|
@@ -645,6 +645,7 @@ func Dlasq2Test(t *testing.T, impl Dlasq2er) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// Perform a bunch of random tests to check for access out of bounds or
|
// Perform a bunch of random tests to check for access out of bounds or
|
||||||
// infinite loops.
|
// infinite loops.
|
||||||
// TODO(btracey): Implement direct tests.
|
// TODO(btracey): Implement direct tests.
|
||||||
@@ -653,7 +654,7 @@ func Dlasq2Test(t *testing.T, impl Dlasq2er) {
|
|||||||
for k := 0; k < 10; k++ {
|
for k := 0; k < 10; k++ {
|
||||||
z := make([]float64, 4*n)
|
z := make([]float64, 4*n)
|
||||||
for i := range z {
|
for i := range z {
|
||||||
z[i] = rand.Float64()
|
z[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
zCopy := make([]float64, len(z))
|
zCopy := make([]float64, len(z))
|
||||||
copy(zCopy, z)
|
copy(zCopy, z)
|
||||||
|
@@ -20,6 +20,7 @@ type Dlasrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlasrTest(t *testing.T, impl Dlasrer) {
|
func DlasrTest(t *testing.T, impl Dlasrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
||||||
for _, pivot := range []lapack.Pivot{lapack.Variable, lapack.Top, lapack.Bottom} {
|
for _, pivot := range []lapack.Pivot{lapack.Variable, lapack.Top, lapack.Bottom} {
|
||||||
for _, direct := range []lapack.Direct{lapack.Forward, lapack.Backward} {
|
for _, direct := range []lapack.Direct{lapack.Forward, lapack.Backward} {
|
||||||
@@ -42,7 +43,7 @@ func DlasrTest(t *testing.T, impl Dlasrer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
var s, c []float64
|
var s, c []float64
|
||||||
if side == blas.Left {
|
if side == blas.Left {
|
||||||
@@ -53,7 +54,7 @@ func DlasrTest(t *testing.T, impl Dlasrer) {
|
|||||||
c = make([]float64, n-1)
|
c = make([]float64, n-1)
|
||||||
}
|
}
|
||||||
for k := range s {
|
for k := range s {
|
||||||
theta := rand.Float64() * 2 * math.Pi
|
theta := rnd.Float64() * 2 * math.Pi
|
||||||
s[k] = math.Sin(theta)
|
s[k] = math.Sin(theta)
|
||||||
c[k] = math.Cos(theta)
|
c[k] = math.Cos(theta)
|
||||||
}
|
}
|
||||||
|
@@ -16,10 +16,11 @@ type Dlasv2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dlasv2Test(t *testing.T, impl Dlasv2er) {
|
func Dlasv2Test(t *testing.T, impl Dlasv2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
f := rand.NormFloat64()
|
f := rnd.NormFloat64()
|
||||||
g := rand.NormFloat64()
|
g := rnd.NormFloat64()
|
||||||
h := rand.NormFloat64()
|
h := rnd.NormFloat64()
|
||||||
|
|
||||||
ssmin, ssmax, snr, csr, snl, csl := impl.Dlasv2(f, g, h)
|
ssmin, ssmax, snr, csr, snl, csl := impl.Dlasv2(f, g, h)
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ type Dlatrder interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DlatrdTest(t *testing.T, impl Dlatrder) {
|
func DlatrdTest(t *testing.T, impl Dlatrder) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
n, nb, lda, ldw int
|
n, nb, lda, ldw int
|
||||||
@@ -42,7 +43,7 @@ func DlatrdTest(t *testing.T, impl Dlatrder) {
|
|||||||
|
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
e := make([]float64, n-1)
|
e := make([]float64, n-1)
|
||||||
|
@@ -18,6 +18,7 @@ type Dorg2ler interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dorg2lTest(t *testing.T, impl Dorg2ler) {
|
func Dorg2lTest(t *testing.T, impl Dorg2ler) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, k, lda int
|
m, n, k, lda int
|
||||||
}{
|
}{
|
||||||
@@ -36,7 +37,7 @@ func Dorg2lTest(t *testing.T, impl Dorg2ler) {
|
|||||||
|
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
tau := nanSlice(max(m, n))
|
tau := nanSlice(max(m, n))
|
||||||
work := make([]float64, n)
|
work := make([]float64, n)
|
||||||
|
@@ -18,6 +18,7 @@ type Dorg2rer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dorg2rTest(t *testing.T, impl Dorg2rer) {
|
func Dorg2rTest(t *testing.T, impl Dorg2rer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, k, lda int
|
m, n, k, lda int
|
||||||
}{
|
}{
|
||||||
@@ -39,7 +40,7 @@ func Dorg2rTest(t *testing.T, impl Dorg2rer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
k := min(m, n)
|
k := min(m, n)
|
||||||
tau := make([]float64, k)
|
tau := make([]float64, k)
|
||||||
|
@@ -19,6 +19,7 @@ type Dorgbrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DorgbrTest(t *testing.T, impl Dorgbrer) {
|
func DorgbrTest(t *testing.T, impl Dorgbrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, vect := range []lapack.DecompUpdate{lapack.ApplyQ, lapack.ApplyP} {
|
for _, vect := range []lapack.DecompUpdate{lapack.ApplyQ, lapack.ApplyP} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, k, lda int
|
m, n, k, lda int
|
||||||
@@ -89,7 +90,7 @@ func DorgbrTest(t *testing.T, impl Dorgbrer) {
|
|||||||
a = make([]float64, n*lda)
|
a = make([]float64, n*lda)
|
||||||
}
|
}
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
nTau := min(ma, na)
|
nTau := min(ma, na)
|
||||||
|
@@ -17,6 +17,7 @@ type Dorgl2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dorgl2Test(t *testing.T, impl Dorgl2er) {
|
func Dorgl2Test(t *testing.T, impl Dorgl2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, lda int
|
m, n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -34,7 +35,7 @@ func Dorgl2Test(t *testing.T, impl Dorgl2er) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
k := min(m, n)
|
k := min(m, n)
|
||||||
tau := make([]float64, k)
|
tau := make([]float64, k)
|
||||||
|
@@ -18,6 +18,7 @@ type Dorglqer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DorglqTest(t *testing.T, impl Dorglqer) {
|
func DorglqTest(t *testing.T, impl Dorglqer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// TODO(btracey): Base tests off of nb and nx.
|
// TODO(btracey): Base tests off of nb and nx.
|
||||||
for _, test := range []struct{ m, n, k, lda int }{
|
for _, test := range []struct{ m, n, k, lda int }{
|
||||||
{10, 10, 10, 0},
|
{10, 10, 10, 0},
|
||||||
@@ -52,7 +53,7 @@ func DorglqTest(t *testing.T, impl Dorglqer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
work := make([]float64, 1)
|
work := make([]float64, 1)
|
||||||
tau := make([]float64, m)
|
tau := make([]float64, m)
|
||||||
|
@@ -17,6 +17,7 @@ type Dorgqler interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DorgqlTest(t *testing.T, impl Dorgqler) {
|
func DorgqlTest(t *testing.T, impl Dorgqler) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
m, n, k, lda int
|
m, n, k, lda int
|
||||||
}{
|
}{
|
||||||
@@ -34,7 +35,7 @@ func DorgqlTest(t *testing.T, impl Dorgqler) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
tau := nanSlice(min(m, n))
|
tau := nanSlice(min(m, n))
|
||||||
work := nanSlice(max(m, n))
|
work := nanSlice(max(m, n))
|
||||||
|
@@ -18,6 +18,7 @@ type Dorgqrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DorgqrTest(t *testing.T, impl Dorgqrer) {
|
func DorgqrTest(t *testing.T, impl Dorgqrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// TODO(btracey): Base tests off of nb and nx.
|
// TODO(btracey): Base tests off of nb and nx.
|
||||||
for _, test := range []struct{ m, n, k, lda int }{
|
for _, test := range []struct{ m, n, k, lda int }{
|
||||||
{10, 10, 10, 0},
|
{10, 10, 10, 0},
|
||||||
@@ -52,7 +53,7 @@ func DorgqrTest(t *testing.T, impl Dorgqrer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, m*lda)
|
a := make([]float64, m*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
work := make([]float64, 1)
|
work := make([]float64, 1)
|
||||||
tau := make([]float64, n)
|
tau := make([]float64, n)
|
||||||
|
@@ -20,6 +20,7 @@ type Dorgtrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DorgtrTest(t *testing.T, impl Dorgtrer) {
|
func DorgtrTest(t *testing.T, impl Dorgtrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
n, lda int
|
n, lda int
|
||||||
@@ -39,7 +40,7 @@ func DorgtrTest(t *testing.T, impl Dorgtrer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -19,6 +19,7 @@ type Dorm2rer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dorm2rTest(t *testing.T, impl Dorm2rer) {
|
func Dorm2rTest(t *testing.T, impl Dorm2rer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
||||||
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
@@ -63,7 +64,7 @@ func Dorm2rTest(t *testing.T, impl Dorm2rer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, ma*lda)
|
a := make([]float64, ma*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
ldc := test.ldc
|
ldc := test.ldc
|
||||||
if ldc == 0 {
|
if ldc == 0 {
|
||||||
@@ -72,7 +73,7 @@ func Dorm2rTest(t *testing.T, impl Dorm2rer) {
|
|||||||
// Compute random C matrix
|
// Compute random C matrix
|
||||||
c := make([]float64, mc*ldc)
|
c := make([]float64, mc*ldc)
|
||||||
for i := range c {
|
for i := range c {
|
||||||
c[i] = rand.Float64()
|
c[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute QR
|
// Compute QR
|
||||||
|
@@ -20,6 +20,7 @@ type Dormbrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DormbrTest(t *testing.T, impl Dormbrer) {
|
func DormbrTest(t *testing.T, impl Dormbrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
for _, vect := range []lapack.DecompUpdate{lapack.ApplyQ, lapack.ApplyP} {
|
for _, vect := range []lapack.DecompUpdate{lapack.ApplyQ, lapack.ApplyP} {
|
||||||
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
||||||
@@ -69,7 +70,7 @@ func DormbrTest(t *testing.T, impl Dormbrer) {
|
|||||||
}
|
}
|
||||||
a = make([]float64, ma*lda)
|
a = make([]float64, ma*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
nTau := min(nq, k)
|
nTau := min(nq, k)
|
||||||
tauP := make([]float64, nTau)
|
tauP := make([]float64, nTau)
|
||||||
@@ -87,7 +88,7 @@ func DormbrTest(t *testing.T, impl Dormbrer) {
|
|||||||
// Apply and compare update.
|
// Apply and compare update.
|
||||||
c := make([]float64, m*ldc)
|
c := make([]float64, m*ldc)
|
||||||
for i := range c {
|
for i := range c {
|
||||||
c[i] = rand.NormFloat64()
|
c[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
cCopy := make([]float64, len(c))
|
cCopy := make([]float64, len(c))
|
||||||
|
@@ -19,6 +19,7 @@ type Dorml2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dorml2Test(t *testing.T, impl Dorml2er) {
|
func Dorml2Test(t *testing.T, impl Dorml2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// TODO(btracey): This test is not complete, because it
|
// TODO(btracey): This test is not complete, because it
|
||||||
// doesn't test individual values of m, n, and k, instead only testing
|
// doesn't test individual values of m, n, and k, instead only testing
|
||||||
// a specific subset of possible k values.
|
// a specific subset of possible k values.
|
||||||
@@ -66,7 +67,7 @@ func Dorml2Test(t *testing.T, impl Dorml2er) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, ma*lda)
|
a := make([]float64, ma*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
ldc := test.ldc
|
ldc := test.ldc
|
||||||
if ldc == 0 {
|
if ldc == 0 {
|
||||||
@@ -75,7 +76,7 @@ func Dorml2Test(t *testing.T, impl Dorml2er) {
|
|||||||
// Compute random C matrix
|
// Compute random C matrix
|
||||||
c := make([]float64, mc*ldc)
|
c := make([]float64, mc*ldc)
|
||||||
for i := range c {
|
for i := range c {
|
||||||
c[i] = rand.Float64()
|
c[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute LQ
|
// Compute LQ
|
||||||
|
@@ -19,6 +19,7 @@ type Dormlqer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DormlqTest(t *testing.T, impl Dormlqer) {
|
func DormlqTest(t *testing.T, impl Dormlqer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
||||||
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
@@ -68,7 +69,7 @@ func DormlqTest(t *testing.T, impl Dormlqer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, ma*lda)
|
a := make([]float64, ma*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
// Compute random C matrix
|
// Compute random C matrix
|
||||||
ldc := test.ldc
|
ldc := test.ldc
|
||||||
@@ -77,7 +78,7 @@ func DormlqTest(t *testing.T, impl Dormlqer) {
|
|||||||
}
|
}
|
||||||
c := make([]float64, mc*ldc)
|
c := make([]float64, mc*ldc)
|
||||||
for i := range c {
|
for i := range c {
|
||||||
c[i] = rand.Float64()
|
c[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute LQ
|
// Compute LQ
|
||||||
@@ -102,7 +103,7 @@ func DormlqTest(t *testing.T, impl Dormlqer) {
|
|||||||
|
|
||||||
// Make sure Dorml2 and Dormlq match with small work
|
// Make sure Dorml2 and Dormlq match with small work
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
lwork := len(work)
|
lwork := len(work)
|
||||||
copy(c, cCopy)
|
copy(c, cCopy)
|
||||||
@@ -117,7 +118,7 @@ func DormlqTest(t *testing.T, impl Dormlqer) {
|
|||||||
work = make([]float64, int(work[0]))
|
work = make([]float64, int(work[0]))
|
||||||
lwork = len(work)
|
lwork = len(work)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
impl.Dormlq(side, trans, mc, nc, k, a, lda, tau, c, ldc, work, lwork)
|
impl.Dormlq(side, trans, mc, nc, k, a, lda, tau, c, ldc, work, lwork)
|
||||||
if !floats.EqualApprox(c, ans, 1e-12) {
|
if !floats.EqualApprox(c, ans, 1e-12) {
|
||||||
|
@@ -19,6 +19,7 @@ type Dormqrer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DormqrTest(t *testing.T, impl Dormqrer) {
|
func DormqrTest(t *testing.T, impl Dormqrer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
for _, side := range []blas.Side{blas.Left, blas.Right} {
|
||||||
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
@@ -68,7 +69,7 @@ func DormqrTest(t *testing.T, impl Dormqrer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, ma*lda)
|
a := make([]float64, ma*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
// Compute random C matrix
|
// Compute random C matrix
|
||||||
ldc := test.ldc
|
ldc := test.ldc
|
||||||
@@ -77,7 +78,7 @@ func DormqrTest(t *testing.T, impl Dormqrer) {
|
|||||||
}
|
}
|
||||||
c := make([]float64, mc*ldc)
|
c := make([]float64, mc*ldc)
|
||||||
for i := range c {
|
for i := range c {
|
||||||
c[i] = rand.Float64()
|
c[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute QR
|
// Compute QR
|
||||||
@@ -102,7 +103,7 @@ func DormqrTest(t *testing.T, impl Dormqrer) {
|
|||||||
|
|
||||||
// Make sure Dorm2r and Dormqr match with small work
|
// Make sure Dorm2r and Dormqr match with small work
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
lwork := len(work)
|
lwork := len(work)
|
||||||
copy(c, cCopy)
|
copy(c, cCopy)
|
||||||
@@ -117,7 +118,7 @@ func DormqrTest(t *testing.T, impl Dormqrer) {
|
|||||||
work = make([]float64, int(work[0]))
|
work = make([]float64, int(work[0]))
|
||||||
lwork = len(work)
|
lwork = len(work)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
_ = lwork
|
_ = lwork
|
||||||
impl.Dormqr(side, trans, mc, nc, k, a, lda, tau, c, ldc, work, lwork)
|
impl.Dormqr(side, trans, mc, nc, k, a, lda, tau, c, ldc, work, lwork)
|
||||||
|
@@ -79,6 +79,7 @@ func DpoconTest(t *testing.T, impl Dpoconer) {
|
|||||||
log.Printf("Dpocon cond mismatch. Want %v, got %v.", test.cond, cond)
|
log.Printf("Dpocon cond mismatch. Want %v, got %v.", test.cond, cond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
// Randomized tests compared against Dgecon.
|
// Randomized tests compared against Dgecon.
|
||||||
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
for _, uplo := range []blas.Uplo{blas.Lower, blas.Upper} {
|
||||||
@@ -96,7 +97,7 @@ func DpoconTest(t *testing.T, impl Dpoconer) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply a by itself to make it symmetric positive definite.
|
// Multiply a by itself to make it symmetric positive definite.
|
||||||
|
@@ -18,6 +18,7 @@ type Dpotrfer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DpotrfTest(t *testing.T, impl Dpotrfer) {
|
func DpotrfTest(t *testing.T, impl Dpotrfer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
n int
|
n int
|
||||||
@@ -33,7 +34,7 @@ func DpotrfTest(t *testing.T, impl Dpotrfer) {
|
|||||||
// Construct a positive-definite symmetric matrix
|
// Construct a positive-definite symmetric matrix
|
||||||
base := make([]float64, n*n)
|
base := make([]float64, n*n)
|
||||||
for i := range base {
|
for i := range base {
|
||||||
base[i] = rand.Float64()
|
base[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
a := make([]float64, len(base))
|
a := make([]float64, len(base))
|
||||||
bi.Dgemm(blas.Trans, blas.NoTrans, n, n, n, 1, base, n, base, n, 0, a, n)
|
bi.Dgemm(blas.Trans, blas.NoTrans, n, n, n, 1, base, n, base, n, 0, a, n)
|
||||||
|
@@ -53,18 +53,19 @@ func DsterfTest(t *testing.T, impl Dsterfer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// Probabilistic tests.
|
// Probabilistic tests.
|
||||||
for _, n := range []int{4, 6, 10} {
|
for _, n := range []int{4, 6, 10} {
|
||||||
for cas := 0; cas < 10; cas++ {
|
for cas := 0; cas < 10; cas++ {
|
||||||
d := make([]float64, n)
|
d := make([]float64, n)
|
||||||
for i := range d {
|
for i := range d {
|
||||||
d[i] = rand.NormFloat64()
|
d[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
dCopy := make([]float64, len(d))
|
dCopy := make([]float64, len(d))
|
||||||
copy(dCopy, d)
|
copy(dCopy, d)
|
||||||
e := make([]float64, n-1)
|
e := make([]float64, n-1)
|
||||||
for i := range e {
|
for i := range e {
|
||||||
e[i] = rand.NormFloat64()
|
e[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
eCopy := make([]float64, len(e))
|
eCopy := make([]float64, len(e))
|
||||||
copy(eCopy, e)
|
copy(eCopy, e)
|
||||||
|
@@ -18,6 +18,7 @@ type Dsytd2er interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Dsytd2Test(t *testing.T, impl Dsytd2er) {
|
func Dsytd2Test(t *testing.T, impl Dsytd2er) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
n, lda int
|
n, lda int
|
||||||
@@ -37,7 +38,7 @@ func Dsytd2Test(t *testing.T, impl Dsytd2er) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -19,6 +19,7 @@ type Dsytrder interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DsytrdTest(t *testing.T, impl Dsytrder) {
|
func DsytrdTest(t *testing.T, impl Dsytrder) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper} {
|
for _, uplo := range []blas.Uplo{blas.Upper} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
n, lda int
|
n, lda int
|
||||||
@@ -42,7 +43,7 @@ func DsytrdTest(t *testing.T, impl Dsytrder) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
d2 := make([]float64, n)
|
d2 := make([]float64, n)
|
||||||
e2 := make([]float64, n)
|
e2 := make([]float64, n)
|
||||||
|
@@ -16,6 +16,7 @@ type Dtrconer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DtrconTest(t *testing.T, impl Dtrconer) {
|
func DtrconTest(t *testing.T, impl Dtrconer) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
// Hand crafted tests.
|
// Hand crafted tests.
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
a []float64
|
a []float64
|
||||||
@@ -77,11 +78,11 @@ func DtrconTest(t *testing.T, impl Dtrconer) {
|
|||||||
lda := test.n
|
lda := test.n
|
||||||
work := make([]float64, 3*test.n)
|
work := make([]float64, 3*test.n)
|
||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rand.Float64()
|
work[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
iwork := make([]int, test.n)
|
iwork := make([]int, test.n)
|
||||||
for i := range iwork {
|
for i := range iwork {
|
||||||
iwork[i] = rand.Int()
|
iwork[i] = rnd.Int()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(test.a))
|
aCopy := make([]float64, len(test.a))
|
||||||
copy(aCopy, test.a)
|
copy(aCopy, test.a)
|
||||||
@@ -128,7 +129,7 @@ func DtrconTest(t *testing.T, impl Dtrconer) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.NormFloat64()
|
a[i] = rnd.NormFloat64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,6 +84,7 @@ func Dtrti2Test(t *testing.T, impl Dtrti2er) {
|
|||||||
t.Errorf("Matrix inverse mismatch. Want %v, got %v.", test.ans, test.a)
|
t.Errorf("Matrix inverse mismatch. Want %v, got %v.", test.ans, test.a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper} {
|
for _, uplo := range []blas.Uplo{blas.Upper} {
|
||||||
for _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
|
for _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
|
||||||
@@ -100,7 +101,7 @@ func Dtrti2Test(t *testing.T, impl Dtrti2er) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64()
|
a[i] = rnd.Float64()
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
@@ -15,6 +15,7 @@ type Dtrtrier interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DtrtriTest(t *testing.T, impl Dtrtrier) {
|
func DtrtriTest(t *testing.T, impl Dtrtrier) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
for _, uplo := range []blas.Uplo{blas.Upper} {
|
for _, uplo := range []blas.Uplo{blas.Upper} {
|
||||||
for _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
|
for _, diag := range []blas.Diag{blas.NonUnit, blas.Unit} {
|
||||||
@@ -35,7 +36,7 @@ func DtrtriTest(t *testing.T, impl Dtrtrier) {
|
|||||||
}
|
}
|
||||||
a := make([]float64, n*lda)
|
a := make([]float64, n*lda)
|
||||||
for i := range a {
|
for i := range a {
|
||||||
a[i] = rand.Float64() + 1 // This keeps the matrices well conditioned.
|
a[i] = rnd.Float64() + 1 // This keeps the matrices well conditioned.
|
||||||
}
|
}
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
|
Reference in New Issue
Block a user