mirror of
https://github.com/gonum/gonum.git
synced 2025-10-07 08:01:20 +08:00
lapack/gonum: require exact length of tau in QR routines
This commit is contained in:

committed by
Vladimír Chalupecký

parent
bd767ae5eb
commit
6e2f5c5890
@@ -62,8 +62,9 @@ func DgeqrfTest(t *testing.T, impl Dgeqrfer) {
|
||||
|
||||
// Allocate a slice for scalar factors of elementary reflectors
|
||||
// and fill it with random numbers.
|
||||
tau := make([]float64, n)
|
||||
for i := 0; i < n; i++ {
|
||||
k := min(m, n)
|
||||
tau := make([]float64, k)
|
||||
for i := range tau {
|
||||
tau[i] = rnd.Float64()
|
||||
}
|
||||
|
||||
|
@@ -84,7 +84,7 @@ func DlarfbTest(t *testing.T, impl Dlarfber) {
|
||||
}
|
||||
|
||||
// Use dgeqr2 to find the v vectors
|
||||
tau := make([]float64, na)
|
||||
tau := make([]float64, k)
|
||||
work := make([]float64, na)
|
||||
impl.Dgeqr2(ma, k, a, lda, tau, work)
|
||||
|
||||
|
@@ -52,7 +52,8 @@ func DlarftTest(t *testing.T, impl Dlarfter) {
|
||||
}
|
||||
}
|
||||
// Use dgeqr2 to find the v vectors
|
||||
tau := make([]float64, n)
|
||||
k := min(m, n)
|
||||
tau := make([]float64, k)
|
||||
work := make([]float64, n)
|
||||
impl.Dgeqr2(m, n, a, lda, tau, work)
|
||||
|
||||
@@ -64,7 +65,6 @@ func DlarftTest(t *testing.T, impl Dlarfter) {
|
||||
|
||||
h := constructH(tau, vMat, store, direct)
|
||||
|
||||
k := min(m, n)
|
||||
ldt := test.ldt
|
||||
if ldt == 0 {
|
||||
ldt = k
|
||||
|
@@ -59,7 +59,7 @@ func Dorg2rTest(t *testing.T, impl Dorg2rer) {
|
||||
q := constructQK("QR", m, n, k, a, lda, tau)
|
||||
|
||||
// Compute the matrix Q using Dorg2r.
|
||||
impl.Dorg2r(m, n, k, a, lda, tau, work)
|
||||
impl.Dorg2r(m, n, k, a, lda, tau[:k], work)
|
||||
|
||||
// Check that the first n columns of both results match.
|
||||
same := true
|
||||
|
@@ -57,7 +57,7 @@ func DorgqrTest(t *testing.T, impl Dorgqrer) {
|
||||
a[i] = rnd.Float64()
|
||||
}
|
||||
work := make([]float64, 1)
|
||||
tau := make([]float64, n)
|
||||
tau := make([]float64, min(m, n))
|
||||
for i := range tau {
|
||||
tau[i] = math.NaN()
|
||||
}
|
||||
@@ -71,12 +71,12 @@ func DorgqrTest(t *testing.T, impl Dorgqrer) {
|
||||
for i := range work {
|
||||
work[i] = math.NaN()
|
||||
}
|
||||
impl.Dorg2r(m, n, k, aUnblocked, lda, tau, work)
|
||||
impl.Dorg2r(m, n, k, aUnblocked, lda, tau[:k], work)
|
||||
// make sure work isn't used before initialized
|
||||
for i := range work {
|
||||
work[i] = math.NaN()
|
||||
}
|
||||
impl.Dorgqr(m, n, k, a, lda, tau, work, len(work))
|
||||
impl.Dorgqr(m, n, k, a, lda, tau[:k], work, len(work))
|
||||
if !floats.EqualApprox(a, aUnblocked, 1e-10) {
|
||||
t.Errorf("Q Mismatch. m = %d, n = %d, k = %d, lda = %d", m, n, k, lda)
|
||||
}
|
||||
|
Reference in New Issue
Block a user