示例#1
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')
示例#2
0
#  Copyright (c) 2009-2015, 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 El

n = 200  # matrix size
realRes = imagRes = 100  # grid resolution

# Display an instance of the Fourier matrix
A = El.DistMatrix(El.zTag)
El.Fourier(A, n)
El.Display(A, "Fourier matrix")

# Display a submatrix and subvector of the Fourier matrix
El.Display(A[(n / 4):(3 * n / 4), (n / 4):(3 * n / 4)], "Middle submatrix")
El.Display(A[1, 0:n], "Second row")

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

# Require the user to press a button before the figures are closed
commSize = El.mpi.Size(El.mpi.COMM_WORLD())
El.Finalize()
if commSize == 1:
    raw_input('Press Enter to exit')
示例#3
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 El, time, math

n=100
realRes = imagRes = 50 # grid resolution

A = El.DistMatrix()
El.JordanCholesky( A, n )
El.Display( A, "A" )

El.Cholesky( El.UPPER, A )
El.MakeTrapezoidal( El.UPPER, A )
El.Display( A, "U" )

portrait = El.SpectralWindow(A,0,6,4,realRes,imagRes)
box = El.SpectralBox_d()
box.center = El.TagToType(El.Complexify(A.tag))(0)
box.realWidth = 6
box.imagWidth = 4
El.DisplayPortrait(portrait,box,"spectral portrait of 2*J_{1/2}(n)")

# 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')
示例#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')
示例#5
0
    El.RealPart(A, AReal)
    El.Display(AReal, 'Real part of Fox-Li matrix (n={})'.format(n))

    # Compute the Schur decomposition (overwriting A with the Schur factor)
    schurStart = time.time()
    w = El.Schur(A)
    schurStop = time.time()
    if A.Grid().Rank() is 0:
        print('Schur decomp for n={}: {} [sec]'.format(
            n,
            schurStop - schurStart,
        ))

    # Compute the spectral portrait of the Schur factor
    portraitStart = time.time()
    portrait, box = El.TriangularSpectralPortrait(A, realRes, imagRes)
    portraitStop = time.time()
    if A.Grid().Rank() is 0:
        print('Portrait for n={}: {} [sec]'.format(
            n,
            portraitStop - portraitStart,
        ))

    # Display the eigenvalues on top of log10 plot of portrait
    El.DisplayPortrait(portrait,
                       box,
                       title='Fox-Li portrait (n={})'.format(n),
                       eigvals=w)

El.Finalize()