def tabulate_derivatives(self, n, pts): """Returns a tuple of length one (A,) such that A[i,j] = D phi_i(pts[j]). The tuple is returned for compatibility with the interfaces of the triangle and tetrahedron expansions.""" ref_pts = numpy.array([self.mapping(pt) for pt in pts]) psitilde_as_derivs = jacobi.eval_jacobi_deriv_batch(0, 0, n, ref_pts) # Jacobi polynomials defined on [-1, 1], first derivatives need scaling psitilde_as_derivs *= 2.0 / self.ref_el.volume() results = numpy.zeros((n + 1, len(pts)), "d") for k in range(0, n + 1): results[k, :] = psitilde_as_derivs[k, :] * numpy.sqrt(k + 0.5) vals = self.tabulate(n, pts) deriv_vals = (results,) # Create the ordinary data structure. dv = [] for i in range(vals.shape[0]): dv.append([]) for j in range(vals.shape[1]): dv[-1].append((vals[i][j], [deriv_vals[0][i][j]])) return dv