def evaluate_basis_at(self, grid, component, prefactor=False):
        r"""Evaluate the basis functions :math:`\phi_k` recursively at the given nodes :math:`\gamma`.

        :param grid: The grid :math:\Gamma` containing the nodes :math:`\gamma`.
        :type grid: A class having a :py:method:`get_nodes(...)` method.
        :param component: The index :math:`i` of a single component :math:`\Phi_i` to evaluate.
                          We need this to choose the correct basis shape.
        :param prefactor: Whether to include a factor of :math:`\frac{1}{\sqrt{\det(Q)}}`.
        :type prefactor: bool, default is ``False``.
        :return: A two-dimensional ndarray :math:`H` of shape :math:`(|\mathcal{K}_i|, |\Gamma|)` where
                 the entry :math:`H[\mu(k), i]` is the value of :math:`\phi_k(\gamma_i)`.
        """
        D = self._dimension

        # instances of eg HyperCubicShape
        bas = self._basis_shapes[component]
        bs = self._basis_sizes[component]

        # TODO: Consider putting this into the Grid class as 2nd level API
        # Allow ndarrays for the 'grid' argument
        if isinstance(grid, Grid):
            # The overall number of nodes
            nn = grid.get_number_nodes(overall=True)
            # The grid nodes
            nodes = grid.get_nodes()
        else:
            # The overall number of nodes
            nn = prod(grid.shape[1:])
            # The grid nodes
            nodes = grid

        # Allocate phi and compute phi0
        phi = zeros((bs, nn), dtype=complexfloating)
        phi0 = self._evaluate_phi0(self._Pis, nodes, prefactor=False)

        # Compute all higher order states phi_k via recursion
        # call C++ helper function for speed
        import EvaluateBasis
        EvaluateBasis.evaluate_basis_at(
                nodes,
                self._Pis[0],self._Pis[1],self._Pis[2],self._Pis[3],double(self._Pis[4][0,0]),
                D, bs,
                bas.get_limits(),
                bas._lima,
                bas._lima_inv,
                phi0,
                self._eps,
                prefactor,
                phi)

        return phi
Exemplo n.º 2
0
 def case_nodes(self):
     nodes_wrong = zeros((self.D-1,self.nn)) # make nodes wrong size
     EvaluateBasis.evaluate_basis_at(
         nodes_wrong, self._Pis[0],self._Pis[1],self._Pis[2],self._Pis[3],double(self._Pis[4][0,0]),
         self.D, self.limits, self.lima, self.lima_inv, self.phi0, self._eps, self.prefactor, self.phi)
Exemplo n.º 3
0
 def testNormalCall(self):
     """Test correct execution of normal call"""
     EvaluateBasis.evaluate_basis_at(
         self.nodes, self._Pis[0],self._Pis[1],self._Pis[2],self._Pis[3],double(self._Pis[4][0,0]),
         self.D, self.bs, self.limits, self.lima, self.lima_inv, self.phi0, self._eps, self.prefactor, self.phi)