Ejemplo n.º 1
0
def CreateExpected(height):
  c = El.DistMultiVec()
  #Zeros( c, height, 1 )
  #localHeight = c.LocalHeight()
  #for iLoc in xrange(localHeight):
  #  i = c.GlobalRow(iLoc)
  #  c.SetLocal(iLoc,0,1.+1./i)
  El.Gaussian( c, height, 1 )
  El.EntrywiseMap( c, lambda alpha : abs(alpha) )

  return c
Ejemplo n.º 2
0
# Define a random (affine) hyperplane
wGen = El.DistMultiVec()
El.Gaussian(wGen, n0 * n1, 1)
wGenNorm = El.FrobeniusNorm(wGen)
El.Scale(1. / wGenNorm, wGen)
# TODO: Add support for mpi::Broadcast and randomly generate this
offset = 0.3147

A = StackedFD2D(n0, n1)

# Label the points based upon their location relative to the hyperplane
d = El.DistMultiVec()
El.Ones(d, 2 * n0 * n1, 1)
El.Multiply(El.NORMAL, 1., A, wGen, -offset, d)
El.EntrywiseMap(d, lambda alpha: 1. if alpha > 0 else -1.)

if display:
    El.Display(wGen, "wGen")
    if worldRank == 0:
        print "offset =", offset
    El.Display(A, "A")
    El.Display(d, "d")

ctrl = El.SVMCtrl_d()
ctrl.ipmCtrl.mehrotraCtrl.progress = True

for j in xrange(0, numLambdas):
    lambd = startLambda + j * (endLambda - startLambda) / (numLambdas - 1.)
    if worldRank == 0:
        print "lambda =", lambd
Ejemplo n.º 3
0
#  Copyright (c) 2009-2016, Jack Poulson
#  All rights reserved.
#
#  This file is part of Elemental and is under the BSD 2-Clause License, 
#  which can be found in the LICENSE file in the root directory, or at 
#  http://opensource.org/licenses/BSD-2-Clause
#
import math, El
n = 100                 # matrix size
realRes = imagRes = 100 # grid resolution

# Display an instance of the Fox-Li/Landau matrix
A = El.DistMatrix(El.zTag)
El.FoxLi(A,n)
El.Display(A,"Fox-Li/Landau matrix")

# Display its spectral portrait
portrait, box = El.SpectralPortrait(A,realRes,imagRes)
El.DisplayPortrait(portrait,box,"spectral portrait of Fox-Li/Landau matrix")

# Display its singular values
s = El.SingularValues(A)
El.EntrywiseMap(s,math.log10)
El.Display(s,"log10(svd(A))")

# Require the user to press a button before the figures are closed
worldSize = El.mpi.WorldSize()
El.Finalize()
if worldSize == 1:
  raw_input('Press Enter to exit')
Ejemplo n.º 4
0
#
#  This file is part of Elemental and is under the BSD 2-Clause License, 
#  which can be found in the LICENSE file in the root directory, or at 
#  http://opensource.org/licenses/BSD-2-Clause
#
import math, El
n = 100                 # matrix size
realRes = imagRes = 100 # grid resolution

# Display an instance of the pathological example
A = El.DistMatrix()
El.GEPPGrowth(A,n)
El.Display(A,"GEPP growth matrix")

# Display the spectral portrait
portrait, box = El.SpectralPortrait(A,realRes,imagRes)
El.DisplayPortrait(portrait,box,"spectral portrait of GEPP growth matrix")

# Display the relevant pieces of pivoted LU factorization
p = El.LU(A)
El.Display(p,"LU permutation")
El.EntrywiseMap(A,lambda x:math.log10(max(abs(x),1)))
El.Display(A,"Logarithmically-scaled LU factors")
El.Display(A[0:n,n-1],"Last column of logarithmic U")

# Require the user to press a button before the figures are closed
worldSize = El.mpi.WorldSize()
El.Finalize()
if worldSize == 1:
  raw_input('Press Enter to exit')