def __init__(self, ops, nproc=1, dtype=None): self.ops = ops nops = np.zeros(len(self.ops), dtype=int) for iop, oper in enumerate(ops): if not isinstance(oper, (LinearOperator, spLinearOperator)): self.ops[iop] = MatrixMult(oper, dtype=oper.dtype) nops[iop] = self.ops[iop].shape[0] self.nops = int(nops.sum()) mops = [oper.shape[1] for oper in self.ops] if len(set(mops)) > 1: raise ValueError("operators have different number of columns") self.mops = int(mops[0]) self.nnops = np.insert(np.cumsum(nops), 0, 0) # create pool for multiprocessing self._nproc = nproc self.pool = None if self.nproc > 1: self.pool = mp.Pool(processes=nproc) self.shape = (self.nops, self.mops) if dtype is None: self.dtype = _get_dtype(self.ops) else: self.dtype = np.dtype(dtype) self.explicit = False self.clinear = all( [getattr(oper, "clinear", True) for oper in self.ops])
def __init__(self, ops, nproc=1, dtype=None): self.ops = ops mops = np.zeros(len(ops), dtype=np.int) nops = np.zeros(len(ops), dtype=np.int) for iop, oper in enumerate(ops): if not isinstance(oper, (LinearOperator, spLinearOperator)): self.ops[iop] = MatrixMult(oper, dtype=oper.dtype) nops[iop] = self.ops[iop].shape[0] mops[iop] = self.ops[iop].shape[1] self.nops = int(nops.sum()) self.mops = int(mops.sum()) self.nnops = np.insert(np.cumsum(nops), 0, 0) self.mmops = np.insert(np.cumsum(mops), 0, 0) # create pool for multiprocessing self._nproc = nproc self.pool = None if self.nproc > 1: self.pool = mp.Pool(processes=nproc) self.shape = (self.nops, self.mops) if dtype is None: self.dtype = _get_dtype(ops) else: self.dtype = np.dtype(dtype) self.explicit = False self.clinear = all( [getattr(oper, 'clinear', True) for oper in self.ops])
def __init__(self, ops, dtype='float64'): self.ops = ops mops = np.zeros(len(ops), dtype=np.int) for iop, op in enumerate(ops): mops[iop] = op.shape[1] self.mops = mops.sum() self.nops = ops[0].shape[0] self.mmops = np.insert(np.cumsum(mops), 0, 0) self.shape = (self.nops, self.mops) if dtype is None: self.dtype = _get_dtype(ops) else: self.dtype = np.dtype(dtype) self.explicit = False
def __init__(self, ops, dtype=None): self.ops = ops mops = np.zeros(len(ops), dtype=np.int) for iop, oper in enumerate(ops): if not isinstance(oper, (LinearOperator, spLinearOperator)): self.ops[iop] = MatrixMult(oper, dtype=oper.dtype) mops[iop] = self.ops[iop].shape[1] self.mops = int(mops.sum()) nops = [oper.shape[0] for oper in self.ops] if len(set(nops)) > 1: raise ValueError('operators have different number of rows') self.nops = int(nops[0]) self.mmops = np.insert(np.cumsum(mops), 0, 0) self.shape = (self.nops, self.mops) if dtype is None: self.dtype = _get_dtype(self.ops) else: self.dtype = np.dtype(dtype) self.explicit = False
def __init__(self, ops, dtype=None): self.ops = ops mops = np.zeros(len(ops), dtype=np.int) nops = np.zeros(len(ops), dtype=np.int) for iop, oper in enumerate(ops): if not isinstance(oper, (LinearOperator, spLinearOperator)): self.ops[iop] = MatrixMult(oper, dtype=oper.dtype) nops[iop] = self.ops[iop].shape[0] mops[iop] = self.ops[iop].shape[1] self.nops = int(nops.sum()) self.mops = int(mops.sum()) self.nnops = np.insert(np.cumsum(nops), 0, 0) self.mmops = np.insert(np.cumsum(mops), 0, 0) self.shape = (self.nops, self.mops) if dtype is None: self.dtype = _get_dtype(ops) else: self.dtype = np.dtype(dtype) self.explicit = False
def __init__(self, ops, chunks=None, compute=(False, False), todask=(False, False), usedelayed=False, dtype=None): self.ops = ops nops = np.zeros(len(ops), dtype=np.int) for iop, oper in enumerate(ops): nops[iop] = oper.shape[0] self.nops = nops.sum() self.mops = ops[0].shape[1] self.nnops = np.insert(np.cumsum(nops), 0, 0) self.shape = (self.nops, self.mops) if dtype is None: self.dtype = _get_dtype(ops) else: self.dtype = np.dtype(dtype) self.chunks = (self.nops, self.mops) if chunks is None else chunks self.compute = compute self.todask = todask self.usedelayed = usedelayed if self.usedelayed: self.todask = (False, False) self.Op = None self.explicit = False