def compare_matrices(fem1, fem2):
    """verifies that the DMIG, DMIJ, DMIJI, and DMIK matrices are the same"""
    for key in fem1.dmig:
        card1 = fem1.dmig[key]
        card2 = fem2.dmig[key]
        assert str(card1) == str(card2)
    for key in fem1.dmij:
        card1 = fem1.dmij[key]
        card2 = fem2.dmij[key]
        assert str(card1) == str(card2)
    for key in fem1.dmiji:
        card1 = fem1.dmiji[key]
        card2 = fem2.dmiji[key]
        assert str(card1) == str(card2)
    for key in fem1.dmik:
        card1 = fem1.dmik[key]
        card2 = fem2.dmik[key]
        assert str(card1) == str(card2)
    for key in fem1.dmiax:
        card1 = fem1.dmiax[key]
        card2 = fem2.dmiax[key]
        assert str(card1) == str(card2)
