1 // Copyright ©2015 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
8 "gonum.org/v1/gonum/blas"
9 "gonum.org/v1/gonum/blas/blas64"
12 // Dorg2r generates an m×n matrix Q with orthonormal columns defined by the
13 // product of elementary reflectors as computed by Dgeqrf.
14 // Q = H_0 * H_1 * ... * H_{k-1}
15 // len(tau) >= k, 0 <= k <= n, 0 <= n <= m, len(work) >= n.
16 // Dorg2r will panic if these conditions are not met.
18 // Dorg2r is an internal routine. It is exported for testing purposes.
19 func (impl Implementation) Dorg2r(m, n, k int, a []float64, lda int, tau []float64, work []float64) {
20 checkMatrix(m, n, a, lda)
39 bi := blas64.Implementation()
40 // Initialize columns k+1:n to columns of the unit matrix.
41 for l := 0; l < m; l++ {
42 for j := k; j < n; j++ {
46 for j := k; j < n; j++ {
49 for i := k - 1; i >= 0; i-- {
55 impl.Dlarf(blas.Left, m-i, n-i-1, a[i*lda+i:], lda, tau[i], a[i*lda+i+1:], lda, work)
58 bi.Dscal(m-i-1, -tau[i], a[(i+1)*lda+i:], lda)
60 a[i*lda+i] = 1 - tau[i]
61 for l := 0; l < i; l++ {