コード例 #1
0
for j in xrange(0, numLambdas):
    lambd = startLambda + j * (endLambda - startLambda) / (numLambdas - 1.)
    if worldRank == 0:
        print('lambda = {}'.format(lambd))

    startTV = El.mpi.Time()
    x = El.TV(b, lambd, ctrl)
    endTV = El.mpi.Time()
    if worldRank == 0:
        print('TV time: {}'.format(endTV - startTV))

    Dx = El.DistMultiVec()
    El.Zeros(Dx, n - 1, 1)
    El.Multiply(El.NORMAL, 1., D, x, 0., Dx)
    if display:
        El.Display(x, "x")
        El.Display(Dx, "Dx")

    DxOneNorm = El.EntrywiseNorm(Dx, 1)
    e = El.DistMultiVec()
    El.Copy(b, e)
    El.Axpy(-1., x, e)
    if display:
        El.Display(e, "e")
    eTwoNorm = El.Nrm2(e)
    if worldRank == 0:
        print('|| D x ||_1   = {}'.format(DxOneNorm))
        print('|| x - b ||_2 = {}'.format(eTwoNorm))

El.Finalize()
コード例 #2
0
ファイル: SOC.py プロジェクト: xj361685640/Elemental
# Compute the Nesterov-Todd scaling point of (s,z)
# ================================================
w = El.SOCNesterovTodd(s, z, orders, firstInds, cutoff)
wRoot = El.SOCSquareRoot(w, orders, firstInds, cutoff)
wRootInv = El.SOCInverse(wRoot, orders, firstInds, cutoff)
sNT = El.SOCApplyQuadratic(wRootInv, s, orders, firstInds, cutoff)
zNT = El.SOCApplyQuadratic(wRoot, z, orders, firstInds, cutoff)
if output:
    El.Print(w, "w")
    El.Print(sNT, "s_NT")
    El.Print(zNT, "z_NT")

# Compute the minimum non-negative step length, alpha, such that s + alpha y
# touches the boundary of the product cone
y = El.DistMultiVec()
El.Uniform(y, n, 1)
upperBound = 100.
alpha = El.MaxStepInSOC(s, y, orders, firstInds, upperBound, cutoff)
p = El.DistMultiVec()
El.Copy(s, p)
El.Axpy(alpha, y, p)
pDets = El.SOCDets(p, orders, firstInds, cutoff)
if output:
    El.Print(y, "y")
    if worldRank == 0:
        print('maximum step in cone is: {}'.format(alpha))
    El.Print(p, "s + alpha y")
    El.Print(pDets, "det(s + alpha y)")

El.Finalize()