本文整理匯總了Golang中github.com/henrylee2cn/algorithm/matrix.FloatNormal函數的典型用法代碼示例。如果您正苦於以下問題:Golang FloatNormal函數的具體用法?Golang FloatNormal怎麽用?Golang FloatNormal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FloatNormal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: _TestMultMV
func _TestMultMV(t *testing.T) {
bM := 100 * M
bN := 100 * N
A := matrix.FloatNormal(bM, bN)
X := matrix.FloatNormal(bN, 1)
Y1 := matrix.FloatZeros(bM, 1)
Y0 := matrix.FloatZeros(bM, 1)
Ar := A.FloatArray()
Xr := X.FloatArray()
Y1r := Y1.FloatArray()
blas.GemvFloat(A, X, Y0, 1.0, 1.0)
DMultMV(Y1r, Ar, Xr, 1.0, 1.0, NOTRANS, 1, A.LeadingIndex(), 1, 0, bN, 0, bM, 32, 32)
t.Logf("Y0 == Y1: %v\n", Y0.AllClose(Y1))
/*
if ! Y0.AllClose(Y1) {
y0 := Y0.SubMatrix(0, 0, 2, 1)
y1 := Y1.SubMatrix(0, 0, 2, 1)
t.Logf("y0=\n%v\n", y0)
t.Logf("y1=\n%v\n", y1)
}
*/
}
示例2: CTestGemv
func CTestGemv(m, n, p int) (fnc func(), A, X, Y *matrix.FloatMatrix) {
A = matrix.FloatNormal(m, n)
X = matrix.FloatNormal(n, 1)
Y = matrix.FloatZeros(m, 1)
fnc = func() {
blas.GemvFloat(A, X, Y, 1.0, 1.0)
}
return
}
示例3: TestTemplate
func TestTemplate(m, n, p int) (fnc func(), A, X, Y *matrix.FloatMatrix) {
A = matrix.FloatNormal(m, n)
X = matrix.FloatNormal(n, 1)
Y = matrix.FloatZeros(m, 1)
fnc = func() {
// test core here
}
return
}
示例4: TestTemplate
func TestTemplate(m, n, p int) (fnc func(), A, B, C *matrix.FloatMatrix) {
A = matrix.FloatNormal(m, p)
B = matrix.FloatNormal(p, n)
C = matrix.FloatZeros(m, n)
fnc = func() {
// test core here
}
return
}
示例5: MMTestMultTransAB
func MMTestMultTransAB(m, n, p int) (fnc func(), A, B, C *matrix.FloatMatrix) {
A = matrix.FloatNormal(p, m)
B = matrix.FloatNormal(n, p)
C = matrix.FloatZeros(m, n)
fnc = func() {
matops.Mult(C, A, B, 1.0, 1.0, matops.TRANSA|matops.TRANSB)
}
return
}
示例6: MMTestMult
func MMTestMult(m, n, p int) (fnc func(), A, B, C *matrix.FloatMatrix) {
A = matrix.FloatNormal(m, p)
B = matrix.FloatNormal(p, n)
C = matrix.FloatZeros(m, n)
fnc = func() {
matops.Mult(C, A, B, 1.0, 1.0, matops.NOTRANS)
}
return
}
示例7: CTestMVMultTransA
func CTestMVMultTransA(m, n, p int) (fnc func(), A, X, Y *matrix.FloatMatrix) {
A = matrix.FloatNormal(n, m)
X = matrix.FloatNormal(n, 1)
Y = matrix.FloatZeros(m, 1)
fnc = func() {
matops.MVMultTransA(Y, A, X, 1.0, 1.0)
}
return
}
示例8: CTestGemvTransA
func CTestGemvTransA(m, n, p int) (fnc func(), A, X, Y *matrix.FloatMatrix) {
A = matrix.FloatNormal(n, m)
X = matrix.FloatNormal(n, 1)
Y = matrix.FloatZeros(m, 1)
A = A.Transpose()
fnc = func() {
blas.GemvFloat(A, X, Y, 1.0, 1.0, linalg.OptTrans)
}
return
}
示例9: _TestMultMVTransA
func _TestMultMVTransA(t *testing.T) {
bM := 1000 * M
bN := 1000 * N
A := matrix.FloatNormal(bN, bM)
X := matrix.FloatWithValue(bN, 1, 1.0)
Y1 := matrix.FloatZeros(bM, 1)
Y0 := matrix.FloatZeros(bM, 1)
Ar := A.FloatArray()
Xr := X.FloatArray()
Y1r := Y1.FloatArray()
blas.GemvFloat(A, X, Y0, 1.0, 1.0, linalg.OptTrans)
DMultMV(Y1r, Ar, Xr, 1.0, 1.0, TRANSA, 1, A.LeadingIndex(), 1, 0, bN, 0, bM, 4, 4)
ok := Y0.AllClose(Y1)
t.Logf("Y0 == Y1: %v\n", ok)
if !ok {
var y1, y0 matrix.FloatMatrix
Y1.SubMatrix(&y1, 0, 0, 5, 1)
t.Logf("Y1[0:5]:\n%v\n", y1)
Y0.SubMatrix(&y0, 0, 0, 5, 1)
t.Logf("Y0[0:5]:\n%v\n", y0)
}
}
示例10: _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)
}
}
示例11: _TestLDLnoPiv
func _TestLDLnoPiv(t *testing.T) {
N := 42
nb := 8
A0 := matrix.FloatUniform(N, N)
A := matrix.FloatZeros(N, N)
Mult(A, A0, A0, 1.0, 1.0, TRANSB)
B := matrix.FloatNormal(A.Rows(), 2)
w := matrix.FloatWithValue(A.Rows(), 2, 1.0)
// B0 = A*B
B0 := B.Copy()
nb = 2
L, _ := DecomposeLDLnoPiv(A.Copy(), w, LOWER, nb)
Mult(B0, A, B, 1.0, 0.0, NOTRANS)
SolveLDLnoPiv(B0, L, LOWER)
t.Logf("L*D*L.T: ||B - A*X||_1: %e\n", NormP(B0.Minus(B), NORM_ONE))
U, _ := DecomposeLDLnoPiv(A.Copy(), w, UPPER, nb)
Mult(B0, A, B, 1.0, 0.0, NOTRANS)
SolveLDLnoPiv(B0, U, UPPER)
t.Logf("U*D*U.T: ||B - A*X||_1: %e\n", NormP(B0.Minus(B), NORM_ONE))
}
示例12: TestUpdateTrmMV
func TestUpdateTrmMV(t *testing.T) {
//bM := 5
bN := 8
//bP := 4
nb := 4
X := matrix.FloatNormal(bN, 1)
//B := matrix.FloatNormal(bP, bN)
Y := X.Copy()
C0 := matrix.FloatZeros(bN, bN)
C2 := matrix.FloatZeros(bN, bN)
C1 := matrix.FloatZeros(bN, bN)
Xr := X.FloatArray()
Yr := Y.FloatArray()
C1r := C1.FloatArray()
C0r := C0.FloatArray()
C2r := C2.FloatArray()
// no transpose
DRankMV(C1r, Xr, Yr, 1.0, C1.LeadingIndex(), 1, 1,
0, bN, 0, bN, nb, nb)
DTrmUpdMV(C0r, Xr, Yr, 1.0, LOWER, C0.LeadingIndex(), 1, 1,
0, bN, nb)
DTrmUpdMV(C2r, Xr, Yr, 1.0, UPPER, C2.LeadingIndex(), 1, 1,
0, bN, nb)
t.Logf("C1:\n%v\nC0:\n%v\nC2:\n%v\n", C1, C0, C2)
// C0 == C2.T
t.Logf("C0 == C2.T: %v\n", C0.AllClose(C2.Transpose()))
// C1 == C1 - C2 + C0.T
Cn := matrix.Minus(C1, C2)
Cn.Plus(C0.Transpose())
t.Logf("C1 == C1 - C2 + C0.T: %v\n", Cn.AllClose(C1))
}
示例13: TestLDLlower
func TestLDLlower(t *testing.T) {
/*
Ldata := [][]float64{
[]float64{7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
[]float64{7.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0},
[]float64{7.0, 6.0, 5.0, 0.0, 0.0, 0.0, 0.0},
[]float64{7.0, 6.0, 5.0, 4.0, 0.0, 0.0, 0.0},
[]float64{7.0, 6.0, 5.0, 4.0, 6.0, 0.0, 0.0},
[]float64{7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 0.0},
[]float64{7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0}}
A := matrix.FloatMatrixFromTable(Ldata, matrix.RowOrder)
N := A.Rows()
*/
N := 7
nb := 0
A0 := matrix.FloatUniform(N, N)
A := matrix.FloatZeros(N, N)
Mult(A, A0, A0, 1.0, 1.0, TRANSB)
B := matrix.FloatNormal(A.Rows(), 2)
B0 := B.Copy()
B1 := B.Copy()
Mult(B0, A, B, 1.0, 0.0, NOTRANS)
_, _, _ = B0, B1, A0
ipiv := make([]int, N, N)
L, _ := DecomposeLDL(A.Copy(), nil, ipiv, LOWER, 0)
//t.Logf("unblk: ipiv = %v\n", ipiv)
//t.Logf("unblk: L\n%v\n", L)
ApplyRowPivots(B, ipiv, FORWARD)
MultTrm(B, L, 1.0, LOWER|UNIT|TRANSA)
MultDiag(B, L, LEFT)
MultTrm(B, L, 1.0, LOWER|UNIT)
ApplyRowPivots(B0, ipiv, FORWARD)
t.Logf(" unblk: L*D*L.T %d pivots: ||A*B - L*D*L.T*B||_1: %e\n",
NumPivots(ipiv), NormP(B.Minus(B0), NORM_ONE))
t.Logf("pivots: %v\n", ipiv)
nb = 4
w := matrix.FloatWithValue(A.Rows(), nb, 1.0)
L, _ = DecomposeLDL(A.Copy(), w, ipiv, LOWER, nb)
//t.Logf("blk: ipiv = %v\n", ipiv)
//t.Logf("blk: L\n%v\n", L)
// B2 = A*B1 == A*B
B2 := B1.Copy()
Mult(B2, A, B1, 1.0, 0.0, NOTRANS)
ApplyRowPivots(B1, ipiv, FORWARD)
MultTrm(B1, L, 1.0, LOWER|UNIT|TRANSA)
MultDiag(B1, L, LEFT)
MultTrm(B1, L, 1.0, LOWER|UNIT)
ApplyRowPivots(B2, ipiv, FORWARD)
t.Logf(" blk: L*D*L.T %d pivots: ||A*B - L*D*L.T*B||_1: %e\n",
NumPivots(ipiv), NormP(B2.Minus(B1), NORM_ONE))
t.Logf("pivots: %v\n", ipiv)
}
示例14: _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)
}
示例15: CTestBlasUp
func CTestBlasUp(m, n, p int) (fnc func(), A, B, C *matrix.FloatMatrix) {
A = matrix.FloatNormalSymmetric(m, matrix.Lower)
B = matrix.FloatNormal(m, n)
C = matrix.FloatZeros(m, n)
fnc = func() {
blas.SymmFloat(A, B, C, 1.0, 1.0, linalg.OptUpper)
}
return fnc, A, B, C
}