예제 #1
0
def test_Matrix_solveAxbWithLUP(Matrix120):
  b = Matrix([[0.1],
              [12.5],
              [10.3]])
  x, y = Matrix.solveAxbWithLUP(Matrix120, b)
  assert y == Matrix([[10.3], [6.319999], [-5.571428]])
  assert x == Matrix([[0.5], [-0.2], [3]])
예제 #2
0
def TryToSolveATask(path):
  A, b = CreateMatricies(path)
  
  if (path == "Tasks/Task_6Y.txt"):
    for i in range(0, A.n_rows):
      A._matrix[0][i] /= float(10**9)
      
      A._matrix[2][i] *= float(10**10)
    b._matrix[0][0] /= float(10**9)
    b._matrix[2][0] *= float(10**10)
    print "-.-.- Applied special transformations -.-.-"
    
  try:
    print "-.-.- solveAxbWithLU -.-.-"
    x, y = Matrix.solveAxbWithLU(A, b)
    PrintResults(x, y)
  except ZeroDivisionError:
    print u"Cannot solve with LU"
    print
    
  try:
    print "-.-.- solveAxbWithLUP -.-.-"
    x, y = Matrix.solveAxbWithLUP(A, b)
    PrintResults(x, y)
  except ZeroDivisionError:
    print u"Cannot solve with LUP"
    print