matrices.py 文件源码

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

项目:shenfun 作者: spectralDNS 项目源码 文件源码
def matvec(self, v, c, format='self', axis=0):
        N = self.shape[0]
        c.fill(0)
        if format == 'self':
            if axis > 0:
                c = np.moveaxis(c, axis, 0)
                v = np.moveaxis(v, axis, 0)
            s = (slice(None),) + (np.newaxis,)*(v.ndim-1) # broadcasting
            ve = v[-2:0:-2].cumsum(axis=0)
            vo = v[-1:0:-2].cumsum(axis=0)
            c[-3::-2] = ve*2.0
            c[-2::-2] = vo*2.0
            if axis > 0:
                c = np.moveaxis(c, 0, axis)
                v = np.moveaxis(v, 0, axis)

        else:
            c = super(SpectralMatrix, self).matvec(v, c, format=format, axis=axis)

        return c
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号