當前位置: 首頁>>代碼示例>>Golang>>正文


Golang matrix.FloatMatrixFromTable函數代碼示例

本文整理匯總了Golang中github.com/henrylee2cn/algorithm/matrix.FloatMatrixFromTable函數的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrixFromTable函數的具體用法?Golang FloatMatrixFromTable怎麽用?Golang FloatMatrixFromTable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了FloatMatrixFromTable函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: _TestRankSmall

func _TestRankSmall(t *testing.T) {
	bM := 5
	bN := 5
	//bP := 5
	Adata := [][]float64{
		[]float64{1.0, 1.0, 1.0, 1.0, 1.0},
		[]float64{2.0, 2.0, 2.0, 2.0, 2.0},
		[]float64{3.0, 3.0, 3.0, 3.0, 3.0},
		[]float64{4.0, 4.0, 4.0, 4.0, 4.0},
		[]float64{5.0, 5.0, 5.0, 5.0, 5.0}}

	A := matrix.FloatMatrixFromTable(Adata, matrix.RowOrder)
	A0 := matrix.FloatMatrixFromTable(Adata, matrix.RowOrder)
	X := matrix.FloatVector([]float64{1.0, 2.0, 3.0, 4.0, 5.0})
	Y := matrix.FloatWithValue(bN, 1, 2.0)

	Ar := A.FloatArray()
	Xr := X.FloatArray()
	Yr := Y.FloatArray()

	blas.GerFloat(X, Y, A0, 1.0)

	DRankMV(Ar, Xr, Yr, 1.0, A.LeadingIndex(), 1, 1, 0, bN, 0, bM, 4, 4)
	ok := A0.AllClose(A)
	t.Logf("A0 == A1: %v\n", ok)
	if !ok {
		t.Logf("blas ger:\n%v\n", A0)
		t.Logf("A1: \n%v\n", A)
	}
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:30,代碼來源:trank_test.go

示例2: TestTrsmUnblk

func TestTrsmUnblk(t *testing.T) {
	//bN := 7
	Udata3 := [][]float64{
		[]float64{2.0, 2.0, 2.0},
		[]float64{0.0, 3.0, 3.0},
		[]float64{0.0, 0.0, 4.0}}
	U3 := matrix.FloatMatrixFromTable(Udata3, matrix.RowOrder)
	_ = U3

	Ldata3 := [][]float64{
		[]float64{1.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 0.0},
		[]float64{1.0, 2.0, 3.0}}
	L3 := matrix.FloatMatrixFromTable(Ldata3, matrix.RowOrder)
	_ = L3

	bN := 10
	nP := 7
	nb := 4
	L := matrix.FloatNormalSymmetric(bN, matrix.Lower)

	//t.Logf("-- TRSM-UPPER, TRANS, RIGHT, NON_UNIT --")
	//trsmSolve(t, U3, UPPER|TRANSA|RIGHT, false, 2, 0)
	//t.Logf("-- TRSM-UPPER, TRANS, RIGHT, UNIT --")
	//trsmSolve(t, U3, UPPER|TRANSA|UNIT|RIGHT, false, 2, 0)

	t.Logf("-- UNBLK TRSM-LOWER, TRANS, RIGHT, NON-UNIT --")
	trsmSolve(t, L, LOWER|TRANSA|RIGHT, false, nP, 0)
	t.Logf("-- BLK   TRSM-LOWER, TRANS, RIGHT, NON-UNIT --")
	trsmSolve(t, L, LOWER|TRANSA|RIGHT, false, nP, nb)

}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:32,代碼來源:tsolve_test.go

示例3: _TestSyrk2Small

func _TestSyrk2Small(t *testing.T) {
	//bN := 7
	Udata3 := [][]float64{
		[]float64{2.0, 2.0, 2.0},
		[]float64{0.0, 3.0, 3.0},
		[]float64{0.0, 0.0, 4.0}}

	Udata := [][]float64{
		[]float64{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
		[]float64{0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0},
		[]float64{0.0, 0.0, 3.0, 3.0, 3.0, 3.0, 3.0},
		[]float64{0.0, 0.0, 0.0, 4.0, 4.0, 4.0, 4.0},
		[]float64{0.0, 0.0, 0.0, 0.0, 5.0, 5.0, 5.0},
		[]float64{0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0},
		[]float64{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 7.0}}
	U := matrix.FloatMatrixFromTable(Udata, matrix.RowOrder)
	U3 := matrix.FloatMatrixFromTable(Udata3, matrix.RowOrder)
	_ = U
	_ = U3

	Ldata3 := [][]float64{
		[]float64{1.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 0.0},
		[]float64{1.0, 2.0, 3.0}}

	Ldata := [][]float64{
		[]float64{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}}
	L := matrix.FloatMatrixFromTable(Ldata, matrix.RowOrder)
	L3 := matrix.FloatMatrixFromTable(Ldata3, matrix.RowOrder)
	_ = L
	_ = L3

	Adata := [][]float64{
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}}
	Bdata := [][]float64{
		[]float64{7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0},
		[]float64{7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0}}
	_ = Bdata
	A := matrix.FloatMatrixFromTable(Adata)
	//B := matrix.FloatMatrixFromTable(Bdata);
	B := matrix.FloatNormal(7, 2)
	t.Logf("-- SYR2K UPPER --")
	syrk2Test(t, U.Copy(), A, B, UPPER, 4, 2)
	t.Logf("-- SYR2K LOWER --")
	syrk2Test(t, L.Copy(), A, B, LOWER, 4, 2)
	t.Logf("-- SYR2K UPPER, TRANSA --")
	//t.Logf("A: \n%v\n", A.Transpose())
	syrk2Test(t, U.Copy(), A.Transpose(), B.Transpose(), UPPER|TRANSA, 4, 2)
	t.Logf("-- SYR2K LOWER, TRANS --")
	syrk2Test(t, L.Copy(), A.Transpose(), B.Transpose(), LOWER|TRANSA, 4, 2)
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:58,代碼來源:trank_test.go

示例4: _TestBKpivot1

func _TestBKpivot1(t *testing.T) {
	Ldata := [][]float64{
		[]float64{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 5.0, 3.0, 4.0, 5.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}}

	Bdata := [][]float64{
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0}}

	A := matrix.FloatMatrixFromTable(Ldata, matrix.RowOrder)
	X := matrix.FloatMatrixFromTable(Bdata, matrix.RowOrder)
	N := A.Rows()
	B := matrix.FloatZeros(N, 2)
	MultSym(B, A, X, 1.0, 0.0, LOWER|LEFT)
	t.Logf("initial B:\n%v\n", B)
	//N := 8
	//A := matrix.FloatUniformSymmetric(N)
	nb := 0

	W := matrix.FloatWithValue(A.Rows(), 5, 0.0)

	ipiv := make([]int, N, N)
	L, _ := DecomposeBK(A.Copy(), W, ipiv, LOWER, nb)
	t.Logf("ipiv: %v\n", ipiv)
	t.Logf("L:\n%v\n", L)

	ipiv0 := make([]int, N, N)
	nb = 4
	L0, _ := DecomposeBK(A.Copy(), W, ipiv0, LOWER, nb)
	t.Logf("ipiv: %v\n", ipiv0)
	t.Logf("L:\n%v\n", L0)
	B0 := B.Copy()
	SolveBK(B0, L0, ipiv0, LOWER)
	t.Logf("B0:\n%v\n", B0)

	ipiv2 := make([]int32, N, N)
	lapack.SytrfFloat(A, ipiv2, linalg.OptLower)
	t.Logf("ipiv2: %v\n", ipiv2)
	t.Logf("lapack A:\n%v\n", A)
	lapack.Sytrs(A, B, ipiv2, linalg.OptLower)
	t.Logf("lapack B:\n%v\n", B)
	t.Logf("B == B0: %v\n", B.AllClose(B0))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:53,代碼來源:ldlbkl_test.go

示例5: _TestBKpivot2n2U

func _TestBKpivot2n2U(t *testing.T) {
	Ldata := [][]float64{
		[]float64{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
		[]float64{1.0, 2.0, 2.0, 2.0, 5.0, 2.0, 2.0},
		[]float64{1.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 4.0, 4.0, 10.0},
		[]float64{1.0, 5.0, 3.0, 4.0, 5.0, 9.0, 5.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 9.0, 6.0, 6.0},
		[]float64{1.0, 2.0, 3.0, 10.0, 5.0, 6.0, 7.0}}

	Bdata := [][]float64{
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0},
		[]float64{10.0, 20.0}}

	A := matrix.FloatMatrixFromTable(Ldata, matrix.RowOrder)
	X := matrix.FloatMatrixFromTable(Bdata, matrix.RowOrder)
	N := A.Rows()
	B := matrix.FloatZeros(N, 2)
	MultSym(B, A, X, 1.0, 0.0, UPPER|LEFT)
	//t.Logf("initial B:\n%v\n", B)

	nb := 0
	W := matrix.FloatWithValue(A.Rows(), 5, 0.0)
	ipiv := make([]int, N, N)
	L, _ := DecomposeBK(A.Copy(), W, ipiv, UPPER, nb)
	t.Logf("ipiv: %v\n", ipiv)
	t.Logf("L:\n%v\n", L)

	//ipiv0 := make([]int, N, N)
	//nb = 4
	//L0, _ := DecomposeBK(A.Copy(), W, ipiv0, UPPER, nb)
	//t.Logf("ipiv: %v\n", ipiv0)
	//t.Logf("L:\n%v\n", L0)
	//B0 := B.Copy()
	//SolveBK(B0, L0, ipiv0, UPPER)
	//t.Logf("B0:\n%v\n", B0)

	ipiv2 := make([]int32, N, N)
	lapack.SytrfFloat(A, ipiv2, linalg.OptUpper)
	t.Logf("ipiv2: %v\n", ipiv2)
	t.Logf("lapack A:\n%v\n", A)
	//lapack.Sytrs(A, B, ipiv2, linalg.OptUpper)
	//t.Logf("lapack B:\n%v\n", B)
	//t.Logf("B == B0: %v\n", B.AllClose(B0))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:50,代碼來源:ldlbku_test.go

示例6: _TestTrmmUnblkSmall

func _TestTrmmUnblkSmall(t *testing.T) {

	U := matrix.FloatMatrixFromTable(upper7, matrix.RowOrder)
	U3 := matrix.FloatMatrixFromTable(upper3, matrix.RowOrder)
	_ = U
	_ = U3

	L := matrix.FloatMatrixFromTable(lower7, matrix.RowOrder)
	L3 := matrix.FloatMatrixFromTable(lower3, matrix.RowOrder)
	_ = L

	t.Logf("-- TRMM-UPPER, NON-UNIT ---")
	fail(t, trmmTest(t, U3, UPPER, 0))
	t.Logf("-- TRMM-UPPER, UNIT ---")
	fail(t, trmmTest(t, U3, UPPER|UNIT, 0))
	t.Logf("-- TRMM-UPPER, NON-UNIT, TRANSA ---")
	fail(t, trmmTest(t, U3, UPPER|TRANSA, 0))
	t.Logf("-- TRMM-UPPER, UNIT, TRANSA ---")
	fail(t, trmmTest(t, U3, UPPER|TRANSA|UNIT, 0))
	t.Logf("-- TRMM-LOWER, NON-UNIT ---")
	fail(t, trmmTest(t, L3, LOWER, 0))
	t.Logf("-- TRMM-LOWER, UNIT ---")
	fail(t, trmmTest(t, L3, LOWER|UNIT, 0))
	t.Logf("-- TRMM-LOWER, NON-UNIT, TRANSA ---")
	fail(t, trmmTest(t, L3, LOWER|TRANSA, 0))
	t.Logf("-- TRMM-LOWER, UNIT, TRANSA ---")
	fail(t, trmmTest(t, L3, LOWER|TRANSA|UNIT, 0))

	t.Logf("-- TRMM-UPPER, NON-UNIT, RIGHT ---")
	fail(t, trmmTest(t, U3, UPPER|RIGHT, 0))
	t.Logf("-- TRMM-UPPER, UNIT, RIGHT ---")
	fail(t, trmmTest(t, U3, UPPER|UNIT|RIGHT, 0))

	t.Logf("-- TRMM-LOWER, NON-UNIT, RIGHT ---")
	fail(t, trmmTest(t, L3, LOWER|RIGHT, 0))
	t.Logf("-- TRMM-LOWER, UNIT, RIGHT ---")
	fail(t, trmmTest(t, L3, LOWER|UNIT|RIGHT, 0))

	t.Logf("-- TRMM-UPPER, NON-UNIT, RIGHT, TRANSA ---")
	fail(t, trmmTest(t, U3, UPPER|RIGHT|TRANSA, 0))
	t.Logf("-- TRMM-UPPER, UNIT, RIGHT, TRANSA ---")
	fail(t, trmmTest(t, U3, UPPER|UNIT|RIGHT|TRANSA, 0))

	t.Logf("-- TRMM-LOWER, NON-UNIT, RIGHT, TRANSA ---")
	fail(t, trmmTest(t, L3, LOWER|RIGHT|TRANSA, 0))
	t.Logf("-- TRMM-LOWER, UNIT, RIGHT, TRANSA ---")
	fail(t, trmmTest(t, L3, LOWER|UNIT|RIGHT|TRANSA, 0))

}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:49,代碼來源:ttrm_test.go

示例7: TestQRSmal

func TestQRSmal(t *testing.T) {
	data := [][]float64{
		[]float64{12.0, -51.0, 4.0},
		[]float64{6.0, 167.0, -68.0},
		[]float64{-4.0, 24.0, -41.0}}

	A := matrix.FloatMatrixFromTable(data, matrix.RowOrder)
	T := matrix.FloatZeros(A.Cols(), A.Cols())
	T0 := T.Copy()

	M := A.Rows()
	//N := A.Cols()
	Tau := matrix.FloatZeros(M, 1)
	X, _ := DecomposeQR(A.Copy(), Tau, nil, 0)
	t.Logf("A\n%v\n", A)
	t.Logf("X\n%v\n", X)
	t.Logf("Tau\n%v\n", Tau)

	Tau0 := matrix.FloatZeros(M, 1)
	lapack.Geqrf(A, Tau0)
	t.Logf("lapack X\n%v\n", A)
	t.Logf("lapack Tau\n%v\n", Tau0)

	unblkQRBlockReflector(X, Tau, T)
	t.Logf("T:\n%v\n", T)

	V := TriLU(X.Copy())
	lapack.LarftFloat(V, Tau, T0)
	t.Logf("T0:\n%v\n", T0)

}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:31,代碼來源:decomp_test.go

示例8: TestTrmvSmall

func TestTrmvSmall(t *testing.T) {

	L := matrix.FloatMatrixFromTable(lower5, matrix.RowOrder)
	U := L.Transpose()
	nb := 0

	t.Logf("-- TRMV, LOWER --")
	trmvTest(t, L, LOWER, nb)
	t.Logf("-- TRMV, UPPER --")
	trmvTest(t, U, UPPER, nb)

	t.Logf("-- TRMV, LOWER, UNIT --")
	trmvTest(t, L, LOWER|UNIT, nb)
	t.Logf("-- TRMV, UPPER, UNIT --")
	trmvTest(t, U, UPPER|UNIT, nb)

	t.Logf("-- TRMV, LOWER, TRANS --")
	trmvTest(t, L, LOWER|TRANS, nb)
	t.Logf("-- TRMV, UPPER, TRANS --")
	trmvTest(t, U, UPPER|TRANS, nb)

	t.Logf("-- TRMV, LOWER, TRANS, UNIT --")
	trmvTest(t, L, LOWER|UNIT|TRANS, nb)
	t.Logf("-- TRMV, UPPER, TRANS, UNIT --")
	trmvTest(t, U, UPPER|UNIT|TRANS, nb)
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:26,代碼來源:ttrm_test.go

示例9: _TestSolveBlockedSmall

func _TestSolveBlockedSmall(t *testing.T) {

	L := matrix.FloatMatrixFromTable(lower5, matrix.RowOrder)
	N := L.Rows()
	nb := 4

	U := L.Transpose()
	X0 := matrix.FloatWithValue(L.Rows(), 1, 1.0)
	X1 := X0.Copy()
	xsum := 0.0
	for i := 0; i < N; i++ {
		xsum += float64(i)
		X0.Add(xsum, i)
		X1.Add(xsum, -(i + 1))
	}

	t.Logf("-- SOLVE LOWER, NON-UNIT ---\n")
	solveMVTest(t, L, X0.Copy(), LOWER, N, nb)
	t.Logf("-- SOLVE UPPER, NON-UNIT ---\n")
	solveMVTest(t, U, X1.Copy(), UPPER, N, nb)

	t.Logf("-- SOLVE LOWER, UNIT ---\n")
	solveMVTest(t, L, X0.Copy(), LOWER|UNIT, N, nb)
	t.Logf("-- SOLVE UPPER, UNIT ---\n")
	solveMVTest(t, U, X1.Copy(), UPPER|UNIT, N, nb)
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:26,代碼來源:tsolve_test.go

示例10: _TestLU3x3Piv

func _TestLU3x3Piv(t *testing.T) {
	Adata2 := [][]float64{
		[]float64{3.0, 2.0, 2.0},
		[]float64{6.0, 4.0, 1.0},
		[]float64{4.0, 6.0, 3.0},
	}
	A := matrix.FloatMatrixFromTable(Adata2, matrix.RowOrder)
	piv := make([]int, A.Rows())
	piv0 := make([]int32, A.Rows())
	A0 := A.Copy()
	t.Logf("start A\n%v\n", A)
	DecomposeBlockSize(0)
	DecomposeLU(A, piv, 0)
	Ld := TriLU(A.Copy())
	Ud := TriU(A.Copy())
	t.Logf("A\n%v\n", A)
	t.Logf("Ld:\n%v\n", Ld)
	t.Logf("Ud:\n%v\n", Ud)
	t.Logf("piv: %v\n", piv)
	t.Logf("result:\n%v\n", matrix.Times(Ld, Ud))
	//t.Logf("A == L*U: %v\n", A0.AllClose(matrix.Times(Ld, Ud)))
	lapack.Getrf(A0, piv0)
	t.Logf("lapack result: piv0 %v\n%v\n", piv0, A0)
	t.Logf("A == A0: %v\n", A0.AllClose(A))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:25,代碼來源:decomp_test.go

示例11: _TestViewUpdate

func _TestViewUpdate(t *testing.T) {
	Adata2 := [][]float64{
		[]float64{4.0, 2.0, 2.0},
		[]float64{6.0, 4.0, 2.0},
		[]float64{4.0, 6.0, 1.0},
	}

	A := matrix.FloatMatrixFromTable(Adata2, matrix.RowOrder)
	N := A.Rows()

	// simple LU decomposition without pivoting
	var A11, a10, a01, a00 matrix.FloatMatrix
	for k := 1; k < N; k++ {
		a00.SubMatrixOf(A, k-1, k-1, 1, 1)
		a01.SubMatrixOf(A, k-1, k, 1, A.Cols()-k)
		a10.SubMatrixOf(A, k, k-1, A.Rows()-k, 1)
		A11.SubMatrixOf(A, k, k)
		//t.Logf("A11: %v  a01: %v\n", A11, a01)
		a10.Scale(1.0 / a00.Float())
		MVRankUpdate(&A11, &a10, &a01, -1.0)
	}

	Ld := TriLU(A.Copy())
	Ud := TriU(A)
	t.Logf("Ld:\n%v\nUd:\n%v\n", Ld, Ud)
	An := matrix.FloatZeros(N, N)
	Mult(An, Ld, Ud, 1.0, 1.0, NOTRANS)
	t.Logf("A == Ld*Ud: %v\n", An.AllClose(An))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:29,代碼來源:simple_test.go

示例12: _TestMultSymmLowerSmall

func _TestMultSymmLowerSmall(t *testing.T) {
	//bM := 5
	bN := 7
	bP := 7
	Adata := [][]float64{
		[]float64{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}}

	A := matrix.FloatMatrixFromTable(Adata, matrix.RowOrder)
	B := matrix.FloatNormal(bN, bP)
	C0 := matrix.FloatZeros(bN, bP)
	C1 := matrix.FloatZeros(bN, bP)

	Ar := A.FloatArray()
	Br := B.FloatArray()
	C1r := C1.FloatArray()

	blas.SymmFloat(A, B, C0, 1.0, 1.0, linalg.OptLower, linalg.OptRight)

	DMultSymm(C1r, Ar, Br, 1.0, 1.0, LOWER|RIGHT, bN, A.LeadingIndex(), bN,
		bN, 0, bP, 0, bN, 2, 2, 2)
	ok := C0.AllClose(C1)
	t.Logf("C0 == C1: %v\n", ok)
	if !ok {
		t.Logf("A=\n%v\n", A)
		t.Logf("blas: C=A*B\n%v\n", C0)
		t.Logf("C1: C1 = A*X\n%v\n", C1)
	}
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:34,代碼來源:tmult_test.go

示例13: _TestBKSolve

func _TestBKSolve(t *testing.T) {
	Ldata := [][]float64{
		[]float64{1.0, 2.0, 3.0, 4.0},
		[]float64{2.0, 2.0, 3.0, 4.0},
		[]float64{3.0, 3.0, 3.0, 4.0},
		[]float64{4.0, 4.0, 4.0, 4.0}}
	Xdata := [][]float64{
		[]float64{1.0, 2.0},
		[]float64{1.0, 2.0},
		[]float64{1.0, 2.0},
		[]float64{1.0, 2.0}}

	A := matrix.FloatMatrixFromTable(Ldata, matrix.RowOrder)
	X := matrix.FloatMatrixFromTable(Xdata, matrix.RowOrder)
	N := A.Rows()
	B := matrix.FloatZeros(N, 2)
	Mult(B, A, X, 1.0, 0.0, NOTRANS)
	S := matrix.FloatZeros(N, 2)
	MultSym(S, A, X, 1.0, 0.0, LOWER|LEFT)
	t.Logf("B:\n%v\n", B)
	t.Logf("S:\n%v\n", S)
	//N := 8
	//A := matrix.FloatUniformSymmetric(N)
	nb := 0

	W := matrix.FloatWithValue(A.Rows(), 5, 0.0)

	ipiv := make([]int, N, N)
	L, _ := DecomposeBK(A.Copy(), W, ipiv, LOWER, nb)
	t.Logf("ipiv: %v\n", ipiv)
	t.Logf("L:\n%v\n", L)
	B0 := B.Copy()
	SolveBK(B0, L, ipiv, LOWER)
	t.Logf("B0:\n%v\n", B0)

	ipiv2 := make([]int32, N, N)
	lapack.Sytrf(A, ipiv2, linalg.OptLower)
	t.Logf("ipiv2: %v\n", ipiv2)
	t.Logf("lapack A:\n%v\n", A)
	lapack.Sytrs(A, B, ipiv2, linalg.OptLower)
	t.Logf("lapack B:\n%v\n", B)
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:42,代碼來源:ldlbkl_test.go

示例14: _TestTrmmBlkSmall

func _TestTrmmBlkSmall(t *testing.T) {
	//bN := 7
	Udata := [][]float64{
		[]float64{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
		[]float64{0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0},
		[]float64{0.0, 0.0, 3.0, 3.0, 3.0, 3.0, 3.0},
		[]float64{0.0, 0.0, 0.0, 4.0, 4.0, 4.0, 4.0},
		[]float64{0.0, 0.0, 0.0, 0.0, 5.0, 5.0, 5.0},
		[]float64{0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0},
		[]float64{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 7.0}}
	U := matrix.FloatMatrixFromTable(Udata, matrix.RowOrder)
	_ = U

	Ldata := [][]float64{
		[]float64{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0},
		[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}}
	L := matrix.FloatMatrixFromTable(Ldata, matrix.RowOrder)
	_ = L

	t.Logf("-- TRMM-UPPER, NON-UNIT ---")
	fail(t, trmmTest(t, U, UPPER, 2))
	t.Logf("-- TRMM-UPPER, NON-UNIT, TRANSA ---")
	fail(t, trmmTest(t, U, UPPER|TRANSA, 2))
	t.Logf("-- TRMM-LOWER, NON-UNIT ---")
	fail(t, trmmTest(t, L, LOWER, 2))
	t.Logf("-- TRMM-LOWER, NON-UNIT, TRANSA ---")
	fail(t, trmmTest(t, L, LOWER|TRANSA, 2))
	t.Logf("-- TRMM-UPPER, RIGHT, NON-UNIT ---")
	fail(t, trmmTest(t, U, UPPER|RIGHT, 2))
	t.Logf("-- TRMM-UPPER, RIGHT, NON-UNIT, TRANSA ---")
	fail(t, trmmTest(t, U, UPPER|RIGHT|TRANSA, 2))
	t.Logf("-- TRMM-LOWER, RIGHT, NON-UNIT ---")
	fail(t, trmmTest(t, U, LOWER|RIGHT, 2))
	t.Logf("-- TRMM-LOWER, RIGHT, NON-UNIT, TRANSA ---")
	fail(t, trmmTest(t, U, LOWER|RIGHT|TRANSA, 2))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:41,代碼來源:ttrm_test.go

示例15: _TestLU2x2NoPiv

func _TestLU2x2NoPiv(t *testing.T) {
	Adata2 := [][]float64{
		[]float64{4.0, 3.0},
		[]float64{6.0, 3.0}}

	A := matrix.FloatMatrixFromTable(Adata2, matrix.RowOrder)
	DecomposeBlockSize(0)
	DecomposeLUnoPiv(A, 0)
	t.Logf("A\n%v\n", A)
	Ld := TriLU(A.Copy())
	Ud := TriU(A)
	t.Logf("L*U\n%v\n", matrix.Times(Ld, Ud))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:13,代碼來源:decomp_test.go


注:本文中的github.com/henrylee2cn/algorithm/matrix.FloatMatrixFromTable函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。