def test_calcProjectionMatrix(self):
        Q = projections.calcProjectionMatrix(self.A)

        expected_Q = np.array([
            [0.5239436 - 0.j, 0.0366197 + 0.3295774j, 0.3661971 + 0.0732394j],
            [0.0366197 - 0.3295774j, 0.7690140 + 0.j, -0.0788732 + 0.2478873j],
            [0.3661971 - 0.0732394j, -0.0788732 - 0.2478873j, 0.7070422 - 0j]
        ])
        np.testing.assert_array_almost_equal(Q, expected_Q)
    def test_calcProjectionMatrix(self):
        Q = projections.calcProjectionMatrix(self.A)

        expected_Q = np.array(
            [
                [0.5239436 - 0.0j, 0.0366197 + 0.3295774j, 0.3661971 + 0.0732394j],
                [0.0366197 - 0.3295774j, 0.7690140 + 0.0j, -0.0788732 + 0.2478873j],
                [0.3661971 - 0.0732394j, -0.0788732 - 0.2478873j, 0.7070422 - 0j],
            ]
        )
        np.testing.assert_array_almost_equal(Q, expected_Q)
示例#3
0
    def test_calc_receive_filter(self):
        # Equivalent channel without including stream reduction
        Heq_k = randn_c(3, 3)
        Re_k = randn_c(3, 2)
        Re_k = np.dot(Re_k, Re_k.transpose().conjugate())

        P1 = blockdiagonalization._calc_stream_reduction_matrix(Re_k, 1)
        P2 = blockdiagonalization._calc_stream_reduction_matrix(Re_k, 2)
        P3 = blockdiagonalization._calc_stream_reduction_matrix(Re_k, 3)

        # Equivalent channels with the stream reduction
        Heq_k_P1 = np.dot(Heq_k, P1)
        Heq_k_P2 = np.dot(Heq_k, P2)
        Heq_k_P3 = np.dot(Heq_k, P3)

        W1 = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k_P1, P1)
        W2 = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k_P2, P2)
        W3 = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k_P3, P3)
        # Note that since P3 is actually including all streams, then the
        # performance is the same as if we don't reduce streams. However W3
        # and W_full are different matrices, since W3 has to compensate the
        # right multiplication of the equivalent channel by P3 and W_full
        # does not. The performance is the same because no energy is lost
        # due to stream reduction and the Frobenius norms of W3 and W_full
        # are equal.
        W_full = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k)

        np.testing.assert_array_almost_equal(np.dot(W1, np.dot(Heq_k, P1)),
                                             np.eye(1))
        np.testing.assert_array_almost_equal(np.dot(W2, np.dot(Heq_k, P2)),
                                             np.eye(2))
        np.testing.assert_array_almost_equal(np.dot(W3, np.dot(Heq_k, P3)),
                                             np.eye(3))
        np.testing.assert_array_almost_equal(np.dot(W_full, Heq_k),
                                             np.eye(3))

        overbar_P2 = calcProjectionMatrix(P2)
        expected_W2 = np.dot(
            np.linalg.pinv(np.dot(overbar_P2, np.dot(Heq_k, P2))),
            overbar_P2)
        np.testing.assert_array_almost_equal(expected_W2, W2)
示例#4
0
    def test_calc_receive_filter(self):
        # Equivalent channel without including stream reduction
        Heq_k = randn_c(3, 3)
        Re_k = randn_c(3, 2)
        Re_k = np.dot(Re_k, Re_k.transpose().conjugate())

        P1 = blockdiagonalization._calc_stream_reduction_matrix(Re_k, 1)
        P2 = blockdiagonalization._calc_stream_reduction_matrix(Re_k, 2)
        P3 = blockdiagonalization._calc_stream_reduction_matrix(Re_k, 3)

        # Equivalent channels with the stream reduction
        Heq_k_P1 = np.dot(Heq_k, P1)
        Heq_k_P2 = np.dot(Heq_k, P2)
        Heq_k_P3 = np.dot(Heq_k, P3)

        W1 = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k_P1, P1)
        W2 = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k_P2, P2)
        W3 = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k_P3, P3)
        # Note that since P3 is actually including all streams, then the
        # performance is the same as if we don't reduce streams. However W3
        # and W_full are different matrices, since W3 has to compensate the
        # right multiplication of the equivalent channel by P3 and W_full
        # does not. The performance is the same because no energy is lost
        # due to stream reduction and the Frobenius norms of W3 and W_full
        # are equal.
        W_full = blockdiagonalization.EnhancedBD.calc_receive_filter_user_k(
            Heq_k)

        np.testing.assert_array_almost_equal(np.dot(W1, np.dot(Heq_k, P1)),
                                             np.eye(1))
        np.testing.assert_array_almost_equal(np.dot(W2, np.dot(Heq_k, P2)),
                                             np.eye(2))
        np.testing.assert_array_almost_equal(np.dot(W3, np.dot(Heq_k, P3)),
                                             np.eye(3))
        np.testing.assert_array_almost_equal(np.dot(W_full, Heq_k), np.eye(3))

        overbar_P2 = calcProjectionMatrix(P2)
        expected_W2 = np.dot(
            np.linalg.pinv(np.dot(overbar_P2, np.dot(Heq_k, P2))), overbar_P2)
        np.testing.assert_array_almost_equal(expected_W2, W2)
 def test_calcOrthogonalProjectionMatrix(self):
     Q = projections.calcProjectionMatrix(self.A)
     oQ = projections.calcOrthogonalProjectionMatrix(self.A)
     expected_oQ = np.eye(3) - Q
     np.testing.assert_array_almost_equal(oQ, expected_oQ)
 def test_calcOrthogonalProjectionMatrix(self):
     Q = projections.calcProjectionMatrix(self.A)
     oQ = projections.calcOrthogonalProjectionMatrix(self.A)
     expected_oQ = np.eye(3) - Q
     np.testing.assert_array_almost_equal(oQ, expected_oQ)