Beispiel #1
0
    def prox(self, x, tau):
        # define current number of iterations
        if isinstance(self.niter, int):
            niter = self.niter
        else:
            niter = self.niter(self.count)

        # solve proximal optimization
        if self.Op is not None and self.b is not None:
            y = x + tau * self.OpTb
            if self.q is not None:
                y -= tau * self.alpha * self.q
            if self.Op.explicit:
                Op1 = MatrixMult(
                    np.eye(self.Op.shape[1]) +
                    tau * self.sigma * np.conj(self.Op.A.T) @ self.Op.A)
                x = Op1.div(y)
            else:
                Op1 = Identity(self.Op.shape[1], dtype=self.Op.dtype) + \
                      tau * self.sigma * self.Op.H * self.Op
                x = lsqr(Op1, y, iter_lim=niter, x0=self.x0)[0]
            if self.warm:
                self.x0 = x
        elif self.b is not None:
            num = x + tau * self.sigma * self.b
            if self.q is not None:
                num -= tau * self.alpha * self.q
            x = num / (1. + tau * self.sigma)
        else:
            num = x
            if self.q is not None:
                num -= tau * self.alpha * self.q
            x = num / (1. + tau * self.sigma)
        return x
Beispiel #2
0
 def prox(self, x, tau):
     if self.Op is not None and self.b is not None:
         y = x - tau * self.b
         if self.Op.explicit:
             Op1 = MatrixMult(np.eye(self.Op.shape[0]) + tau * self.Op.A)
             x = Op1.div(y)
         else:
             Op1 = Identity(self.Op.shape[0], dtype=self.Op.dtype) + \
                   tau * self.Op.A
             x = lsqr(Op1, y, iter_lim=self.niter, x0=self.x0)[0]
         if self.warm:
             self.x0 = x
     elif self.b is not None:
         x = x - tau * self.b
     return x