mparray.py 文件源码

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

项目:mpnum 作者: dseuss 项目源码 文件源码
def __mul__(self, fact):
        """Multiply ``MPArray`` by a scalar.
          .. todo::  These could be made more stable by rescaling all
            non-normalized tens
        """
        if np.isscalar(fact):
            lcanon, rcanon = self.canonical_form
            ltens = self._lt
            ltens_new = it.chain(ltens[:lcanon], [fact * ltens[lcanon]],
                                 ltens[lcanon + 1:])
            return type(self)(LocalTensors(ltens_new, cform=(lcanon, rcanon)))

        raise NotImplementedError("Multiplication by non-scalar not supported")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号