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
评论列表
文章目录