示例#1
0
    def test_cg_DLORegularizedGram(self):
        ATA = linop.DLORegularizedGram(self.A)
        AAT = linop.DLORegularizedGram(self.A, transpose=True)
        BBT = linop.DLORegularizedGram(self.B)
        BTB = linop.DLORegularizedGram(self.B, transpose=False)

        M_ATA = linop.DLODiagonal((1. / (self.rho + self.dATA)).persist())
        M_AAT = linop.DLODiagonal((1. / (self.rho + self.dAAT)).persist())
        M_BBT = linop.DLODiagonal((1. / (self.rho + self.dBBT)).persist())
        M_BTB = linop.DLODiagonal((1. / (self.rho + self.dBTB)).persist())

        for A, M in ((ATA, M_ATA), (AAT, M_AAT), (BBT, M_BBT), (BTB, M_BTB)):
            assert cg_reduces_residuals(A)
            assert cg_warmstart_reduces_iterations(A)
示例#2
0
def jacobi_preconditioner(array, name=None):
    name = 'jacobi-precond-' + array.name if name is None else name
    m, n = array.shape
    assert m == n, 'preconditioner expects square linear operator'
    diag = da.diag(array)
    return linop.DLODiagonal(da.core.map_blocks(da.reciprocal, diag,
                                                name=name))
示例#3
0
    def test_cg_DLOGram(self):
        ATA = linop.DLOGram(self.A)
        AAT = linop.DLOGram(self.A, transpose=True)
        BBT = linop.DLOGram(self.B)
        BTB = linop.DLOGram(self.B, transpose=False)
        M_ATA = linop.DLODiagonal(self.dATA)
        M_BBT = linop.DLODiagonal(self.dBBT)

        # skinny, full rank Gram
        assert cg_reduces_residuals(ATA)
        assert cg_warmstart_reduces_iterations(ATA)

        # skinny, rank-deficient Gram
        assert not cg_reduces_residuals(AAT)

        # fat, full rank Gram
        assert cg_reduces_residuals(BBT)
        assert cg_warmstart_reduces_iterations(BBT)

        # fat, rank-deficient Gram
        assert not cg_reduces_residuals(BTB)
示例#4
0
 def test_DLODiag_ops(self):
     D = linop.DLODiagonal(self.D)
     Dx = self.D * self.x
     assert operations_consistent(D, self.x, self.x, Dx, Dx)
示例#5
0
def jacobi_preconditioner(linear_op, name=None):
    name = 'jacobi-precond-' + linear_op.name if name is None else name
    diag = atoms.diag_gram(linear_op)
    return linop.DLODiagonal(da.core.map_blocks(da.reciprocal, diag,
                                                name=name))