def __call__(self, out_mesh): from scipy.linalg import inv out_mesh = mesh.coordify(out_mesh) dimension = len(out_mesh[0]) self.C = self.eval_BF(out_mesh, out_mesh) A = self.eval_BF(self.in_mesh, out_mesh) V = np.zeros([len(self.in_mesh), dimension + 1]) V[:, 0] = 1 V[:, 1:] = self.in_mesh Q = np.zeros([len(out_mesh), dimension + 1]) Q[:, 0] = 1 Q[:, 1:] = out_mesh # Q, V = V, Q # Swap f_xi = self.in_vals QQ, QR = scipy.linalg.qr(Q, mode="economic") epsilon = V.T @ f_xi eta = A.T @ f_xi mu = np.linalg.solve(self.C, eta) tau = Q.T @ mu - epsilon sigma = (QQ @ inv(QR).T) @ tau output = mu - sigma # output = sigma # ST = inv(P).T @ Pt.T - (QQ @ inv(QR).T) @ (Q.T @ inv(P).T @ Pt.T + V.T) return output
def __call__(self, out_mesh): out_mesh = mesh.coordify(out_mesh) dimension = len(out_mesh[0]) polyparams = dimension + 1 # polyparams = 0 C = np.zeros([len(out_mesh) + polyparams, len(out_mesh) + polyparams]) C[0, polyparams:] = 1 C[1:polyparams, polyparams:] = out_mesh.T C[polyparams:, 0] = 1 C[polyparams:, 1:polyparams] = out_mesh C[polyparams:, polyparams:] = self.eval_BF(out_mesh, out_mesh) A = np.zeros([len(self.in_mesh), len(out_mesh) + polyparams]) A[:, 0] = 1 A[:, 1:polyparams] = self.in_mesh A[:, polyparams:] = self.eval_BF(self.in_mesh, out_mesh) au = A.T @ self.in_vals out_vals = np.linalg.solve(C, au)[polyparams:] if self.rescale: au_rescaled = self.eval_BF(self.in_mesh, out_mesh).T @ np.ones_like(self.in_vals) out_vals = out_vals / np.linalg.solve( self.eval_BF(out_mesh, out_mesh), au_rescaled) return out_vals
def __call__(self, out_mesh): out_mesh = mesh.coordify(out_mesh) A = self.eval_BF(out_mesh, self.in_mesh) V = np.zeros([out_mesh.shape[0], out_mesh.shape[1] + 1]) V[:, 0] = 1 V[:, 1:] = out_mesh out_vals = A @ self.gamma if self.rescaled: out_vals = out_vals / (A @ self.gamma_rescaled) return out_vals + V @ self.beta
def __init__(self, basisfunction, in_mesh, in_vals, rescale=False): in_mesh = mesh.coordify(in_mesh) self.in_mesh, self.basisfunction = in_mesh, basisfunction Q = np.zeros([in_mesh.shape[0], in_mesh.shape[1] + 1]) Q[:, 0] = 1 Q[:, 1:] = in_mesh lsqrRes = scipy.sparse.linalg.lsqr(Q, in_vals) self.beta = lsqrRes[0] self.C = self.eval_BF(in_mesh, in_mesh) rhs = in_vals - Q @ self.beta self.gamma = np.linalg.solve(self.C, rhs) self.rescaled = rescale if rescale: self.gamma_rescaled = np.linalg.solve(self.C, np.ones_like(self.gamma))
def __init__(self, basisfunction, in_mesh, in_vals): self.basisfunction, self.in_vals = basisfunction, in_vals self.in_mesh = mesh.coordify(in_mesh)
def __init__(self, basisfunction, in_mesh, in_vals, rescale=False): self.basisfunction, self.in_vals, self.rescale = basisfunction, in_vals, rescale self.in_mesh = mesh.coordify(in_mesh)