mirror of
https://github.com/gonum/gonum.git
synced 2025-10-23 15:13:31 +08:00
cgo: add Dorgql
This commit is contained in:

committed by
Vladimír Chalupecký

parent
aabe3c2025
commit
0ddbe87d4b
@@ -47,6 +47,7 @@ const (
|
|||||||
kGTM = "lapack: k > m"
|
kGTM = "lapack: k > m"
|
||||||
kGTN = "lapack: k > n"
|
kGTN = "lapack: k > n"
|
||||||
kLT0 = "lapack: k < 0"
|
kLT0 = "lapack: k < 0"
|
||||||
|
mLT0 = "lapack: m < 0"
|
||||||
mLTN = "lapack: m < n"
|
mLTN = "lapack: m < n"
|
||||||
negDimension = "lapack: negative matrix dimension"
|
negDimension = "lapack: negative matrix dimension"
|
||||||
negZ = "lapack: negative z value"
|
negZ = "lapack: negative z value"
|
||||||
@@ -1285,6 +1286,53 @@ func (impl Implementation) Dorglq(m, n, k int, a []float64, lda int, tau, work [
|
|||||||
lapacke.Dorglq(m, n, k, a, lda, tau, work, lwork)
|
lapacke.Dorglq(m, n, k, a, lda, tau, work, lwork)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dorgql generates the m×n matrix Q with orthonormal columns defined as the
|
||||||
|
// last n columns of a product of k elementary reflectors of order m
|
||||||
|
// Q = H_{k-1} * ... * H_1 * H_0.
|
||||||
|
//
|
||||||
|
// It must hold that
|
||||||
|
// 0 <= k <= n <= m,
|
||||||
|
// and Dorgql will panic otherwise.
|
||||||
|
//
|
||||||
|
// On entry, the (n-k+i)-th column of A must contain the vector which defines
|
||||||
|
// the elementary reflector H_i, for i=0,...,k-1, and tau[i] must contain its
|
||||||
|
// scalar factor. On return, a contains the m×n matrix Q.
|
||||||
|
//
|
||||||
|
// tau must have length at least k, and Dorgql will panic otherwise.
|
||||||
|
//
|
||||||
|
// work must have length at least max(1,lwork), and lwork must be at least
|
||||||
|
// max(1,n), otherwise Dorgql will panic. For optimum performance lwork must
|
||||||
|
// be a sufficiently large multiple of n.
|
||||||
|
//
|
||||||
|
// If lwork == -1, instead of computing Dorgql the optimal work length is stored
|
||||||
|
// into work[0].
|
||||||
|
//
|
||||||
|
// Dorgql is an internal routine. It is exported for testing purposes.
|
||||||
|
func (impl Implementation) Dorgql(m, n, k int, a []float64, lda int, tau, work []float64, lwork int) {
|
||||||
|
switch {
|
||||||
|
case n < 0:
|
||||||
|
panic(nLT0)
|
||||||
|
case m < n:
|
||||||
|
panic(mLTN)
|
||||||
|
case k < 0:
|
||||||
|
panic(kLT0)
|
||||||
|
case k > n:
|
||||||
|
panic(kGTN)
|
||||||
|
case lwork < max(1, n) && lwork != -1:
|
||||||
|
panic(badWork)
|
||||||
|
case len(work) < lwork:
|
||||||
|
panic(shortWork)
|
||||||
|
}
|
||||||
|
if lwork != -1 {
|
||||||
|
checkMatrix(m, n, a, lda)
|
||||||
|
if len(tau) < k {
|
||||||
|
panic(badTau)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lapacke.Dorgql(m, n, k, a, lda, tau, work, lwork)
|
||||||
|
}
|
||||||
|
|
||||||
// Dorgqr generates an m×n matrix Q with orthonormal columns defined by the
|
// Dorgqr generates an m×n matrix Q with orthonormal columns defined by the
|
||||||
// product of elementary reflectors
|
// product of elementary reflectors
|
||||||
// Q = H_0 * H_1 * ... * H_{k-1}
|
// Q = H_0 * H_1 * ... * H_{k-1}
|
||||||
|
@@ -24,20 +24,35 @@ import (
|
|||||||
//
|
//
|
||||||
// Dorgql is an internal routine. It is exported for testing purposes.
|
// Dorgql is an internal routine. It is exported for testing purposes.
|
||||||
func (impl Implementation) Dorgql(m, n, k int, a []float64, lda int, tau, work []float64, lwork int) {
|
func (impl Implementation) Dorgql(m, n, k int, a []float64, lda int, tau, work []float64, lwork int) {
|
||||||
checkMatrix(m, n, a, lda)
|
switch {
|
||||||
if len(tau) < k {
|
case n < 0:
|
||||||
panic(badTau)
|
panic(nLT0)
|
||||||
|
case m < n:
|
||||||
|
panic(mLTN)
|
||||||
|
case k < 0:
|
||||||
|
panic(kLT0)
|
||||||
|
case k > n:
|
||||||
|
panic(kGTN)
|
||||||
|
case lwork < max(1, n) && lwork != -1:
|
||||||
|
panic(badWork)
|
||||||
|
case len(work) < lwork:
|
||||||
|
panic(shortWork)
|
||||||
}
|
}
|
||||||
nb := impl.Ilaenv(1, "DORGQL", " ", m, n, k, -1)
|
if lwork != -1 {
|
||||||
lworkopt := n * nb
|
checkMatrix(m, n, a, lda)
|
||||||
work[0] = float64(lworkopt)
|
if len(tau) < k {
|
||||||
if lwork == -1 {
|
panic(badTau)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if n == 0 {
|
||||||
|
work[0] = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if lwork < n {
|
|
||||||
panic(badWork)
|
nb := impl.Ilaenv(1, "DORGQL", " ", m, n, k, -1)
|
||||||
}
|
if lwork == -1 {
|
||||||
if n == 0 {
|
work[0] = float64(n * nb)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,4 +118,5 @@ func (impl Implementation) Dorgql(m, n, k int, a []float64, lda int, tau, work [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
work[0] = float64(iws)
|
||||||
}
|
}
|
||||||
|
@@ -53,6 +53,7 @@ const (
|
|||||||
kGTM = "lapack: k > m"
|
kGTM = "lapack: k > m"
|
||||||
kGTN = "lapack: k > n"
|
kGTN = "lapack: k > n"
|
||||||
kLT0 = "lapack: k < 0"
|
kLT0 = "lapack: k < 0"
|
||||||
|
mLT0 = "lapack: m < 0"
|
||||||
mLTN = "lapack: m < n"
|
mLTN = "lapack: m < n"
|
||||||
negDimension = "lapack: negative matrix dimension"
|
negDimension = "lapack: negative matrix dimension"
|
||||||
negZ = "lapack: negative z value"
|
negZ = "lapack: negative z value"
|
||||||
|
Reference in New Issue
Block a user