def get_setup(self, shape, shift, density): state = np.random.RandomState(0) column = state.uniform(-1, 1, shape[0]) matrix = state.uniform(-1, 1, (shape[1], shape[1] // 10)) if isinstance(density, int) and density == 1: return cic_matrix((column, shift), shape), matrix else: mask = state.uniform(0, 1, shape[0]) <= density data = column[mask] offsets, = np.nonzero(mask) return cic_matrix((data, offsets, shift), shape), matrix
def get_setup(self, n_blocks, block_shape, block_shift, shift, density): shape = (block_shape[0], n_blocks * block_shape[1]) state = np.random.RandomState(0) column = state.uniform(-1, 1, shape[0]) vector = state.uniform(-1, 1, shape[1]) if isinstance(density, int) and density == 1: cic = cic_matrix((column, block_shift), block_shape) else: mask = state.uniform(0, 1, shape[0]) <= density data = column[mask] offsets, = np.nonzero(mask) cic = cic_matrix((data, offsets, block_shift), block_shape) return chb_matrix((cic.tocsr(), shift), shape), vector