Пример #1
0
func TestCorrMultiStrideNaive_vsDecimate(t *testing.T) {
	const (
		numIn = 4
		eps   = 1e-9
	)
	for _, q := range strideCases {
		f := randMulti(q.ImSize.X, q.ImSize.Y, numIn)
		g := randMulti(q.TmplSize.X, q.TmplSize.Y, numIn)
		h, err := slide.CorrMulti(f, g)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		want := slide.Decimate(h, q.K)
		got, err := slide.CorrMultiStrideNaive(f, g, q.K)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		if err := errIfNotEqImage(want, got, eps); err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
	}
}
Пример #2
0
func TestCorrMultiStrideBLAS_vsNaive(t *testing.T) {
	const (
		numIn = 4
		eps   = 1e-9
	)
	for _, q := range strideCases {
		f := randMulti(q.ImSize.X, q.ImSize.Y, numIn)
		g := randMulti(q.TmplSize.X, q.TmplSize.Y, numIn)
		naive, err := slide.CorrMultiStrideNaive(f, g, q.K)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		blas, err := slide.CorrMultiStrideBLAS(f, g, q.K)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		if err := errIfNotEqImage(naive, blas, eps); err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
	}
}