예제 #1
0
파일: BPComplex.py 프로젝트: birm/Elemental
def ConcatFD2D(N0,N1):
  A = El.DistSparseMatrix(El.zTag)
  height = N0*N1
  width = 2*N0*N1
  A.Resize(height,width)
  localHeight = A.LocalHeight()
  A.Reserve(11*localHeight)
  for sLoc in xrange(localHeight):
    s = A.GlobalRow(sLoc)
    x0 = s % N0
    x1 = s / N0
    sRel = s + N0*N1

    A.QueueUpdate( s, s,    El.ComplexDouble(1,1) )
    A.QueueUpdate( s, sRel, El.ComplexDouble(20,2) )
    if x0 > 0:
      A.QueueUpdate( s, s-1,    El.ComplexDouble(-1,3) )
      A.QueueUpdate( s, sRel-1, El.ComplexDouble(-17,4) )
    if x0+1 < N0:
      A.QueueUpdate( s, s+1,    El.ComplexDouble(2,5) )
      A.QueueUpdate( s, sRel+1, El.ComplexDouble(-20,6) )
    if x1 > 0:
      A.QueueUpdate( s, s-N0,    El.ComplexDouble(-30,7) )
      A.QueueUpdate( s, sRel-N0, El.ComplexDouble(-3,8) )
    if x1+1 < N1:
      A.QueueUpdate( s, s+N0,    El.ComplexDouble(4,9) )
      A.QueueUpdate( s, sRel+N0, El.ComplexDouble(3,10) )

  A.ProcessLocalQueues()
  return A
예제 #2
0
파일: BPComplex.py 프로젝트: birm/Elemental
ctrl.ipmCtrl.mehrotraCtrl.targetTol = 1e-8
ctrl.ipmCtrl.mehrotraCtrl.time = True
ctrl.ipmCtrl.mehrotraCtrl.progress = True
ctrl.ipmCtrl.mehrotraCtrl.outerEquil = False
ctrl.ipmCtrl.mehrotraCtrl.innerEquil = True
ctrl.ipmCtrl.mehrotraCtrl.qsdCtrl.progress = True
startBP = El.mpi.Time()
x = El.BP( A, b, ctrl )
endBP = El.mpi.Time()
if worldRank == 0:
  print "BP time:", endBP-startBP, "seconds"
if display:
  El.Display( x, "x" )
if output:
  El.Print( x, "x" )

xOneNorm = El.EntrywiseNorm( x, 1 )
e = El.DistMultiVec(El.zTag)
El.Copy( b, e )
El.Multiply \
( El.NORMAL, El.ComplexDouble(-1), A, x, El.ComplexDouble(1), e )
eTwoNorm = El.Nrm2( e )
if worldRank == 0:
  print "|| x ||_1       =", xOneNorm
  print "|| A x - b ||_2 =", eTwoNorm

# Require the user to press a button before the figures are closed
El.Finalize()
if worldSize == 1:
  raw_input('Press Enter to exit')
예제 #3
0
def ConcatFD2D(N0,N1):
  A = El.DistMatrix(El.zTag)
  height = N0*N1
  width = 2*N0*N1
  El.Zeros(A,height,width)
  localHeight = A.LocalHeight()
  A.Reserve(11*localHeight)
  for iLoc in xrange(localHeight):
    i = A.GlobalRow(iLoc)
    x0 = i % N0
    x1 = i / N0
    iRel = i + N0*N1

    A.Update( i, i,    El.ComplexDouble(1,1) )
    A.Update( i, iRel, El.ComplexDouble(20,2) )
    if x0 > 0:
      A.Update( i, i-1,    El.ComplexDouble(-1,3) )
      A.Update( i, iRel-1, El.ComplexDouble(-17,4) )
    if x0+1 < N0:
      A.Update( i, i+1,    El.ComplexDouble(2,5) )
      A.Update( i, iRel+1, El.ComplexDouble(-20,6) )
    if x1 > 0:
      A.Update( i, i-N0,    El.ComplexDouble(-30,7) )
      A.Update( i, iRel-N0, El.ComplexDouble(-3,8) )
    if x1+1 < N1:
      A.Update( i, i+N0,    El.ComplexDouble(4,9) )
      A.Update( i, iRel+N0, El.ComplexDouble(3,10) )

    # The dense last column
    A.Update( i, width-1, El.ComplexDouble(-10/height) );

  return A
예제 #4
0
import El

# NOTE: Going above polynomials of order 50 leads to *very* large coefficients
#       alpha^n for n > 50, even if alpha is close to 1.
#
#       A different scheme is likely warranted than simply looking for
#       Z-linear dependence of { alpha^j }_{j=0}^{n-1}
#
alpha = El.ComplexDouble(1.002, 1.003)
n = 30
tag = El.zTag
progress = False
timeLLL = False
outputAll = False
outputCoeff = False

print "alpha=", alpha

ctrl = El.LLLCtrl_d()
ctrl.progress = progress
ctrl.time = timeLLL

NSqrt = 100000.

# NOTE: The coefficients become orders of magnitude higher for 'weak'
#       reductions and seem to reliably lead to an exception being thrown,
#       so these tests will only use strong LLL reductions

B = El.Matrix()
for presort, smallestFirst in (True, True), (True, False), (False, False):
    for deltaLower in 0.5, 0.75, 0.95, 0.98, 0.99:
예제 #5
0
ctrl = El.BPCtrl_z()
ctrl.ipmCtrl.mehrotraCtrl.minTol = 1e-5
ctrl.ipmCtrl.mehrotraCtrl.targetTol = 1e-8
ctrl.ipmCtrl.mehrotraCtrl.time = True
ctrl.ipmCtrl.mehrotraCtrl.progress = True
ctrl.ipmCtrl.mehrotraCtrl.solveCtrl.progress = True
startBP = El.mpi.Time()
x = El.BP( A, b, ctrl )
endBP = El.mpi.Time()
if worldRank == 0:
  print('BP time: {} seconds'.format(endBP-startBP))
if display:
  El.Display( x, "x" )
if output:
  El.Print( x, "x" )

xOneNorm = El.EntrywiseNorm( x, 1 )
e = El.DistMatrix(El.zTag)
El.Copy( b, e )
El.Gemv( El.NORMAL, El.ComplexDouble(-1), A, x, El.ComplexDouble(1), e )
if display:
  El.Display( e, "e" )
if output:
  El.Print( e, "e" )
eTwoNorm = El.Nrm2( e )
if worldRank == 0:
  print('|| x ||_1       = {}'.format(xOneNorm))
  print('|| A x - b ||_2 = {}'.format(eTwoNorm))

El.Finalize()