import unittest
from Numeric import *
from Matrix import *
from LuDecomposition import *
from TriDiagonal import *

class TestTridiagonal(unittest.TestCase):
        def testGetMatrixY(self):
                a = [[1,1,-1],[2,6,-4],[1,-1,-1]]
                b = [[3],[6],[8]]
                l, u = LuDecomposition(a).perform()
                expected = [[3],[0],[-5]]
                actual = getMatrixY(l, b)
                self.assertEquals(actual, expected)

        def testGetMatrixX(self):
                a = [[1,1,-1],[2,6,-4],[1,-1,-1]]
                b = [[3],[6],[8]]
                l, u = LuDecomposition(a).perform()
                expectedY = [[3],[0],[-5]]
                matrixY = getMatrixY(l, b)
                self.assertEquals(matrixY, expectedY)
                expectedX = [[0.5],[-2.5],[-5]]
                matrixX = getMatrixX(u, matrixY)
                self.assertEquals(matrixX, expectedX)

if __name__=="__main__":
        unittest.main()