test_tensor.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def test_valued_tensor_get_matrix():
    numpy = import_module("numpy")
    if numpy is None:
        skip("numpy not installed.")

    (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
     n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()

    matab = AB(i0, i1).get_matrix()
    assert matab == Matrix([
                            [1,  0,  0,  0],
                            [0, -1,  0,  0],
                            [0,  0, -1,  0],
                            [0,  0,  0, -1],
                            ])
    # when alternating contravariant/covariant with [1, -1, -1, -1] metric
    # it becomes the identity matrix:
    assert AB(i0, -i1).get_matrix() == eye(4)

    # covariant and contravariant forms:
    assert A(i0).get_matrix() == Matrix([E, px, py, pz])
    assert A(-i0).get_matrix() == Matrix([E, -px, -py, -pz])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号