def _hex_orthob_at(order, p, q, r): sk = [mp.sqrt(k + 0.5) for k in xrange(order)] pa = [c*jp for c, jp in zip(sk, jacobi(order - 1, 0, 0, p))] pb = [c*jp for c, jp in zip(sk, jacobi(order - 1, 0, 0, q))] pc = [c*jp for c, jp in zip(sk, jacobi(order - 1, 0, 0, r))] return [pi*pj*pk for pi in pa for pj in pb for pk in pc]
def jac_ortho_basis_at_mp(self, p, q, r): a = 2 * (1 + p) / (1 - q) - 1 if q != 1 else -1 b = q c = r f = jacobi(self.order - 1, 0, 0, a) df = jacobi_diff(self.order - 1, 0, 0, a) pab = [] for i, (fi, dfi) in enumerate(zip(f, df)): g = jacobi(self.order - i - 1, 2 * i + 1, 0, b) dg = jacobi_diff(self.order - i - 1, 2 * i + 1, 0, b) for j, (gj, dgj) in enumerate(zip(g, dg)): cij = mp.sqrt((2 * i + 1) * (2 * i + 2 * j + 2)) / 2 ** (i + 1) tmp = (1 - b) ** (i - 1) if i > 0 else 1 pij = 2 * tmp * dfi * gj qij = tmp * (-i * fi + (1 + a) * dfi) * gj + (1 - b) ** i * fi * dgj rij = (1 - b) ** i * fi * gj pab.append([cij * pij, cij * qij, cij * rij]) sk = [mp.sqrt(k + 0.5) for k in range(self.order)] hc = [s * jp for s, jp in zip(sk, jacobi(self.order - 1, 0, 0, c))] dhc = [s * jp for s, jp in zip(sk, jacobi_diff(self.order - 1, 0, 0, c))] return [[pij * hk, qij * hk, rij * dhk] for pij, qij, rij in pab for hk, dhk in zip(hc, dhc)]
def jac_ortho_basis_at_mp(self, p, q, r): a = 2 * p / (1 - r) if r != 1 else 0 b = 2 * q / (1 - r) if r != 1 else 0 c = r sk = [mp.mpf(2) ** (-k - 0.25) * mp.sqrt(k + 0.5) for k in range(self.order)] fc = [s * jp for s, jp in zip(sk, jacobi(self.order - 1, 0, 0, a))] gc = [s * jp for s, jp in zip(sk, jacobi(self.order - 1, 0, 0, b))] dfc = [s * jp for s, jp in zip(sk, jacobi_diff(self.order - 1, 0, 0, a))] dgc = [s * jp for s, jp in zip(sk, jacobi_diff(self.order - 1, 0, 0, b))] ob = [] for i, (fi, dfi) in enumerate(zip(fc, dfc)): for j, (gj, dgj) in enumerate(zip(gc, dgc)): h = jacobi(self.order - max(i, j) - 1, 2 * (i + j + 1), 0, c) dh = jacobi_diff(self.order - max(i, j) - 1, 2 * (i + j + 1), 0, c) for k, (hk, dhk) in enumerate(zip(h, dh)): ck = mp.sqrt(2 * (k + j + i) + 3) tmp = (1 - c) ** (i + j - 1) if i + j > 0 else 1 pijk = 2 * tmp * dfi * gj * hk qijk = 2 * tmp * fi * dgj * hk rijk = ( tmp * (a * dfi * gj + b * fi * dgj - (i + j) * fi * gj) * hk + (1 - c) ** (i + j) * fi * gj * dhk ) ob.append([ck * pijk, ck * qijk, ck * rijk]) return ob
def ortho_basis_at_mp(self, p, q, r): r = r if r != 1 else r + mp.eps a = 2*p/(1 - r) b = 2*q/(1 - r) c = r sk = [mp.mpf(2)**(-k - 0.25)*mp.sqrt(k + 0.5) for k in xrange(self.order)] pa = [s*jp for s, jp in zip(sk, jacobi(self.order - 1, 0, 0, a))] pb = [s*jp for s, jp in zip(sk, jacobi(self.order - 1, 0, 0, b))] ob = [] for i, pi in enumerate(pa): for j, pj in enumerate(pb): cij = (1 - c)**(i + j) pij = pi*pj pc = jacobi(self.order - max(i, j) - 1, 2*(i + j + 1), 0, c) for k, pk in enumerate(pc): ck = mp.sqrt(2*(k + j + i) + 3) ob.append(cij*ck*pij*pk) return ob
def ortho_basis_at_mp(self, p, q, r): sk = [mp.sqrt(k + 0.5) for k in range(self.order)] pa = [c * jp for c, jp in zip(sk, jacobi(self.order - 1, 0, 0, p))] pb = [c * jp for c, jp in zip(sk, jacobi(self.order - 1, 0, 0, q))] pc = [c * jp for c, jp in zip(sk, jacobi(self.order - 1, 0, 0, r))] return [pi * pj * pk for pi in pa for pj in pb for pk in pc]
def jac_ortho_basis_at_mp(self, p, q): sk = [mp.sqrt(k + 0.5) for k in range(self.order)] pa = [c * jp for c, jp in zip(sk, jacobi(self.order - 1, 0, 0, p))] pb = [c * jp for c, jp in zip(sk, jacobi(self.order - 1, 0, 0, q))] dpa = [c * jp for c, jp in zip(sk, jacobi_diff(self.order - 1, 0, 0, p))] dpb = [c * jp for c, jp in zip(sk, jacobi_diff(self.order - 1, 0, 0, q))] return [[dpi * pj, pi * dpj] for pi, dpi in zip(pa, dpa) for pj, dpj in zip(pb, dpb)]
def _tri_orthob_at(order, p, q): a = 2*(1 + p)/(1 - q) - 1 if q != 1 else 0 b = q ob = [] for i, pi in enumerate(jacobi(order - 1, 0, 0, a)): pa = pi*(1 - b)**i for j, pj in enumerate(jacobi(order - i - 1, 2*i + 1, 0, b)): cij = mp.sqrt((2*i + 1)*(2*i + 2*j + 2)) / 2**(i + 1) ob.append(cij*pa*pj) return ob
def ortho_basis_at_mp(self, p, q): a = 2 * (1 + p) / (1 - q) - 1 if q != 1 else -1 b = q ob = [] for i, pi in enumerate(jacobi(self.order - 1, 0, 0, a)): pa = pi * (1 - b) ** i for j, pj in enumerate(jacobi(self.order - i - 1, 2 * i + 1, 0, b)): cij = mp.sqrt((2 * i + 1) * (2 * i + 2 * j + 2)) / 2 ** (i + 1) ob.append(cij * pa * pj) return ob
def _pri_orthob_at(order, p, q, r): a = 2*(1 + p)/(1 - q) - 1 if q != 1 else 0 b = q c = r pab = [] for i, pi in enumerate(jacobi(order - 1, 0, 0, a)): ci = (1 - b)**i / 2**(i + 1) for j, pj in enumerate(jacobi(order - i - 1, 2*i + 1, 0, b)): cij = mp.sqrt((2*i + 1)*(2*i + 2*j + 2))*ci pab.append(cij*pi*pj) sk = [mp.sqrt(k + 0.5) for k in xrange(order)] pc = [s*jp for s, jp in zip(sk, jacobi(order - 1, 0, 0, c))] return [pij*pk for pij in pab for pk in pc]
def ortho_basis_at_mp(self, p, q, r): q = q if q != 1 else q + mp.eps a = 2*(1 + p)/(1 - q) - 1 b = q c = r pab = [] for i, pi in enumerate(jacobi(self.order - 1, 0, 0, a)): ci = (1 - b)**i / 2**(i + 1) for j, pj in enumerate(jacobi(self.order - i - 1, 2*i + 1, 0, b)): cij = mp.sqrt((2*i + 1)*(2*i + 2*j + 2))*ci pab.append(cij*pi*pj) sk = [mp.sqrt(k + 0.5) for k in xrange(self.order)] pc = [s*jp for s, jp in zip(sk, jacobi(self.order - 1, 0, 0, c))] return [pij*pk for pij in pab for pk in pc]
def ortho_basis_at_mp(self, p, q, r): a = -2 * (1 + p) / (q + r) - 1 if r != -q else -1 b = 2 * (1 + q) / (1 - r) - 1 if r != 1 else -1 c = r ob = [] for i, pi in enumerate(jacobi(self.order - 1, 0, 0, a)): ci = mp.mpf(2) ** (-2 * i - 1) * mp.sqrt(2 * i + 1) * (1 - b) ** i for j, pj in enumerate(jacobi(self.order - i - 1, 2 * i + 1, 0, b)): cj = mp.sqrt(i + j + 1) * 2 ** -j * (1 - c) ** (i + j) cij = ci * cj pij = pi * pj jp = jacobi(self.order - i - j - 1, 2 * (i + j + 1), 0, c) for k, pk in enumerate(jp): ck = mp.sqrt(2 * (k + j + i) + 3) ob.append(cij * ck * pij * pk) return ob
def _tet_orthob_at(order, p, q, r): a = -2*(1 + p)/(q + r) - 1 if q + r != 0 else 0 b = 2*(1 + q)/(1 - r) - 1 if r != 1 else 0 c = r ob = [] for i, pi in enumerate(jacobi(order - 1, 0, 0, a)): ci = mp.mpf(2)**(-2*i - 1.5)*mp.sqrt(4*i + 2)*(1 - b)**i for j, pj in enumerate(jacobi(order - i - 1, 2*i + 1, 0, b)): cj = mp.sqrt(i + j + 1)*2**-j*(1 - c)**(i + j) cij = ci*cj pij = pi*pj jp = jacobi(order - i - j - 1, 2*(i + j + 1), 0, c) for k, pk in enumerate(jp): ck = mp.sqrt(2*(k + j + i) + 3) ob.append(cij*ck*pij*pk) return ob
def jac_ortho_basis_at_mp(self, p, q, r): a = -2 * (1 + p) / (q + r) - 1 if r != -q else -1 b = 2 * (1 + q) / (1 - r) - 1 if r != 1 else -1 c = r f = jacobi(self.order - 1, 0, 0, a) df = jacobi_diff(self.order - 1, 0, 0, a) ob = [] for i, (fi, dfi) in enumerate(zip(f, df)): ci = mp.mpf(2) ** (-2 * i - 1) * mp.sqrt(2 * i + 1) g = jacobi(self.order - i - 1, 2 * i + 1, 0, b) dg = jacobi_diff(self.order - i - 1, 2 * i + 1, 0, b) for j, (gj, dgj) in enumerate(zip(g, dg)): cj = mp.sqrt(i + j + 1) * 2 ** -j cij = ci * cj h = jacobi(self.order - i - j - 1, 2 * (i + j + 1), 0, c) dh = jacobi_diff(self.order - i - j - 1, 2 * (i + j + 1), 0, c) for k, (hk, dhk) in enumerate(zip(h, dh)): ck = mp.sqrt(2 * (k + j + i) + 3) cijk = cij * ck tmp1 = (1 - c) ** (i + j - 1) if i + j > 0 else 1 tmp2 = tmp1 * (1 - b) ** (i - 1) if i > 0 else 1 pijk = 4 * tmp2 * dfi * gj * hk qijk = 2 * (tmp2 * (-i * fi + (1 + a) * dfi) * gj + tmp1 * (1 - b) ** i * fi * dgj) * hk rijk = ( 2 * (1 + a) * tmp2 * dfi * gj * hk + (1 + b) * tmp1 * (1 - b) ** i * fi * dgj * hk + (1 - c) ** (i + j) * (1 - b) ** i * fi * gj * dhk - (i * (1 + b) * tmp2 + (i + j) * tmp1 * (1 - b) ** i) * fi * gj * hk ) ob.append([cijk * pijk, cijk * qijk, cijk * rijk]) return ob
def jac_ortho_basis_at_mp(self, p, q): a = 2 * (1 + p) / (1 - q) - 1 if q != 1 else -1 b = q f = jacobi(self.order - 1, 0, 0, a) df = jacobi_diff(self.order - 1, 0, 0, a) ob = [] for i, (fi, dfi) in enumerate(zip(f, df)): g = jacobi(self.order - i - 1, 2 * i + 1, 0, b) dg = jacobi_diff(self.order - i - 1, 2 * i + 1, 0, b) for j, (gj, dgj) in enumerate(zip(g, dg)): cij = mp.sqrt((2 * i + 1) * (2 * i + 2 * j + 2)) / 2 ** (i + 1) tmp = (1 - b) ** (i - 1) if i > 0 else 1 pij = 2 * tmp * dfi * gj qij = tmp * (-i * fi + (1 + a) * dfi) * gj + (1 - b) ** i * fi * dgj ob.append([cij * pij, cij * qij]) return ob
def ortho_basis_at_mp(self, p, q): sk = [mp.sqrt(k + 0.5) for k in range(self.order)] pa = [c * jp for c, jp in zip(sk, jacobi(self.order - 1, 0, 0, p))] pb = [c * jp for c, jp in zip(sk, jacobi(self.order - 1, 0, 0, q))] return [pi * pj for pi in pa for pj in pb]
def _quad_orthob_at(order, p, q): sk = [mp.sqrt(k + 0.5) for k in xrange(order)] pa = [c*jp for c, jp in zip(sk, jacobi(order - 1, 0, 0, p))] pb = [c*jp for c, jp in zip(sk, jacobi(order - 1, 0, 0, q))] return [pi*pj for pi in pa for pj in pb]
def _line_orthob_at(order, p): jp = jacobi(order - 1, 0, 0, p) return [mp.sqrt(i + 0.5)*p for i, p in enumerate(jp)]
def ortho_basis_at_mp(self, p): jp = jacobi(self.order - 1, 0, 0, p) return [mp.sqrt(i + 0.5) * p for i, p in enumerate(jp)]