def inner0_j1k2(j, k): ''' Calculates the L2 inner product <P_j1, P_k2> Args: j, k: indices for the monomials P_j1, P_k2 Returns: L2 inner product <P_j1, P_k2> ''' s1 = 0 for l in range(j + 1): s1 += alpha(j - l) * alpha(k + l + 1) + beta(k + l + 1) * eta(j - l) return -2 * s1
def norm_p_jk(addr, j, k): ''' This function calculates the value of the normal derivative of the monomial basis partial_{n}p_jk at a point on SG addressed by addr. Args: j, k: indices mentioned in preceding paragraph. addr: address of evaluation point F_w(q_n) given as a string of digits whose first digit is i and whose following digits are those in w. Returns: value of partial_{n}p_jk(F_w(q_n)) ''' # Based on (2.14), (2.20) of the Calculus paper if k == 1: res = norm_f_jk(addr, j, 0) for l in range(j + 1): res += alpha(j - l) * (norm_f_jk(addr, l, 1) + norm_f_jk(addr, l, 2)) if k == 2: res = 0 for l in range(j + 1): res += beta(j - l) * (norm_f_jk(addr, l, 1) + norm_f_jk(addr, l, 2)) if k == 3: res = 0 for l in range(j + 1): res += gamma(j - l) * (norm_f_jk(addr, l, 1) - norm_f_jk(addr, l, 2)) return res
def p_jk(addr, j, k): ''' This function calculates the value of the monomial basis p_jk at a point on SG addressed by addr. This code is based on the Splines on Fractals paper and Calculus on SG I. Args: j, k: indices mentioned in preceding paragraph. addr: address of evaluation point F_w(q_i) given as a string of digits whose first digit is i and whose following digits are those in w. Returns: value of p_jk(F_w(q_i)) ''' # Based on (2.14), (2.20) of the Calculus paper if k == 1: res = f_jk(addr, j, 0) for l in range(j + 1): res += alpha(j - l) * (f_jk(addr, l, 1) + f_jk(addr, l, 2)) if k == 2: res = 0 for l in range(j + 1): res += beta(j - l) * (f_jk(addr, l, 1) + f_jk(addr, l, 2)) if k == 3: res = 0 for l in range(j + 1): res += gamma(j - l) * (f_jk(addr, l, 1) - f_jk(addr, l, 2)) return res
def inner0_j3k3(j, k): ''' Calculates the L2 inner product <P_j3, P_k3> Args: j, k: indices for the monomials P_j3, P_k3 Returns: L2 inner product <P_j3, P_k3> ''' ms = min(j, k) s1 = 0 for l in range(j - ms, j + 1): s1 += alpha(j - l + 1) * eta(k + l + 2) - alpha(k + l + 2) * eta(j - l + 1) return 18 * s1
def inner0_j1k1(j, k): ''' Calculates the L2 inner product <P_j1, P_k1> Args: j, k: indices for the monomials P_j1, P_k1 Returns: L2 inner product <P_j1, P_k1> ''' ms = min(j, k) s1 = 0 for l in range(j - ms, j + 1): s1 += alpha(j - l) * eta(k + l + 1) - alpha(k + l + 1) * eta(j - l) return 2 * s1
def pnj1(nn, j, i): ''' This function calculates the value of P_{j,1}^(n) at q_i Args: nn: corresponds to the value of (n) in P_{j,1}^(n) j: corresponds to the value of j in P_{j,1}^(n) i: corresponds to the boundary index q_i Returns: Value of P_{j,1}^(n) at q_i ''' return int(j == 0) if i == nn else alpha(j)
def inner0_j2k2(j, k): ''' Calculates the L2 inner product <P_j2, P_k2> Args: j, k: indices for the monomials P_j2, P_k Returns: L2 inner product <P_j2, P_k2> ''' ms = min(j, k) s1 = 0 for l in range(j - ms, j + 1): s1 += beta(j - l) * alpha(k + l + 1) - beta(k + l + 1) * ap(j - l) return -2 * s1
def dnpj2(j): return -alpha(j)