コード例 #1
0
    def test_jones_multiply(self):
        """ Verify jones matrix multiplication code against NumPy """

        # Generate random matrices
        def rmat(shape):
            return np.random.random(size=shape) + \
                np.random.random(size=shape)*1j

        N = 100
        shape = (100, 2,2)

        A, B = rmat(shape), rmat(shape)

        AM = [np.matrix(A[i,:,:]) for i in range(N)]
        BM = [np.matrix(B[i,:,:]) for i in range(N)]

        C = CPUSolver.jones_multiply(A, B, jones_shape='2x2')

        for Am, Bm, Cm in zip(AM, BM, C):
            assert np.allclose(Am*Bm, Cm)

        C = CPUSolver.jones_multiply(A, B, hermitian=True, jones_shape='2x2')

        for Am, Bm, Cm in zip(AM, BM, C):
            assert np.allclose(Am*Bm.H, Cm)
コード例 #2
0
ファイル: test_rime_v4.py プロジェクト: andferrari/montblanc
    def test_jones_multiply(self):
        """ Verify jones matrix multiplication code against NumPy """

        # Generate random matrices
        def rmat(shape):
            return np.random.random(size=shape) + \
                np.random.random(size=shape)*1j

        N = 100
        shape = (100, 2, 2)

        A, B = rmat(shape), rmat(shape)

        AM = [np.matrix(A[i, :, :]) for i in range(N)]
        BM = [np.matrix(B[i, :, :]) for i in range(N)]

        C = CPUSolver.jones_multiply(A, B, jones_shape='2x2')

        for Am, Bm, Cm in zip(AM, BM, C):
            assert np.allclose(Am * Bm, Cm)

        C = CPUSolver.jones_multiply(A, B, hermitian=True, jones_shape='2x2')

        for Am, Bm, Cm in zip(AM, BM, C):
            assert np.allclose(Am * Bm.H, Cm)