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.
7 import "gonum.org/v1/gonum/blas"
9 // Dgelq2 computes the LQ factorization of the m×n matrix A.
11 // In an LQ factorization, L is a lower triangular m×n matrix, and Q is an n×n
12 // orthonormal matrix.
14 // a is modified to contain the information to construct L and Q.
15 // The lower triangle of a contains the matrix L. The upper triangular elements
16 // (not including the diagonal) contain the elementary reflectors. tau is modified
17 // to contain the reflector scales. tau must have length of at least k = min(m,n)
18 // and this function will panic otherwise.
20 // See Dgeqr2 for a description of the elementary reflectors and orthonormal
21 // matrix Q. Q is constructed as a product of these elementary reflectors,
22 // Q = H_{k-1} * ... * H_1 * H_0.
24 // work is temporary storage of length at least m and this function will panic otherwise.
26 // Dgelq2 is an internal routine. It is exported for testing purposes.
27 func (impl Implementation) Dgelq2(m, n int, a []float64, lda int, tau, work []float64) {
28 checkMatrix(m, n, a, lda)
36 for i := 0; i < k; i++ {
37 a[i*lda+i], tau[i] = impl.Dlarfg(n-i, a[i*lda+i], a[i*lda+min(i+1, n-1):], 1)
41 impl.Dlarf(blas.Right, m-i-1, n-i,