Exemple #1
0
func RandomTree(nbits uint) (m1 arith.Model, desc string) {
	x1 := arith.Shift2{
		P0: arith.P(rand.Intn(arith.MaxP / 2)),
		I0: byte(rand.Intn(8) + 1),
		P1: arith.P(rand.Intn(arith.MaxP / 2)),
		I1: byte(rand.Intn(8) + 1),
	}

	m1 = arith.NewTree(nbits, func() arith.Model {
		x := x1
		return &x
	})

	desc = fmt.Sprintf("%#v", x1)
	return
}
Exemple #2
0
func RandomModel() (m1, m2 arith.Model, desc string) {
	switch rand.Intn(1) {
	case 0:
		x1 := arith.Shift2{
			P0: arith.P(rand.Intn(arith.MaxP / 2)),
			I0: byte(rand.Intn(8) + 1),
			P1: arith.P(rand.Intn(arith.MaxP / 2)),
			I1: byte(rand.Intn(8) + 1),
		}
		x2 := x1
		m1, m2 = &x1, &x2
	case 1:
		x1 := arith.Shift4{
			P: [4]arith.P{
				arith.P(rand.Intn(arith.MaxP / 4)),
				arith.P(rand.Intn(arith.MaxP / 4)),
				arith.P(rand.Intn(arith.MaxP / 4)),
				arith.P(rand.Intn(arith.MaxP / 4)),
			},
			I: [4]byte{
				byte(rand.Intn(7) + 1),
				byte(rand.Intn(7) + 1),
				byte(rand.Intn(7) + 1),
				byte(rand.Intn(7) + 1),
			},
		}
		x2 := x1
		m1, m2 = &x1, &x2
	}
	desc = fmt.Sprintf("%#v", m1)
	return
}