コード例 #1
0
ファイル: ldlbk_test.go プロジェクト: hrautila/gomas
func TestSolveBKLowerBig(t *testing.T) {
	N := 427
	normsrc := cmat.NewFloatNormSource(5.0, 10.0)
	A := cmat.NewMatrix(N, N)
	A.SetFrom(normsrc, cmat.LOWER)

	X := cmat.NewMatrix(N, 2)
	X.SetFrom(normsrc)
	B := cmat.NewCopy(X)
	blasd.MultSym(B, A, X, 1.0, 0.0, gomas.LOWER|gomas.LEFT)

	ipiv := lapackd.NewPivots(N)

	conf := gomas.NewConf()
	conf.LB = 16
	W := lapackd.Workspace(lapackd.BKFactorWork(A, conf))
	lapackd.BKFactor(A, W, ipiv, gomas.LOWER, conf)

	lapackd.BKSolve(B, A, ipiv, gomas.LOWER, conf)
	ok := B.AllClose(X)
	t.Logf("N=%d unblk.BK(X) == A.-1*B : %v\n", N, ok)
	blasd.Plus(B, X, 1.0, -1.0, gomas.NONE)
	nrm := lapackd.NormP(B, lapackd.NORM_ONE)
	t.Logf("  ||X - A.-1*B||_1: %.4e\n", nrm)

}
コード例 #2
0
ファイル: ldlbk_test.go プロジェクト: hrautila/gomas
func TestBKLowerBig(t *testing.T) {
	N := 411
	normsrc := cmat.NewFloatNormSource(5.0, 10.0)
	A := cmat.NewMatrix(N, N)
	A.SetFrom(normsrc, cmat.LOWER)
	A0 := cmat.NewCopy(A)

	ipiv := lapackd.NewPivots(N)
	ipiv0 := lapackd.NewPivots(N)

	conf := gomas.NewConf()
	conf.LB = 0

	// unblocked
	W := lapackd.Workspace(lapackd.BKFactorWork(A, conf))
	err := lapackd.BKFactor(A, W, ipiv, gomas.LOWER, conf)
	if err != nil {
		t.Logf("unblk.err: %v\n", err)
	}

	// blocked
	conf.LB = 8
	W = lapackd.Workspace(lapackd.BKFactorWork(A0, conf))
	err = lapackd.BKFactor(A0, W, ipiv0, gomas.LOWER, conf)
	if err != nil {
		t.Logf("blk.err: %v\n", err)
	}
	ok := A.AllClose(A0)
	t.Logf("N=%d unblk.A == blk.A : %v\n", N, ok)

	if !ok {
		r, c := errorLoc(A, A0)
		t.Logf("unblk.A != blk.A at: %d, %d\n", r, c)
		for k, _ := range ipiv {
			t.Logf("%3d  %3d  %3d\n", k, ipiv[k], ipiv0[k])
		}
	}
}