spectralbase.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:shenfun 作者: spectralDNS 项目源码 文件源码
def vandermonde_scalar_product(self, input_array, output_array):
        """Naive implementation of scalar product

        args:
            input_array   (input)    Function values on quadrature mesh
            output_array   (output)   Expansion coefficients

        """
        assert abs(self.padding_factor-1) < 1e-8
        assert self.N == input_array.shape[self.axis]
        points, weights = self.points_and_weights(self.N)
        V = self.vandermonde(points)
        P = self.get_vandermonde_basis(V)
        if input_array.ndim == 1:
            output_array[:] = np.dot(input_array*weights, np.conj(P))

        else: # broadcasting
            bc_shape = [np.newaxis,]*input_array.ndim
            bc_shape[self.axis] = slice(None)
            fc = np.moveaxis(input_array*weights[bc_shape], self.axis, -1)
            output_array[:] = np.moveaxis(np.dot(fc, np.conj(P)), -1, self.axis)

        assert output_array is self.forward.output_array
        return output_array
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号