def adupdates_simple(x, g, L, stepsize, inner_stepsizes, niter,
                     random=False):
    """Non-optimized version of ``adupdates``.
    This function is intended for debugging. It makes a lot of copies and
    performs no error checking.
    """
    # Initializations
    length = len(g)
    ranges = [Li.range for Li in L]
    duals = [space.zero() for space in ranges]

    # Iteratively find a solution
    for _ in range(niter):
        # Update x = x - 1/stepsize * sum([ops[i].adjoint(duals[i])
        # for i in range(length)])
        for i in range(length):
            x -= (1.0 / stepsize) * L[i].adjoint(duals[i])

        rng = np.random.permutation(range(length)) if random else range(length)

        for j in rng:
            dual_tmp = ranges[j].element()
            dual_tmp = (g[j].convex_conj.proximal
                        (stepsize * inner_stepsizes[j]
                         if np.isscalar(inner_stepsizes[j])
                         else stepsize * np.asarray(inner_stepsizes[j]))
                        (duals[j] + stepsize * inner_stepsizes[j] * L[j](x)
                         if np.isscalar(inner_stepsizes[j])
                         else duals[j] + stepsize *
                         np.asarray(inner_stepsizes[j]) * L[j](x)))
            x -= 1.0 / stepsize * L[j].adjoint(dual_tmp - duals[j])
            duals[j].assign(dual_tmp)
def adupdates_simple ( x , g , L , stepsize , inner_stepsizes , niter , random = False ) : length = len ( g ) ranges = [ Li . range for Li in L ] duals = [ space . zero ( ) for space in ranges ] for _ in range ( niter ) : for i in range ( length ) : x -= ( 1.0 / stepsize ) * L [ i ] . adjoint ( duals [ i ] ) rng = np . random . permutation ( range ( length ) ) if random else range ( length ) for j in rng : dual_tmp = ranges [ j ] . element ( ) dual_tmp = ( g [ j ] . convex_conj . proximal ( stepsize * inner_stepsizes [ j ] if np . isscalar ( inner_stepsizes [ j ] ) else stepsize * np . asarray ( inner_stepsizes [ j ] ) ) ( duals [ j ] + stepsize * inner_stepsizes [ j ] * L [ j ] ( x ) if np . isscalar ( inner_stepsizes [ j ] ) else duals [ j ] + stepsize * np . asarray ( inner_stepsizes [ j ] ) * L [ j ] ( x ) ) ) x -= 1.0 / stepsize * L [ j ] . adjoint ( dual_tmp - duals [ j ] ) duals [ j ] . assign ( dual_tmp )
Non-optimized version of ``adupdates``.
    This function is intended for debugging. It makes a lot of copies and
    performs no error checking.