def setUp(self): self.prng = np.random.RandomState(10) n = 8 I = matrix.Identity(n) O = matrix.Ones(n, n) P = workload.Prefix(n) V = matrix.VStack([I, -0.5 * O]) H = matrix.HStack([I, -0.5 * O]) S = matrix.Sum([I, -0.5 * O]) K = matrix.Kronecker([I, V, P]) W = matrix.Weighted(K, 3.0) M = workload.DimKMarginals((2, 3, 4), 2) D = workload.Disjuncts([P, I]) N = workload.AllNormK(n, 2) self.matrices = [I, O, P, V, H, K, O, W, D, N, M]
def select(self): N = self.domain_shape[self.hb_dim] domains = list(self.domain_shape) del domains[self.hb_dim] if self.impl == 'MM': I = matrix.Identity(int(np.prod(domains))) H = HB((N, )).select() elif self.impl == 'sparse': I = matrix.Identity(int(np.prod(domains))).sparse_matrix() H = HB((N, )).select().sparse_matrix() elif self.impl == 'dense': I = matrix.Identity(int(np.prod(domains))).dense_matrix() H = HB((N, )).select().dense_matrix() else: print("Invalid measurement type", self.impl) exit(1) return matrix.Kronecker([I, H])
def strategy(self): return matrix.Kronecker([T.strategy() for T in self._templates])
def select(self): if len(self.domain_shape) == 1: return matrix.Haar(self.domain_shape[0]) return matrix.Kronecker([matrix.Haar(n) for n in self.domain_shape])