本文整理匯總了Golang中github.com/henrylee2cn/algorithm/matrix.FloatMatrix.DiagOf方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrix.DiagOf方法的具體用法?Golang FloatMatrix.DiagOf怎麽用?Golang FloatMatrix.DiagOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/henrylee2cn/algorithm/matrix.FloatMatrix
的用法示例。
在下文中一共展示了FloatMatrix.DiagOf方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestQRBlk
func TestQRBlk(t *testing.T) {
M := 8
N := 6
nb := 2
A := matrix.FloatUniform(M, N)
Tau := matrix.FloatZeros(M, 1)
Tz := matrix.FloatZeros(N, N)
Tx := matrix.FloatZeros(N, N)
DecomposeBlockSize(0)
Z, _ := DecomposeQRT(A.Copy(), Tz, nil, 0)
_ = Z
DecomposeBlockSize(nb)
//X, _ := DecomposeQR(A.Copy(), Tau, nil)
X, _ := DecomposeQRT(A.Copy(), Tx, nil, nb)
Tau0 := matrix.FloatZeros(M, 1)
A0 := A.Copy()
lapack.Geqrf(A0, Tau0)
ok := X.AllClose(A0)
var dx matrix.FloatMatrix
dx.DiagOf(Tx)
//okt := Tau.AllClose(Tau0)
okt := true
_ = Tau
t.Logf("lapack QR == DecomposeQR: %v\n", ok && okt)
if !ok || !okt || true {
t.Logf("A0: %d, %d, %d\n", A0.Rows(), A0.Cols(), A0.LeadingIndex())
t.Logf("A\n%v\n", A)
t.Logf("X\n%v\n", X)
t.Logf("Tz\n%v\n", Tz)
t.Logf("Tx\n%v\n", Tx)
t.Logf("Tau\n%v\n", &dx)
t.Logf("lapack X\n%v\n", A0)
t.Logf("lapack Tau\n%v\n", Tau0)
}
}
示例2: TestQRT
func TestQRT(t *testing.T) {
M := 6
N := 5
var Tau matrix.FloatMatrix
A := matrix.FloatUniform(M, N)
T := matrix.FloatZeros(A.Cols(), A.Cols())
T0 := T.Copy()
X, _ := DecomposeQRT(A.Copy(), T, nil, 0)
Tau.DiagOf(T)
Tau0 := matrix.FloatZeros(M, 1)
A0 := A.Copy()
lapack.Geqrf(A0, Tau0)
ok := X.AllClose(A0)
okt := Tau.AllClose(Tau0)
t.Logf("lapack QR == DecomposeQR: %v\n", ok && okt)
if !ok || !okt {
t.Logf("A0: %d, %d, %d\n", A0.Rows(), A0.Cols(), A0.LeadingIndex())
t.Logf("A\n%v\n", A)
t.Logf("X\n%v\n", X)
t.Logf("Tau\n%v\n", &Tau)
t.Logf("lapack X\n%v\n", A0)
t.Logf("lapack Tau\n%v\n", Tau0)
}
// build block reflectors
//unblkQRBlockReflector(X, Tau, T)
V := TriLU(A0.Copy())
lapack.LarftFloat(V, Tau0, T0)
ok = T0.AllClose(T)
t.Logf("lapack.dlarft == QRBlockReflector: %v\n", ok)
if !ok {
t.Logf("T:\n%v\n", T)
t.Logf("lapack T0:\n%v\n", T0)
}
}
示例3: blockedQR
/*
* Blocked QR decomposition with compact WY transform. As implemented
* in lapack.xGEQRF subroutine.
*/
func blockedQR(A, Tvec, Twork, W *matrix.FloatMatrix, nb int) {
var ATL, ATR, ABL, ABR, AL, AR matrix.FloatMatrix
var A00, A01, A02, A10, A11, A12, A20, A21, A22 matrix.FloatMatrix
var TT, TB matrix.FloatMatrix
var t0, tau, t2, Tdiag, WT, WB, W0, W1, W2 matrix.FloatMatrix
//var Twork, W *matrix.FloatMatrix
Tdiag.DiagOf(Twork)
partition2x2(
&ATL, &ATR,
&ABL, &ABR, A, 0, 0, pTOPLEFT)
partition2x1(
&TT,
&TB, Tvec, 0, pTOP)
partition2x1(
&WT,
&WB, W, 0, pTOP)
for ABR.Rows() > 0 && ABR.Cols() > 0 {
repartition2x2to3x3(&ATL,
&A00, &A01, &A02,
&A10, &A11, &A12,
&A20, &A21, &A22, A, nb, pBOTTOMRIGHT)
repartition2x1to3x1(&TT,
&t0,
&tau,
&t2, Tvec, nb, pBOTTOM)
repartition2x1to3x1(&WT,
&W0,
&W1,
&W2, W, nb, pBOTTOM)
partition1x2(
&AL, &AR, &ABR, nb, pLEFT)
// current block size
cb, rb := A11.Size()
if rb < cb {
cb = rb
}
// --------------------------------------------------------
// decompose left side AL == /A11\
// \A21/
unblockedQRT(&AL, Twork)
// copy scaling from T diagonal to tau-vector
Tdiag.CopyTo(&tau)
// update A'tail i.e. A12 and A22 with (I - Y*T*Y.T).T * A'tail
// compute: C - Y*(C.T*Y*T).T
updateWithQT(&A12, &A22, &A11, &A21, Twork, &W2, cb, true)
// --------------------------------------------------------
continue3x3to2x2(
&ATL, &ATR,
&ABL, &ABR, &A00, &A11, &A22, A, pBOTTOMRIGHT)
continue3x1to2x1(
&TT,
&TB, &t0, &tau, Tvec, pBOTTOM)
continue3x1to2x1(
&WT,
&WB, &W0, &W1, W, pBOTTOM)
}
}