本文整理匯總了Golang中github.com/hrautila/cmat.FloatMatrix.AllClose方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrix.AllClose方法的具體用法?Golang FloatMatrix.AllClose怎麽用?Golang FloatMatrix.AllClose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hrautila/cmat.FloatMatrix
的用法示例。
在下文中一共展示了FloatMatrix.AllClose方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestSubMatrixGob
func TestSubMatrixGob(t *testing.T) {
var B, As cmat.FloatMatrix
var network bytes.Buffer
N := 32
A := cmat.NewMatrix(N, N)
zeromean := cmat.NewFloatNormSource()
A.SetFrom(zeromean)
As.SubMatrix(A, 3, 3, N-6, N-6)
enc := gob.NewEncoder(&network)
dec := gob.NewDecoder(&network)
// encode to network
err := enc.Encode(&As)
if err != nil {
t.Logf("encode error: %v\n", err)
t.FailNow()
}
// decode from network
err = dec.Decode(&B)
if err != nil {
t.Logf("decode error: %v\n", err)
t.FailNow()
}
ar, ac := As.Size()
br, bc := B.Size()
t.Logf("As[%d,%d] == B[%d,%d]: %v\n", ar, ac, br, bc, B.AllClose(&As))
}
示例2: TestJSON
func TestJSON(t *testing.T) {
var B cmat.FloatMatrix
var network bytes.Buffer
N := 26
A := cmat.NewMatrix(N, N)
zeromean := cmat.NewFloatNormSource()
A.SetFrom(zeromean)
enc := json.NewEncoder(&network)
dec := json.NewDecoder(&network)
// encode to network
err := enc.Encode(A)
//t.Logf("bytes: %v\n", string(network.Bytes()))
if err != nil {
t.Logf("encode error: %v\n", err)
t.FailNow()
}
// decode from network
err = dec.Decode(&B)
if err != nil {
t.Logf("decode error: %v\n", err)
t.FailNow()
}
t.Logf("A == B: %v\n", B.AllClose(A))
}
示例3: errorLoc
func errorLoc(D, C *cmat.FloatMatrix) (r, c int) {
var dmat, cmat cmat.FloatMatrix
dr, dc := D.Size()
for i := 0; i < dr; i++ {
dmat.SubMatrix(D, i, 0, 1, dc)
cmat.SubMatrix(C, i, 0, 1, dc)
if !dmat.AllClose(&cmat) {
r = i
break
}
}
for i := 0; i < dc; i++ {
dmat.SubMatrix(D, 0, i, dr, 1)
cmat.SubMatrix(C, 0, i, dr, 1)
if !dmat.AllClose(&cmat) {
c = i
break
}
}
return
}
示例4: TestSubMatrixCopy
func TestSubMatrixCopy(t *testing.T) {
var subA, subB cmat.FloatMatrix
M := 9
N := 9
A := cmat.NewMatrix(M, N)
B := cmat.NewMatrix(M, N)
twos := cmat.NewFloatConstSource(2.0)
B.SetFrom(twos)
subA.SubMatrix(A, 1, 1, M-2, N-2)
subB.SubMatrix(B, 1, 1, M-2, N-2)
subA.Copy(&subB)
ok := subA.AllClose(&subB)
if !ok {
t.Logf("copy status: %v\n", ok)
if N < 9 {
t.Logf("subA\n%v\n", subA)
}
}
if N < 10 {
t.Logf("A\n%v\n", A)
}
}