def build(self, dcf): from qmpy.lib.math import lowertriang, rqmatrix if len(self) == 0: self.lhs = None self.rhs = None return drhs = self.daterhs() outer = self.inner N = len(outer) K = len(drhs) lhs = sparsecf(N,N) rhs = sparsecf(N,K) row = 0 for cfs in self.itervalues(): for kv in cfs: dte = kv.key cf = kv.value if drhs.has_key(dte): col = drhs.index(dte)[0] rhs.append(row,col,cf) else: col = outer.index(dte)[0] lhs.append(row,col,cf) row += 1 self.lhs = lhs self.rhs = rhs trhs = rqmatrix(K) k = 0 for d in drhs: trhs[k] = dcf(d.key) self.trhs = trhs
def build(self, dcf): from qmpy.lib.math import lowertriang, rqmatrix if len(self) == 0: self.lhs = None self.rhs = None return drhs = self.daterhs() outer = self.inner N = len(outer) K = len(drhs) lhs = sparsecf(N, N) rhs = sparsecf(N, K) row = 0 for cfs in self.itervalues(): for kv in cfs: dte = kv.key cf = kv.value if drhs.has_key(dte): col = drhs.index(dte)[0] rhs.append(row, col, cf) else: col = outer.index(dte)[0] lhs.append(row, col, cf) row += 1 self.lhs = lhs self.rhs = rhs trhs = rqmatrix(K) k = 0 for d in drhs: trhs[k] = dcf(d.key) self.trhs = trhs
def getmatrices(self): from qmpy.lib.core import lowertriang, rqmatrix trhs = self.trhs if trhs == None: return None,None,None lhs = self.lhs rhs = self.rhs N = lhs.rows K = rhs.cols if self.lowertriang: LHS = lowertriang(N) else: LHS = rqmatrix(N,N) RHS = rqmatrix(N,K) lhs.fill(LHS) rhs.fill(RHS) return LHS,RHS,trhs
def getmatrices(self): from qmpy.lib.core import lowertriang, rqmatrix trhs = self.trhs if trhs == None: return None, None, None lhs = self.lhs rhs = self.rhs N = lhs.rows K = rhs.cols if self.lowertriang: LHS = lowertriang(N) else: LHS = rqmatrix(N, N) RHS = rqmatrix(N, K) lhs.fill(LHS) rhs.fill(RHS) return LHS, RHS, trhs