U E D R , A S I H C RSS

Cubic Spline/1002/test_tridiagonal.py

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()
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0804 sec