예제 #1
0
    def old_code_container(self):
        r = sp.array([1.0, 0.9, 0.8])
        C = sp_la.toeplitz(r)
        cnos = [10, 15.3, 50]

        print 'initial matrix:'
        print C
        print

        for cno in cnos:
            print 'initial condition:', matrix_cond(C)
            print 'target condition:', cno
            print
            Ddiag = diagonal_loading(C, cno)
            Dcol = coloured_loading(C, cno)
            print 'diagonally loaded:', matrix_cond(Ddiag)
            print Ddiag
            print 'coloured loaded:', matrix_cond(Dcol)
            print Dcol
            print

        print 'C matrix:', matrix_cond(C)
        print C
        Cnew = coloured_loading(C, 10, overwrite_mat=True)
        print 'Cnew loaded at condition:', matrix_cond(Cnew)
        print Cnew
        print 'same matrices: C is Cnew', C is Cnew
        print
예제 #2
0
    def old_code_container(self):
        r = sp.array([1.0, 0.9, 0.8])
        C = sp_la.toeplitz(r)
        cnos = [10, 15.3, 50]

        print 'initial matrix:'
        print C
        print

        for cno in cnos:
            print 'initial condition:', matrix_cond(C)
            print 'target condition:', cno
            print
            Ddiag = diagonal_loading(C, cno)
            Dcol = coloured_loading(C, cno)
            print 'diagonally loaded:', matrix_cond(Ddiag)
            print Ddiag
            print 'coloured loaded:', matrix_cond(Dcol)
            print Dcol
            print

        print 'C matrix:', matrix_cond(C)
        print C
        Cnew = coloured_loading(C, 10, overwrite_mat=True)
        print 'Cnew loaded at condition:', matrix_cond(Cnew)
        print Cnew
        print 'same matrices: C is Cnew', C is Cnew
        print
예제 #3
0
    def testMatrixLoading(self):
        """test for diagonal loading"""

        # trivial
        assert_equal(diagonal_loading(self.mat, 1.0), sp.eye(3))
        assert_equal(coloured_loading(self.mat, 1.0), sp.eye(3))

        # application
        c = 5.2445626465380286
        assert_equal(diagonal_loading(self.mat, 3.0),
            sp.array([[c, 2, 1], [2, c, 2], [1, 2, c]]))
        assert_almost_equal(coloured_loading(self.mat, 3.0), sp.array([
            [4.1713186830564446, 1.7111326024008537, 1.1713186830564448],
            [1.7111326024008537, 4.4870710649124632, 1.7111326024008537],
            [1.1713186830564448, 1.7111326024008537, 4.1713186830564446]]))
예제 #4
0
    def testMatrixLoading(self):
        """test for diagonal loading"""

        # trivial
        assert_equal(diagonal_loading(self.mat, 1.0), sp.eye(3))
        assert_equal(coloured_loading(self.mat, 1.0), sp.eye(3))

        # application
        assert_almost_equal(
            diagonal_loading(self.mat, 3.0),
            sp.array([[5.2445626465380286, 2, 1], [2, 5.2445626465380286, 2],
                      [1, 2, 5.2445626465380286]]))
        assert_almost_equal(
            coloured_loading(self.mat, 3.0),
            sp.array([[4.17131868306, 1.7111326024, 1.17131868306],
                      [1.7111326024, 4.48707106491, 1.7111326024],
                      [1.17131868306, 1.7111326024, 4.17131868306]]))
예제 #5
0
    def testMatrixLoading(self):
        """test for diagonal loading"""

        # trivial
        assert_equal(diagonal_loading(self.mat, 1.0), sp.eye(3))
        assert_equal(coloured_loading(self.mat, 1.0), sp.eye(3))

        # application
        assert_almost_equal(
            diagonal_loading(self.mat, 3.0),
            sp.array([
                [5.2445626465380286, 2, 1],
                [2, 5.2445626465380286, 2],
                [1, 2, 5.2445626465380286]]))
        assert_almost_equal(
            coloured_loading(self.mat, 3.0),
            sp.array([
                [4.17131868306, 1.7111326024, 1.17131868306],
                [1.7111326024, 4.48707106491, 1.7111326024],
                [1.17131868306, 1.7111326024, 4.17131868306]]))