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