예제 #1
0
    def testSolvingComplexAxbWithCholeskyAndForwardBackwardSolve(self):

        R = md.cholesky(self.complexA, self.n)

        for i in range(self.n):
            for j in range(self.n):
                self.assertAlmostEqual(
                    self.complexR[i][j].tolist(), R[i][j].tolist(), 14,
                    "expected " + str(self.complexR[i][j]) + " was " +
                    str(R[i][j]))

        RT = mynp.conjugatetranspose(R)

        y = ls.forwardSolve(RT, self.complexb, self.n)

        for i in range(self.n):
            self.assertAlmostEqual(
                self.complexy[i].tolist(), y[i].tolist(), 14,
                "expected " + str(self.complexy[i]) + " was " + str(y[i]))

        x = ls.backtrackSolve(R, y, self.n)

        for i in range(self.n):
            self.assertAlmostEqual(
                self.complexx[i].tolist(), x[i].tolist(), 14,
                "expected " + str(self.complexx[i]) + " was " + str(x[i]))
예제 #2
0
파일: testCholesky.py 프로젝트: jpaasen/cos
 def testIfCholeskyRIsAsExpected(self):
    
    R = md.cholesky(self.A, self.n)
    
    for i in range(self.n):
       for j in range(self.n):   
          self.assertAlmostEqual(self.R[i][j].tolist(), R[i][j].tolist(), 14, 
                            "expected " + str(self.R[i][j]) + " was " + str(R[i][j].real))
예제 #3
0
    def testIfCholeskyRIsAsExpected(self):

        R = md.cholesky(self.A, self.n)

        for i in range(self.n):
            for j in range(self.n):
                self.assertAlmostEqual(
                    self.R[i][j].tolist(), R[i][j].tolist(), 14, "expected " +
                    str(self.R[i][j]) + " was " + str(R[i][j].real))
예제 #4
0
파일: testCholesky.py 프로젝트: jpaasen/cos
 def testRTransposedTimesRIsEqualA(self):
    
    R = md.cholesky(self.A, self.n)
    
    RT = mynp.conjugatetranspose(R)
    
    A = mynp.dot(RT, R)
    
    for i in range(self.n):
       for j in range(self.n):   
          self.assertAlmostEqual(self.A[i][j].tolist(), A[i][j].tolist(), 15, 
                            "expected " + str(self.A[i][j]) + " was " + str(A[i][j]))
예제 #5
0
    def testRTransposedTimesRIsEqualA(self):

        R = md.cholesky(self.A, self.n)

        RT = mynp.conjugatetranspose(R)

        A = mynp.dot(RT, R)

        for i in range(self.n):
            for j in range(self.n):
                self.assertAlmostEqual(
                    self.A[i][j].tolist(), A[i][j].tolist(), 15,
                    "expected " + str(self.A[i][j]) + " was " + str(A[i][j]))
예제 #6
0
    def testCholesky(self):

        #      cho_solve(cho_factor(R), a)
        self.R = np.array([[3, 2], [2, 3]], dtype=complex)
        self.a = np.array([7, 7], dtype=complex)
        self.n = 2

        Ria = np.linalg.solve(self.R, self.a)

        U = md.cholesky(self.R, self.n)
        UT = U.conjugate().transpose()

        y = ls.forwardSolve(UT, self.a, self.n)
        x = ls.backtrackSolve(U, y, self.n)

        self.almostEqual(Ria, x)
예제 #7
0
   def testCholesky(self):
      
#      cho_solve(cho_factor(R), a)
      self.R = np.array([[3,2],[2,3]],dtype=complex)
      self.a = np.array([7,7],dtype=complex)
      self.n = 2
      
      Ria = np.linalg.solve(self.R, self.a)
      
      
      U = md.cholesky(self.R, self.n)
      UT = U.conjugate().transpose()
      
      y = ls.forwardSolve(UT, self.a, self.n)
      x = ls.backtrackSolve(U, y, self.n)
   
      
      self.almostEqual(Ria, x)
예제 #8
0
파일: testCholesky.py 프로젝트: jpaasen/cos
 def testSolvingAxbWithCholeskyAndForwardBackwardSolve(self):
    
    R = md.cholesky(self.A, self.n) 
    
    RT = mynp.conjugatetranspose(R)
    
    y = ls.forwardSolve(RT, self.b1, self.n)
    x = ls.backtrackSolve(R, y, self.n)
    
    for i in range(self.n):
       self.assertAlmostEqual(self.x1[i].tolist(), x[i].tolist(), 14, 
                         "expected " + str(self.x1[i]) + " was " + str(x[i]))
       
    y = ls.forwardSolve(RT, self.b2, self.n)
    x = ls.backtrackSolve(R, y, self.n)
    
    for i in range(self.n):
       self.assertAlmostEqual(self.x2[i].tolist(), x[i].tolist(), 14, 
                         "expected " + str(self.x2[i]) + " was " + str(x[i]))
예제 #9
0
    def testSolvingAxbWithCholeskyAndForwardBackwardSolve(self):

        R = md.cholesky(self.A, self.n)

        RT = mynp.conjugatetranspose(R)

        y = ls.forwardSolve(RT, self.b1, self.n)
        x = ls.backtrackSolve(R, y, self.n)

        for i in range(self.n):
            self.assertAlmostEqual(
                self.x1[i].tolist(), x[i].tolist(), 14,
                "expected " + str(self.x1[i]) + " was " + str(x[i]))

        y = ls.forwardSolve(RT, self.b2, self.n)
        x = ls.backtrackSolve(R, y, self.n)

        for i in range(self.n):
            self.assertAlmostEqual(
                self.x2[i].tolist(), x[i].tolist(), 14,
                "expected " + str(self.x2[i]) + " was " + str(x[i]))
예제 #10
0
파일: testCholesky.py 프로젝트: jpaasen/cos
   def testSolvingComplexAxbWithCholeskyAndForwardBackwardSolve(self):
      
      R = md.cholesky(self.complexA, self.n)
      
      for i in range(self.n):
         for j in range(self.n):   
            self.assertAlmostEqual(self.complexR[i][j].tolist(), R[i][j].tolist(), 14, 
                              "expected " + str(self.complexR[i][j]) + " was " + str(R[i][j]))

      RT = mynp.conjugatetranspose(R)
      
      y = ls.forwardSolve(RT, self.complexb, self.n)
      
      for i in range(self.n):
         self.assertAlmostEqual(self.complexy[i].tolist(), y[i].tolist(), 14, 
                           "expected " + str(self.complexy[i]) + " was " + str(y[i]))
      
      x = ls.backtrackSolve(R, y, self.n)
      
      for i in range(self.n):
         self.assertAlmostEqual(self.complexx[i].tolist(), x[i].tolist(), 14, 
                           "expected " + str(self.complexx[i]) + " was " + str(x[i]))