本文整理匯總了Golang中github.com/hrautila/gomas/blasd.Mult函數的典型用法代碼示例。如果您正苦於以下問題:Golang Mult函數的具體用法?Golang Mult怎麽用?Golang Mult使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Mult函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateRightRQ
// compute:
// C*Q.T = C*(I -Y*T*Y.T).T == C - C*Y*T.T*Y.T
// or
// C*Q = (I -Y*T*Y.T)*C == C - C*Y*T*Y.T
//
//
// where C = ( C2 C1 ), Y = ( Y2 Y1 )
//
// C1 is K*nb, C2 is K*P, Y1 is nb*nb triuu, Y2 is nb*P, T is nb*nb
// W = K*nb
func updateRightRQ(C1, C2, Y1t, Y2t, T, W *cmat.FloatMatrix, transpose bool, conf *gomas.Config) {
// -- compute: W = C*Y = C1*Y1 + C2*Y2
// W = C1
blasd.Plus(W, C1, 0.0, 1.0, gomas.NONE)
// W = C1*Y1t.T
blasd.MultTrm(W, Y1t, 1.0, gomas.RIGHT|gomas.LOWER|gomas.UNIT|gomas.TRANSA, conf)
// W = W + C2*Y2t.T
blasd.Mult(W, C2, Y2t, 1.0, 1.0, gomas.TRANSB, conf)
// --- here: W == C*Y ---
tflags := gomas.RIGHT | gomas.LOWER
if transpose {
tflags |= gomas.TRANSA
}
// W = W*T or W*T.T
blasd.MultTrm(W, T, 1.0, tflags, conf)
// --- here: W == C*Y*T or C*Y*T.T ---
// C2 = C2 - W*Y2t
blasd.Mult(C2, W, Y2t, -1.0, 1.0, gomas.NONE, conf)
// C1 = C1 - W*Y1t
// W = W*Y1
blasd.MultTrm(W, Y1t, 1.0, gomas.RIGHT|gomas.LOWER|gomas.UNIT, conf)
// C1 = C1 - W
blasd.Plus(C1, W, 1.0, -1.0, gomas.NONE)
// --- here: C = (I - Y*T*Y.T).T * C ---
}
示例2: updateLeftRQ
// compute:
// Q.T*C = (I -Y*T*Y.T).T*C == C - Y*(C.T*Y*T).T
// or
// Q*C = (I -Y*T*Y.T)*C == C - Y*(C.T*Y*T.T).T
//
//
// where C = ( C2 ) Y = ( Y2 Y1 )
// ( C1 )
//
// C1 is nb*K, C2 is P*K, Y1 is nb*nb triuu, Y2 is nb*P, T is nb*nb
// W = K*nb
func updateLeftRQ(C1, C2, Y1t, Y2t, T, W *cmat.FloatMatrix, transpose bool, conf *gomas.Config) {
// W = C1.T
blasd.Plus(W, C1, 0.0, 1.0, gomas.TRANSB)
// W = C1.T*Y1.T
blasd.MultTrm(W, Y1t, 1.0, gomas.RIGHT|gomas.LOWER|gomas.UNIT|gomas.TRANSA, conf)
// W = W + C2.T*Y2.T
blasd.Mult(W, C2, Y2t, 1.0, 1.0, gomas.TRANSA|gomas.TRANSB, conf)
// --- here: W == C.T*Y == C1.T*Y1.T + C2.T*Y2.T ---
tflags := gomas.RIGHT | gomas.LOWER
if !transpose {
tflags |= gomas.TRANSA
}
// W = W*T or W*T.T
blasd.MultTrm(W, T, 1.0, tflags, conf)
// --- here: W == C.T*Y*T or C.T*Y*T.T ---
// C2 = C2 - Y2*W.T
blasd.Mult(C2, Y2t, W, -1.0, 1.0, gomas.TRANSA|gomas.TRANSB, conf)
// W = Y1*W.T ==> W.T = W*Y1
blasd.MultTrm(W, Y1t, 1.0, gomas.RIGHT|gomas.LOWER|gomas.UNIT, conf)
// C1 = C1 - W.T
blasd.Plus(C1, W, 1.0, -1.0, gomas.TRANSB)
// --- here: C = (I - Y*T*Y.T).T * C ---
}
示例3: TestDTrmmUnitUpper
func TestDTrmmUnitUpper(t *testing.T) {
var d cmat.FloatMatrix
N := 563
K := 171
A := cmat.NewMatrix(N, N)
B := cmat.NewMatrix(N, K)
B0 := cmat.NewMatrix(N, K)
C := cmat.NewMatrix(N, K)
zeros := cmat.NewFloatConstSource(0.0)
ones := cmat.NewFloatConstSource(1.0)
zeromean := cmat.NewFloatNormSource()
A.SetFrom(zeromean, cmat.UPPER|cmat.UNIT)
B.SetFrom(ones)
B0.SetFrom(ones)
// B = A*B
blasd.MultTrm(B, A, 1.0, gomas.UPPER|gomas.LEFT|gomas.UNIT)
d.Diag(A).SetFrom(ones)
blasd.Mult(C, A, B0, 1.0, 0.0, gomas.NONE)
ok := C.AllClose(B)
t.Logf("trmm(B, A, L|U|N|U) == gemm(C, TriUU(A), B) : %v\n", ok)
B.SetFrom(ones)
// B = A.T*B
d.Diag(A).SetFrom(zeros)
blasd.MultTrm(B, A, 1.0, gomas.UPPER|gomas.LEFT|gomas.TRANSA|gomas.UNIT)
d.Diag(A).SetFrom(ones)
blasd.Mult(C, A, B0, 1.0, 0.0, gomas.TRANSA)
ok = C.AllClose(B)
t.Logf("trmm(B, A, L|U|T|U) == gemm(C, TriUU(A).T, B) : %v\n", ok)
}
示例4: TestDTrmmLowerRight
func TestDTrmmLowerRight(t *testing.T) {
N := 563
K := 171
nofail := true
A := cmat.NewMatrix(N, N)
B := cmat.NewMatrix(K, N)
B0 := cmat.NewMatrix(K, N)
C := cmat.NewMatrix(K, N)
ones := cmat.NewFloatConstSource(1.0)
zeromean := cmat.NewFloatNormSource()
A.SetFrom(zeromean, cmat.LOWER)
B.SetFrom(ones)
B0.SetFrom(ones)
// B = B*A
blasd.MultTrm(B, A, 1.0, gomas.LOWER|gomas.RIGHT)
blasd.Mult(C, B0, A, 1.0, 0.0, gomas.NONE)
ok := C.AllClose(B)
nofail = nofail && ok
t.Logf("trmm(B, A, R|L|N) == gemm(C, B, TriL(A)) : %v\n", ok)
B.SetFrom(ones)
// B = B*A.T
blasd.MultTrm(B, A, 1.0, gomas.LOWER|gomas.RIGHT|gomas.TRANSA)
blasd.Mult(C, B0, A, 1.0, 0.0, gomas.TRANSB)
ok = C.AllClose(B)
nofail = nofail && ok
t.Logf("trmm(B, A, R|L|T) == gemm(C, B, TriL(A).T) : %v\n", ok)
}
示例5: TestDTrmmUnitUpperRight
func TestDTrmmUnitUpperRight(t *testing.T) {
var d cmat.FloatMatrix
N := 563
K := 171
A := cmat.NewMatrix(N, N)
B := cmat.NewMatrix(K, N)
B0 := cmat.NewMatrix(K, N)
C := cmat.NewMatrix(K, N)
zeros := cmat.NewFloatConstSource(0.0)
ones := cmat.NewFloatConstSource(1.0)
zeromean := cmat.NewFloatNormSource()
A.SetFrom(zeromean, cmat.UPPER|cmat.UNIT)
B.SetFrom(ones)
B0.SetFrom(ones)
// B = B*A
blasd.MultTrm(B, A, 1.0, gomas.UPPER|gomas.RIGHT|gomas.UNIT)
d.Diag(A).SetFrom(ones)
blasd.Mult(C, B0, A, 1.0, 0.0, gomas.NONE)
ok := C.AllClose(B)
t.Logf("trmm(B, A, R|U|N|U) == gemm(C, B, TriUU(A)) : %v\n", ok)
B.SetFrom(ones)
// B = B*A.T
d.SetFrom(zeros)
blasd.MultTrm(B, A, 1.0, gomas.UPPER|gomas.RIGHT|gomas.TRANSA|gomas.UNIT)
d.SetFrom(ones)
blasd.Mult(C, B0, A, 1.0, 0.0, gomas.TRANSB)
ok = C.AllClose(B)
t.Logf("trmm(B, A, R|U|T|U) == gemm(C, B, TriUU(A).T) : %v\n", ok)
}
示例6: TestDTrmmLower
func TestDTrmmLower(t *testing.T) {
N := 563
K := 171
nofail := true
A := cmat.NewMatrix(N, N)
B := cmat.NewMatrix(N, K)
B0 := cmat.NewMatrix(N, K)
C := cmat.NewMatrix(N, K)
ones := cmat.NewFloatConstSource(1.0)
zeromean := cmat.NewFloatNormSource()
A.SetFrom(zeromean, cmat.LOWER)
B.SetFrom(ones)
B0.SetFrom(ones)
// B = A*B
blasd.MultTrm(B, A, 1.0, gomas.LOWER|gomas.LEFT)
blasd.Mult(C, A, B0, 1.0, 0.0, gomas.NONE)
ok := C.AllClose(B)
nofail = nofail && ok
t.Logf("trmm(B, A, L|L|N) == gemm(C, TriL(A), B) : %v\n", ok)
B.SetFrom(ones)
// B = A.T*B
blasd.MultTrm(B, A, 1.0, gomas.LOWER|gomas.LEFT|gomas.TRANSA)
blasd.Mult(C, A, B0, 1.0, 0.0, gomas.TRANSA)
ok = C.AllClose(B)
nofail = nofail && ok
t.Logf("trmm(B, A, L|L|T) == gemm(C, TriL(A).T, B) : %v\n", ok)
}
示例7: test_bdsvd
func test_bdsvd(N, flags, kind int, verbose bool, t *testing.T) {
var At, sD, sE, tmp cmat.FloatMatrix
uplo := "upper"
offdiag := 1
if flags&gomas.LOWER != 0 {
offdiag = -1
uplo = "lower"
}
A0 := cmat.NewMatrix(N, N)
desc := setDiagonals(A0, offdiag, kind)
At.SubMatrix(A0, 0, 0, N, N)
sD.Diag(A0, 0)
sE.Diag(A0, offdiag)
D := cmat.NewCopy(&sD)
E := cmat.NewCopy(&sE)
// unit singular vectors
U := cmat.NewMatrix(N, N)
sD.Diag(U, 0)
sD.Add(1.0)
V := cmat.NewMatrix(N, N)
sD.Diag(V, 0)
sD.Add(1.0)
W := cmat.NewMatrix(4*N, 1)
C := cmat.NewMatrix(N, N)
lapackd.BDSvd(D, E, U, V, W, flags|gomas.WANTU|gomas.WANTV)
blasd.Mult(C, U, U, 1.0, 0.0, gomas.TRANSA)
sD.Diag(C)
sD.Add(-1.0)
nrmu := lapackd.NormP(C, lapackd.NORM_ONE)
blasd.Mult(C, V, V, 1.0, 0.0, gomas.TRANSB)
sD.Add(-1.0)
nrmv := lapackd.NormP(C, lapackd.NORM_ONE)
blasd.Mult(C, U, A0, 1.0, 0.0, gomas.TRANSA)
blasd.Mult(&At, C, V, 1.0, 0.0, gomas.TRANSB)
if verbose && N < 10 {
t.Logf("D:\n%v\n", asRow(&tmp, D))
t.Logf("U:\n%v\n", U)
t.Logf("V:\n%v\n", V)
t.Logf("U.T*A*V\n%v\n", &At)
}
sD.Diag(&At)
blasd.Axpy(&sD, D, -1.0)
nrma := lapackd.NormP(&At, lapackd.NORM_ONE)
t.Logf("N=%d [%s,%s] ||U.T*A*V - bdsvd(A)||_1: %e\n", N, uplo, desc, nrma)
t.Logf(" ||I - U.T*U||_1: %e\n", nrmu)
t.Logf(" ||I - V.T*V||_1: %e\n", nrmv)
}
示例8: TestQLMultRightTrans
// test: C = C*Q.T
func TestQLMultRightTrans(t *testing.T) {
var d, di0, di1 cmat.FloatMatrix
M := 891
N := 853
lb := 36
conf := gomas.NewConf()
A := cmat.NewMatrix(M, N)
src := cmat.NewFloatNormSource()
A.SetFrom(src)
C0 := cmat.NewMatrix(N, M)
d.Diag(C0, M-N)
ones := cmat.NewFloatConstSource(1.0)
d.SetFrom(ones)
C1 := cmat.NewCopy(C0)
I0 := cmat.NewMatrix(N, N)
I1 := cmat.NewCopy(I0)
di0.Diag(I0)
di1.Diag(I1)
tau := cmat.NewMatrix(N, 1)
W := cmat.NewMatrix(lb*(M+N), 1)
conf.LB = lb
lapackd.QLFactor(A, tau, W, conf)
conf.LB = 0
lapackd.QLMult(C0, A, tau, W, gomas.RIGHT|gomas.TRANS, conf)
// I = Q*Q.T - I
blasd.Mult(I0, C0, C0, 1.0, 0.0, gomas.TRANSB, conf)
blasd.Add(&di0, -1.0)
n0 := lapackd.NormP(I0, lapackd.NORM_ONE)
conf.LB = lb
lapackd.QLMult(C1, A, tau, W, gomas.RIGHT|gomas.TRANS, conf)
// I = Q*Q.T - I
blasd.Mult(I1, C1, C1, 1.0, 0.0, gomas.TRANSB, conf)
blasd.Add(&di1, -1.0)
n1 := lapackd.NormP(I1, lapackd.NORM_ONE)
if N < 10 {
t.Logf("unblk C0*Q:\n%v\n", C0)
t.Logf("blk. C2*Q:\n%v\n", C1)
}
blasd.Plus(C0, C1, 1.0, -1.0, gomas.NONE)
n2 := lapackd.NormP(C0, lapackd.NORM_ONE)
t.Logf("M=%d, N=%d ||unblk.QLMult(C) - blk.QLMult(C)||_1: %e\n", M, N, n2)
t.Logf("unblk M=%d, N=%d ||I - Q*Q.T||_1: %e\n", M, N, n0)
t.Logf("blk M=%d, N=%d ||I - Q*Q.T||_1: %e\n", M, N, n1)
}
示例9: TestUpperCHOL
func TestUpperCHOL(t *testing.T) {
N := 311
K := 43
nb := 0
conf := gomas.NewConf()
conf.LB = nb
Z := cmat.NewMatrix(N, N)
A := cmat.NewMatrix(N, N)
A0 := cmat.NewMatrix(N, N)
B := cmat.NewMatrix(N, K)
X := cmat.NewMatrix(N, K)
unitrand := cmat.NewFloatUniformSource()
Z.SetFrom(unitrand)
blasd.Mult(A, Z, Z, 1.0, 0.0, gomas.TRANSB)
A0.Copy(A)
B.SetFrom(unitrand)
X.Copy(B)
// A = chol(A) = U.T*U
t.Logf("Unblocked version: nb=%d\n", conf.LB)
lapackd.CHOLFactor(A, gomas.UPPER, conf)
// X = A.-1*B = U.-1*(U.-T*B)
lapackd.CHOLSolve(X, A, gomas.UPPER)
// B = B - A*X
blasd.Mult(B, A0, X, -1.0, 1.0, gomas.NONE)
// ||B - A*X||_1
nrm := lapackd.NormP(B, lapackd.NORM_ONE)
t.Logf("N=%d: ||B - A*X||_1: %e\n", N, nrm)
// A = chol(A) = U.T*U
A.Copy(A0)
B.SetFrom(unitrand)
X.Copy(B)
conf.LB = 16
t.Logf("Blocked version: nb=%d\n", conf.LB)
lapackd.CHOLFactor(A, gomas.UPPER, conf)
// X = A.-1*B = U.-1*(U.-T*B)
lapackd.CHOLSolve(X, A, gomas.UPPER)
// B = B - A*X
blasd.Mult(B, A0, X, -1.0, 1.0, gomas.NONE)
// ||B - A*X||_1
nrm = lapackd.NormP(B, lapackd.NORM_ONE)
t.Logf("N=%d: ||B - A*X||_1: %e\n", N, nrm)
}
示例10: TestQLBuildwithK
func TestQLBuildwithK(t *testing.T) {
var dc cmat.FloatMatrix
M := 711
N := 707
K := 691
lb := 36
conf := gomas.NewConf()
A := cmat.NewMatrix(M, N)
src := cmat.NewFloatNormSource()
A.SetFrom(src)
tau := cmat.NewMatrix(N, 1)
W := cmat.NewMatrix(M+N, 1)
C := cmat.NewMatrix(N, N)
conf.LB = lb
lapackd.QLFactor(A, tau, W, conf)
A1 := cmat.NewCopy(A)
conf.LB = 0
lapackd.QLBuild(A, tau, W, K, conf)
blasd.Mult(C, A, A, 1.0, 0.0, gomas.TRANSA, conf)
dc.Diag(C)
blasd.Add(&dc, -1.0)
if N < 10 {
t.Logf("unblk.QLBuild Q:\n%v\n", A)
t.Logf("unblk.QLBuild Q.T*Q:\n%v\n", C)
}
n0 := lapackd.NormP(C, lapackd.NORM_ONE)
conf.LB = lb
W1 := lapackd.Workspace(lapackd.QLBuildWork(A1, conf))
lapackd.QLBuild(A1, tau, W1, K, conf)
if N < 10 {
t.Logf("blk.QLBuild Q:\n%v\n", A1)
}
// compute: I - Q.T*Q
blasd.Mult(C, A1, A1, 1.0, 0.0, gomas.TRANSA, conf)
blasd.Add(&dc, -1.0)
n1 := lapackd.NormP(C, lapackd.NORM_ONE)
blasd.Plus(A, A1, 1.0, -1.0, gomas.NONE)
n2 := lapackd.NormP(A, lapackd.NORM_ONE)
t.Logf("M=%d, N=%d, K=%d ||unblk.QLBuild(A) - blk.QLBuild(A)||_1 :%e\n", M, N, K, n2)
t.Logf("unblk M=%d, N=%d, K=%d ||Q.T*Q - I||_1 : %e\n", M, N, K, n0)
t.Logf("blk M=%d, N=%d, K=%d ||Q.T*Q - I||_1 : %e\n", M, N, K, n1)
}
示例11: test_trdevd
func test_trdevd(N, flags, kind int, verbose bool, t *testing.T) {
var At, sD, sE, tmp cmat.FloatMatrix
A0 := cmat.NewMatrix(N, N)
desc := setTrdDiagonals(A0, kind)
At.SubMatrix(A0, 0, 0, N, N)
sD.Diag(A0, 0)
sE.Diag(A0, 1)
D := cmat.NewCopy(&sD)
E := cmat.NewCopy(&sE)
V := cmat.NewMatrix(N, N)
sD.Diag(V, 0)
sD.Add(1.0)
W := cmat.NewMatrix(4*N, 1)
C := cmat.NewMatrix(N, N)
if verbose && N < 10 {
t.Logf("A0:\n%v\n", A0.ToString("%6.3f"))
t.Logf("V.pre:\n%v\n", V.ToString("%6.3f"))
}
lapackd.TRDEigen(D, E, V, W, flags|gomas.WANTV)
for k := 0; k < N-1; k++ {
if E.GetAt(k) != 0.0 {
t.Logf("E[%d] != 0.0 (%e)\n", k, E.GetAt(k))
}
}
blasd.Mult(C, V, V, 1.0, 0.0, gomas.TRANSB)
sD.Diag(C)
sD.Add(-1.0)
nrmv := lapackd.NormP(C, lapackd.NORM_ONE)
blasd.Mult(C, V, A0, 1.0, 0.0, gomas.TRANSA)
blasd.Mult(&At, C, V, 1.0, 0.0, gomas.NONE)
if verbose && N < 10 {
t.Logf("D:\n%v\n", asRow(&tmp, D).ToString("%6.3f"))
t.Logf("V:\n%v\n", V.ToString("%6.3f"))
t.Logf("V.T*A*V\n%v\n", At.ToString("%6.3f"))
}
sD.Diag(&At)
blasd.Axpy(&sD, D, -1.0)
nrma := lapackd.NormP(&At, lapackd.NORM_ONE)
t.Logf("N=%d [%s] ||V.T*A*V - eigen(A)||_1: %e\n", N, desc, nrma)
t.Logf(" ||I - V.T*V||_1: %e\n", nrmv)
}
示例12: TestLQBuild
func TestLQBuild(t *testing.T) {
var dc cmat.FloatMatrix
M := 877
N := 913
K := 831
lb := 48
conf := gomas.NewConf()
_ = lb
A := cmat.NewMatrix(M, N)
src := cmat.NewFloatNormSource()
A.SetFrom(src)
tau := cmat.NewMatrix(M, 1)
W := cmat.NewMatrix(M, 1)
C := cmat.NewMatrix(M, M)
dc.Diag(C)
conf.LB = lb
lapackd.LQFactor(A, tau, W, conf)
A1 := cmat.NewCopy(A)
conf.LB = 0
lapackd.LQBuild(A, tau, W, K, conf)
if N < 10 {
t.Logf("unblk.LQBuild Q:\n%v\n", A)
}
blasd.Mult(C, A, A, 1.0, 0.0, gomas.TRANSB, conf)
blasd.Add(&dc, -1.0)
n0 := lapackd.NormP(C, lapackd.NORM_ONE)
conf.LB = lb
W2 := lapackd.Workspace(lapackd.LQBuildWork(A, conf))
lapackd.LQBuild(A1, tau, W2, K, conf)
if N < 10 {
t.Logf("blk.LQBuild Q:\n%v\n", A1)
}
blasd.Mult(C, A1, A1, 1.0, 0.0, gomas.TRANSB, conf)
blasd.Add(&dc, -1.0)
n1 := lapackd.NormP(C, lapackd.NORM_ONE)
blasd.Plus(A, A1, 1.0, -1.0, gomas.NONE)
n2 := lapackd.NormP(A, lapackd.NORM_ONE)
t.Logf("M=%d, N=%d, K=%d ||unblk.LQBuild(A) - blk.LQBuild(A)||_1 :%e\n", M, N, K, n2)
t.Logf("unblk M=%d, N=%d, K=%d ||I - Q*Q.T||_1 : %e\n", M, N, K, n0)
t.Logf(" blk M=%d, N=%d, K=%d ||I - Q*Q.T||_1 : %e\n", M, N, K, n1)
}
示例13: TestGivensLQ
// Simple and slow LQ decomposition with Givens rotations
func TestGivensLQ(t *testing.T) {
var d cmat.FloatMatrix
M := 149
N := 167
A := cmat.NewMatrix(M, N)
A1 := cmat.NewCopy(A)
ones := cmat.NewFloatConstSource(1.0)
src := cmat.NewFloatNormSource()
A.SetFrom(src)
A0 := cmat.NewCopy(A)
Qt := cmat.NewMatrix(N, N)
d.Diag(Qt)
d.SetFrom(ones)
// R = G(n)...G(2)G(1)*A; Q = G(1).T*G(2).T...G(n).T ; Q.T = G(n)...G(2)G(1)
for i := 0; i < M; i++ {
// zero elements right of diagonal
for j := N - 2; j >= i; j-- {
c, s, r := lapackd.ComputeGivens(A.Get(i, j), A.Get(i, j+1))
A.Set(i, j, r)
A.Set(i, j+1, 0.0)
// apply rotation to this column starting from row i+1
lapackd.ApplyGivensRight(A, j, j+1, i+1, M-i-1, c, s)
// update Qt = G(k)*Qt
lapackd.ApplyGivensRight(Qt, j, j+1, 0, N, c, s)
}
}
// A = L*Q
blasd.Mult(A1, A, Qt, 1.0, 0.0, gomas.TRANSB)
blasd.Plus(A0, A1, 1.0, -1.0, gomas.NONE)
nrm := lapackd.NormP(A0, lapackd.NORM_ONE)
t.Logf("M=%d, N=%d ||A - L*G(1)..G(n)||_1: %e\n", M, N, nrm)
}
示例14: TestSolveQR
// test: min ||X|| s.t A.T*X = B
func TestSolveQR(t *testing.T) {
M := 799
N := 711
K := 241
nb := 32
conf := gomas.NewConf()
conf.LB = nb
tau := cmat.NewMatrix(N, 1)
A := cmat.NewMatrix(M, N)
src := cmat.NewFloatNormSource()
A.SetFrom(src)
A0 := cmat.NewCopy(A)
B0 := cmat.NewMatrix(M, K)
B0.SetFrom(src)
B := cmat.NewCopy(B0)
W := lapackd.Workspace(lapackd.QRFactorWork(A, conf))
lapackd.QRFactor(A, tau, W, conf)
lapackd.QRSolve(B, A, tau, W, gomas.TRANS, conf)
var Bmin cmat.FloatMatrix
Bmin.SubMatrix(B0, 0, 0, N, K)
blasd.Mult(&Bmin, A0, B, 1.0, -1.0, gomas.TRANSA, conf)
nrm := lapackd.NormP(&Bmin, lapackd.NORM_ONE)
t.Logf("M=%d, N=%d ||B - A.T*X||_1: %e\n", M, N, nrm)
}
示例15: blockedLUnoPiv
// blocked LU decomposition w/o pivots, FLAME LU nopivots variant 5
func blockedLUnoPiv(A *cmat.FloatMatrix, nb int, conf *gomas.Config) *gomas.Error {
var err *gomas.Error = nil
var ATL, ATR, ABL, ABR cmat.FloatMatrix
var A00, A01, A02, A10, A11, A12, A20, A21, A22 cmat.FloatMatrix
util.Partition2x2(
&ATL, &ATR,
&ABL, &ABR, A, 0, 0, util.PTOPLEFT)
for m(&ATL) < m(A)-nb {
util.Repartition2x2to3x3(&ATL,
&A00, &A01, &A02,
&A10, &A11, &A12,
&A20, &A21, &A22, A, nb, util.PBOTTOMRIGHT)
// A00 = LU(A00)
unblockedLUnoPiv(&A11, conf)
// A12 = trilu(A00)*A12.-1 (TRSM)
blasd.SolveTrm(&A12, &A11, 1.0, gomas.LEFT|gomas.LOWER|gomas.UNIT)
// A21 = A21.-1*triu(A00) (TRSM)
blasd.SolveTrm(&A21, &A11, 1.0, gomas.RIGHT|gomas.UPPER)
// A22 = A22 - A21*A12
blasd.Mult(&A22, &A21, &A12, -1.0, 1.0, gomas.NONE)
util.Continue3x3to2x2(
&ATL, &ATR,
&ABL, &ABR, &A00, &A11, &A22, A, util.PBOTTOMRIGHT)
}
// last block
if m(&ATL) < m(A) {
unblockedLUnoPiv(&ABR, conf)
}
return err
}