def evaluate_at_box(self,k,coeff,n,l,nn,ll,x): if isinstance(x,list) or isinstance(x,Vector): value_list = [] for i in range(len(x)): coordinate = (x[i]+ll)*(2.0**(n-nn))-l p = Vector(phi(coordinate,k)) value_list.append(coeff.inner(p)*math.sqrt(2.0**n)) return Vector(value_list) else: coordinate = (x + ll)*(2.0**(n-nn))-l p = Vector(phi(coordinate,self.k)) value = coeff.inner(p)*math.sqrt(2.0**n) return value
def evaluate_at_box(self, k, coeff, n, l, nn, ll, x): if isinstance(x, list) or isinstance(x, Vector): value_list = [] for i in range(len(x)): coordinate = (x[i] + ll) * (2.0**(n - nn)) - l p = Vector(phi(coordinate, k)) value_list.append(coeff.inner(p) * math.sqrt(2.0**n)) return Vector(value_list) else: coordinate = (x + ll) * (2.0**(n - nn)) - l p = Vector(phi(coordinate, self.k)) value = coeff.inner(p) * math.sqrt(2.0**n) return value
def init_quadrature(self, order): x, w = gauss_legendre(order) self.quad_w = Vector(w) self.quad_x = Vector(x) self.quad_npt = npt = len(w) self.quad_phi = Matrix(npt, self.k) # phi[point,i] self.quad_phiT = Matrix(self.k, npt) # phi[point,i] transpose self.quad_phiw = Matrix(npt, self.k) # phi[point,i]*weight[point] for i in xrange(npt): p = phi(self.quad_x[i], self.k) for m in xrange(self.k): self.quad_phi[i, m] = p[m] self.quad_phiT[m, i] = p[m] self.quad_phiw[i, m] = w[i] * p[m]
def __evaluate(self, n, l, x): ''' eval f(x) using adaptively refined numerical representation of f(x) answer should be within tolerance of the analytical f(x) Descend tree looking for box (n,l) with scaling function coefficients containing the point x. ''' if self.s[n].has_key(l): p = Vector(phi(x, self.k)) return self.s[n][l].inner(p) * math.sqrt(2.0**n) else: n, l, x = n + 1, 2 * l, 2 * x if x >= 1: l, x = l + 1, x - 1 return self.__evaluate(n, l, x)
def __evaluate(self, n, l, x): ''' eval f(x) using adaptively refined numerical representation of f(x) answer should be within tolerance of the analytical f(x) Descend tree looking for box (n,l) with scaling function coefficients containing the point x. ''' if self.s[n].has_key(l): p = Vector(phi(x, self.k)) return self.s[n][l].inner(p)*math.sqrt(2.0**n) else: n, l, x = n + 1, 2 * l, 2 * x if x >= 1: l, x = l + 1, x - 1 return self.__evaluate(n, l, x)