def test_math(self): mnp0 = np.asmatrix(np.random.rand(9).reshape(3, 3)) mnp1 = np.asmatrix(np.random.rand(9).reshape(3, 3)) m0 = Matrix_3x3(mnp0) m1 = Matrix_3x3(mnp1) mnp01 = mnp0 * mnp1 m01 = m0 * m1 aa_eq_np(m01.to_ndmatrix(), mnp01)
def test_0(self): import numpy as np mat = Matrix_3x3(list(range(9))) assert mat[:].shape == (3, 3) assert mat.buffer1d.shape == (9, ) asmat1 = np.asmatrix(np.arange(9).reshape((3, 3))).astype(np.float64) eq_np_to_mat(asmat1, mat) mat[0, 0] = 100. assert mat.tolist()[0][0] == 100. # test memview npmat = np.asmatrix(mat[:]) mat[0, 0] = 20. assert npmat[0, 0] == 20. mat *= mat v1 = mat.row1 assert v1.tolist() == list(mat[0]) assert np.any(npmat == mat.to_ndmatrix()) == True mat_as_ndmatrix = mat.as_ndmatrix() mat_as_ndmatrix[0] = 10000. assert np.any(npmat == mat.to_ndmatrix()) == True assert np.any(npmat == mat_as_ndmatrix) == True v1np = np.asarray(v1[:]).reshape(3, 1)
def test_0(self): v1 = Vec3(0., 0., 0.) v1[0] = 200. v1[:] = [100, 300, 400] assert v1.tolist() == [100, 300, 400] assert isinstance(v1.tolist(), list) == True from pytraj.math import Matrix_3x3 Matrix_3x3(list(range(9)))
def test_from_matrix_3x3(self): from pytraj.math import Matrix_3x3 mat = Matrix_3x3() Box(mat)
def test_0(self): mat = Matrix_3x3(list(range(10, 19))) vec = Vec3(list(range(3)))
def test_0(self): Matrix_3x3(list(range(10, 19))) Vec3(list(range(3)))