def convert_to_givens_form(self):
     """
     Convert from eigen to givens form
     """
     rank = self.parameters['rank'][0]
     Uc, E, Ur = giv.givensise(self.parameters['vec'])
     EUr = np.dot(E[:rank, :rank], Ur)
     D = np.dot(np.dot(EUr, np.diag(self.parameters['val'])), EUr.T)
     U = Uc[:, :rank]
     return U, D
 def convert_to_givens_form(self):
     """
     Convert from eigen to givens form
     """
     rank = self.parameters['rank'][0]
     Uc,E,Ur = giv.givensise(self.parameters['vec'])
     EUr = np.dot(E[:rank,:rank],Ur)
     D = np.dot(np.dot(EUr, np.diag(self.parameters['val'])), EUr.T)
     U = Uc[:,:rank]
     return U, D
 def runTest(self):
     
     for d in range(1,self.dMax+1):
         for r in range(1,d):
             
             # Random matrix of orthogonal columns
             X = np.random.randn(d,d)
             A = np.dot(X,X.T)
             eVal,eVec = linalg.eigh(A)
             U = eVec[:,:2]
             
             # Factorise it
             Uc,E,Ur = givensise(U)
             
             # Reconstruct
             shouldBeU = np.dot(Uc,np.dot(E,Ur))
             
             # Test
             np.testing.assert_almost_equal(U,shouldBeU)                
    def runTest(self):

        for d in range(1, self.dMax + 1):
            for r in range(1, d):

                # Random matrix of orthogonal columns
                X = np.random.randn(d, d)
                A = np.dot(X, X.T)
                eVal, eVec = linalg.eigh(A)
                U = eVec[:, :2]

                # Factorise it
                Uc, E, Ur = givensise(U)

                # Reconstruct
                shouldBeU = np.dot(Uc, np.dot(E, Ur))

                # Test
                np.testing.assert_almost_equal(U, shouldBeU)