geometry.py 文件源码

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

项目:dft 作者: rosenbrockc 项目源码 文件源码
def M(self):
        """Returns the :math:`M` matrix of integers that determine points at which the
        functions are sampled in the unit cell.

        Examples:
            For `S = [2, 2, 1]`, the returned matrix is:

        .. code-block:: python

            np.ndarray([[0,0,0],
                        [1,0,0],
                        [0,1,0],
                        [1,1,0]], dtype=int)
        """
        if self._M is None:
            ms = np.arange(np.prod(self.S, dtype=int))
            m1 = np.fmod(ms, self.S[0])
            m2 = np.fmod(np.floor(ms/self.S[0]), self.S[1])
            m3 = np.fmod(np.floor(ms/(self.S[0]*self.S[1])), self.S[2])
            #Make sure we explicitly use an integer array; it's faster.
            self._M = np.asarray(np.vstack((m1, m2, m3)).T, dtype=int)
        return self._M
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号