Beispiel #1
0
def bernstein_matrix_inverse_test():

    #*****************************************************************************80
    #
    ## BERNSTEIN_MATRIX_INVERSE_TEST tests BERNSTEIN_MATRIX_INVERSE.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    03 December 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    import numpy as np
    import platform
    from bernstein_matrix import bernstein_matrix
    from r8mat_is_identity import r8mat_is_identity
    from r8mat_norm_fro import r8mat_norm_fro

    print('')
    print('BERNSTEIN_MATRIX_INVERSE_TEST')
    print('  Python version: %s' % (platform.python_version()))
    print('  BERNSTEIN_MATRIX returns a matrix A which transforms a')
    print('  polynomial coefficient vector from the power basis to')
    print('  the Bernstein basis.')
    print('  BERNSTEIN_MATRIX_INVERSE computes the inverse B.')
    print('')
    print('    N     ||A||            ||B||      ||I-A*B||')
    print('')

    for n in range(5, 16):

        a = bernstein_matrix(n)
        a_norm_frobenius = r8mat_norm_fro(n, n, a)

        b = bernstein_matrix_inverse(n)
        b_norm_frobenius = r8mat_norm_fro(n, n, b)

        c = np.dot(a, b)
        error_norm_frobenius = r8mat_is_identity(n, c)

        print ( '  %4d  %14g  %14g  %14g' % \
          ( n, a_norm_frobenius, b_norm_frobenius, error_norm_frobenius ) )


#
#  Terminate.
#
    print('')
    print('BERNSTEIN_MATRIX_INVERSE TEST')
    print('  Normal end of execution.')
    return
def r8mat_is_inverse ( n, a, b ):

#*****************************************************************************80
#
## R8MAT_IS_INVERSE measures the error in a matrix inverse.
#
#  Discussion:
#
#    An R8MAT is a matrix of real values.
#
#    This routine returns the sum of the Frobenius norms of
#      A * B - I and B * A - I.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    23 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer N, the order of the matrix.
#
#    Input, real A(N,N), the matrix.
#
#    Input, real B(M,N), the inverse matrix.
#
#    Output, real VALUE, the Frobenius norm
#    of the difference matrices A * B - I and B * A - I.
#
  from identity import identity
  from r8mat_mm import r8mat_mm
  from r8mat_sub import r8mat_sub
  from r8mat_norm_fro import r8mat_norm_fro

  ab = r8mat_mm ( n, n, n, a, b )
  ba = r8mat_mm ( n, n, n, b, a )
  id = identity ( n, n )
  d1 = r8mat_sub ( n, n, ab, id )
  d2 = r8mat_sub ( n, n, ba, id )
 
  value = r8mat_norm_fro ( n, n, d1 ) \
        + r8mat_norm_fro ( n, n, d2 )

  return value
def r8mat_is_solution ( m, n, k, a, x, b ):

#*****************************************************************************80
#
## R8MAT_IS_SOLUTION measures the error in a linear system solution.
#
#  Discussion:
#
#    An R8MAT is a matrix of real values.
#
#    The system matrix A is an M x N matrix.
#    It is not required that A be invertible.
#
#    The solution vector X is actually allowed to be an N x K matrix.
#
#    The right hand side "vector" B is actually allowed to be an M x K matrix.
#
#    This routine simply returns the Frobenius norm of the M x K matrix:
#    A * X - B.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    02 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer M, N, K, the order of the matrices.
#
#    Input, real A(M,N), X(N,K), B(M,K), the matrices.
#
#    Output, real VALUE, the Frobenius norm
#    of the difference matrix A * X - B, which would be exactly zero
#    if X was the "solution" of the linear system.
#
  from r8mat_norm_fro import r8mat_norm_fro
  from r8mat_mm import r8mat_mm
  from r8mat_sub import r8mat_sub
#
#  AX = A*X
#
  ax = r8mat_mm ( m, n, k, a, x )
#
#  AXMB = AX-B.
#
  axmb = r8mat_sub ( m, k, ax, b )
#
#  Value = ||AX-B|\
#
  value = r8mat_norm_fro ( m, k, axmb )

  return value
Beispiel #4
0
def r8mat_is_solution(m, n, k, a, x, b):

    #*****************************************************************************80
    #
    ## R8MAT_IS_SOLUTION measures the error in a linear system solution.
    #
    #  Discussion:
    #
    #    An R8MAT is a matrix of real values.
    #
    #    The system matrix A is an M x N matrix.
    #    It is not required that A be invertible.
    #
    #    The solution vector X is actually allowed to be an N x K matrix.
    #
    #    The right hand side "vector" B is actually allowed to be an M x K matrix.
    #
    #    This routine simply returns the Frobenius norm of the M x K matrix:
    #    A * X - B.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    02 March 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    #  Parameters:
    #
    #    Input, integer M, N, K, the order of the matrices.
    #
    #    Input, real A(M,N), X(N,K), B(M,K), the matrices.
    #
    #    Output, real VALUE, the Frobenius norm
    #    of the difference matrix A * X - B, which would be exactly zero
    #    if X was the "solution" of the linear system.
    #
    from r8mat_norm_fro import r8mat_norm_fro
    from r8mat_mm import r8mat_mm
    from r8mat_sub import r8mat_sub
    #
    #  AX = A*X
    #
    ax = r8mat_mm(m, n, k, a, x)
    #
    #  AXMB = AX-B.
    #
    axmb = r8mat_sub(m, k, ax, b)
    #
    #  Value = ||AX-B|\
    #
    value = r8mat_norm_fro(m, k, axmb)

    return value
def bernstein_matrix_determinant_test():

    #*****************************************************************************80
    #
    ## BERNSTEIN_MATRIX_DETERMINANT_TEST tests BERNSTEIN_MATRIX_DETERMINANT.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    03 December 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    import numpy as np
    import platform
    from bernstein_matrix import bernstein_matrix
    from r8mat_is_identity import r8mat_is_identity
    from r8mat_norm_fro import r8mat_norm_fro

    print('')
    print('BERNSTEIN_MATRIX_DETERMINANT_TEST')
    print('  Python version: %s' % (platform.python_version()))
    print('  BERNSTEIN_MATRIX_DETERMINANT computes the determinant of')
    print('  the Bernstein matrix.')
    print('')
    print('    N     ||A||            det(A)      np.linalg.det(A)')
    print('')

    for n in range(5, 16):

        a = bernstein_matrix(n)
        a_norm_frobenius = r8mat_norm_fro(n, n, a)

        d1 = bernstein_matrix_determinant(n)
        d2 = np.linalg.det(a)

        print ( '  %4d  %14g  %14g  %14g' % \
          ( n, a_norm_frobenius, d1, d2 ) )


#
#  Terminate.
#
    print('')
    print('BERNSTEIN_MATRIX_DETERMINANT TEST')
    print('  Normal end of execution.')
    return
def r8mat_is_plu ( m, n, a, p, l, u ):

#*****************************************************************************80
#
## R8MAT_IS_PLU measures the error in a PLU factorization.
#
#  Discussion:
#
#    An R8MAT is a matrix of real values.
#
#    This routine computes the Frobenius norm of
#
#      A - P * L * U
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    23 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer M, N, the order of the matrix.
#
#    Input, real A(M,N), the matrix.
#
#    Input, real P(M,M), L(M,M), U(M,N), the PLU factors.
#
#    Output, real VALUE, the Frobenius norm
#    of the difference matrix A - P * L * U.
#
  from r8mat_mm import r8mat_mm
  from r8mat_sub import r8mat_sub
  from r8mat_norm_fro import r8mat_norm_fro

  lu = r8mat_mm ( m, m, n, l, u )
  plu = r8mat_mm ( m, m, n, p, lu )

  d = r8mat_sub ( m, n, a, plu )
 
  value = r8mat_norm_fro ( m, n, d )

  return value
Beispiel #7
0
def test_plu():

    #*****************************************************************************80
    #
    ## TEST_PLU tests the PLU factors.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    07 April 2014
    #
    #  Author:
    #
    #    John Burkardt
    #
    import numpy as np
    from bodewig import bodewig
    from bodewig import bodewig_plu
    from borderband import borderband
    from borderband import borderband_plu
    from dif2 import dif2
    from dif2 import dif2_plu
    from gfpp import gfpp
    from gfpp import gfpp_plu
    from givens import givens
    from givens import givens_plu
    from i4_uniform_ab import i4_uniform_ab
    from kms import kms
    from kms import kms_plu
    from lehmer import lehmer
    from lehmer import lehmer_plu
    from maxij import maxij
    from maxij import maxij_plu
    from minij import minij
    from minij import minij_plu
    from moler1 import moler1
    from moler1 import moler1_plu
    from moler3 import moler3
    from moler3 import moler3_plu
    from oto import oto
    from oto import oto_plu
    from pascal2 import pascal2
    from pascal2 import pascal2_plu
    from plu import plu
    from plu import plu_plu
    from r8_uniform_ab import r8_uniform_ab
    from r8mat_is_plu import r8mat_is_plu
    from r8mat_norm_fro import r8mat_norm_fro
    from r8vec_uniform_ab import r8vec_uniform_ab
    from vand2 import vand2
    from vand2 import vand2_plu
    from wilson import wilson
    from wilson import wilson_plu

    print ''
    print 'TEST_PLU'
    print '  A = a test matrix of order M by N'
    print '  P, L, U are the PLU factors.'
    print ''
    print '  ||A|| = Frobenius norm of A.'
    print '  ||A-PLU|| = Frobenius norm of A-P*L*U.'
    print ''
    print '  Title                    M     N         ',
    print '||A||        ||A-PLU||'
    print ''
    #
    #  BODEWIG
    #
    title = 'BODEWIG'
    m = 4
    n = 4
    a = bodewig()
    p, l, u = bodewig_plu()
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  BORDERBAND
    #
    title = 'BORDERBAND'
    m = 5
    n = 5
    a = borderband(n)
    p, l, u = borderband_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  DIF2
    #
    title = 'DIF2'
    m = 5
    n = 5
    a = dif2(m, n)
    p, l, u = dif2_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  GFPP
    #
    title = 'GFPP'
    m = 5
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    a = gfpp(n, alpha)
    p, l, u = gfpp_plu(n, alpha)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  GIVENS
    #
    title = 'GIVENS'
    m = 5
    n = 5
    a = givens(m, n)
    p, l, u = givens_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  KMS
    #
    title = 'KMS'
    m = 5
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    a = kms(alpha, m, n)
    p, l, u = kms_plu(alpha, n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  LEHMER
    #
    title = 'LEHMER'
    m = 5
    n = 5
    a = lehmer(m, n)
    p, l, u = lehmer_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  MAXIJ
    #
    title = 'MAXIJ'
    m = 5
    n = 5
    a = maxij(m, n)
    p, l, u = maxij_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  MINIJ
    #
    title = 'MINIJ'
    m = 5
    n = 5
    a = minij(n, n)
    p, l, u = minij_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  MOLER1
    #
    title = 'MOLER1'
    m = 5
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    a = moler1(alpha, n, n)
    p, l, u = moler1_plu(alpha, n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  MOLER3
    #
    title = 'MOLER3'
    m = 5
    n = 5
    a = moler3(m, n)
    p, l, u = moler3_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  OTO
    #
    title = 'OTO'
    m = 5
    n = 5
    a = oto(m, n)
    p, l, u = oto_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  PASCAL2
    #
    title = 'PASCAL2'
    m = 5
    n = 5
    a = pascal2(n)
    p, l, u = pascal2_plu(n)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  PLU
    #
    title = 'PLU'
    m = 5
    n = 5
    pivot = np.zeros(n)
    seed = 123456789
    for i in range(0, n):
        i4_lo = i
        i4_hi = n - 1
        pivot[i], seed = i4_uniform_ab(i4_lo, i4_hi, seed)
    a = plu(n, pivot)
    p, l, u = plu_plu(n, pivot)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  VAND2
    #
    title = 'VAND2'
    m = 4
    n = 4
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    x, seed = r8vec_uniform_ab(m, r8_lo, r8_hi, seed)
    a = vand2(m, x)
    p, l, u = vand2_plu(m, x)
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  WILSON
    #
    title = 'WILSON'
    m = 4
    n = 4
    a = wilson()
    p, l, u = wilson_plu()
    error_frobenius = r8mat_is_plu(m, n, a, p, l, u)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    print '  %-20s  %4d  %4d  %14g  %14g' \
      % ( title, m, n, norm_a_frobenius, error_frobenius )
    #
    #  Terminate.
    #
    print ''
    print 'TEST_PLU:'
    print '  Normal end of execution.'

    return
def test_null_right():

    #*****************************************************************************80
    #
    ## TEST_NULL_RIGHT tests right null vectors.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    12 March 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from a123 import a123
    from a123 import a123_null_right
    from archimedes import archimedes
    from archimedes import archimedes_null_right
    from cheby_diff1 import cheby_diff1
    from cheby_diff1 import cheby_diff1_null_right
    from creation import creation
    from creation import creation_null_right
    from dif1 import dif1
    from dif1 import dif1_null_right
    from dif1cyclic import dif1cyclic
    from dif1cyclic import dif1cyclic_null_right
    from dif2cyclic import dif2cyclic
    from dif2cyclic import dif2cyclic_null_right
    from fibonacci1 import fibonacci1
    from fibonacci1 import fibonacci1_null_right
    from hamming import hamming
    from hamming import hamming_null_right
    from line_adj import line_adj
    from line_adj import line_adj_null_right
    from moler2 import moler2
    from moler2 import moler2_null_right
    from neumann import neumann
    from neumann import neumann_null_right
    from one import one
    from one import one_null_right
    from r8_uniform_ab import r8_uniform_ab
    from r8mat_is_null_right import r8mat_is_null_right
    from r8mat_norm_fro import r8mat_norm_fro
    from r8vec_norm_l2 import r8vec_norm_l2
    from ring_adj import ring_adj
    from ring_adj import ring_adj_null_right
    from rosser1 import rosser1
    from rosser1 import rosser1_null_right
    from zero import zero
    from zero import zero_null_right

    print ''
    print 'TEST_NULL_RIGHT'
    print '  A = a test matrix of order M by N'
    print '  x = an N vector, candidate for a right null vector.'
    print ''
    print '  ||A|| = Frobenius norm of A.'
    print '  ||x|| = L2 norm of x.'
    print '  ||A*x||/||x|| = L2 norm of A*x over L2 norm of x.'
    print ''
    print '  Title                    M     N      ',
    print '||A||            ||x||        ||A*x||/||x||'
    print ''
    #
    #  A123
    #
    title = 'A123'
    m = 3
    n = 3
    a = a123()
    x = a123_null_right()
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  ARCHIMEDES
    #
    title = 'ARCHIMEDES'
    m = 7
    n = 8
    a = archimedes()
    x = archimedes_null_right()
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  CHEBY_DIFF1
    #
    title = 'CHEBY_DIFF1'
    m = 5
    n = m
    a = cheby_diff1(n)
    x = cheby_diff1_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  CREATION
    #
    title = 'CREATION'
    m = 5
    n = m
    a = creation(m, n)
    x = creation_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  DIF1
    #  Only has null vectors for N odd.
    #
    title = 'DIF1'
    m = 5
    n = m
    a = dif1(m, n)
    x = dif1_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  DIF1CYCLIC
    #
    title = 'DIF1CYCLIC'
    m = 5
    n = m
    a = dif1cyclic(n)
    x = dif1cyclic_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  DIF2CYCLIC
    #
    title = 'DIF2CYCLIC'
    m = 5
    n = m
    a = dif2cyclic(n)
    x = dif2cyclic_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  FIBONACCI1
    #
    title = 'FIBONACCI1'
    m = 5
    n = m
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    f1, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    f2, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    a = fibonacci1(n, f1, f2)
    x = fibonacci1_null_right(m, n, f1, f2)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  HAMMING
    #
    title = 'HAMMING'
    m = 5
    n = (2**m) - 1
    a = hamming(m, n)
    x = hamming_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  LINE_ADJ
    #
    title = 'LINE_ADJ'
    m = 7
    n = m
    a = line_adj(n)
    x = line_adj_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  MOLER2
    #
    title = 'MOLER2'
    m = 5
    n = 5
    a = moler2()
    x = moler2_null_right()
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  NEUMANN
    #
    title = 'NEUMANN'
    row_num = 5
    col_num = 5
    m = row_num * col_num
    n = row_num * col_num
    a = neumann(row_num, col_num)
    x = neumann_null_right(row_num, col_num)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  ONE
    #
    title = 'ONE'
    m = 5
    n = 5
    a = one(m, n)
    x = one_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  RING_ADJ
    #  N must be a multiple of 4 for there to be a null vector.
    #
    title = 'RING_ADJ'
    m = 12
    n = 12
    a = ring_adj(m, n)
    x = ring_adj_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  ROSSER1
    #
    title = 'ROSSER1'
    m = 8
    n = 8
    a = rosser1()
    x = rosser1_null_right()
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  ZERO
    #
    title = 'ZERO'
    m = 5
    n = 5
    a = zero(m, n)
    x = zero_null_right(m, n)
    error_l2 = r8mat_is_null_right(m, n, a, x)
    norm_a_frobenius = r8mat_norm_fro(m, n, a)
    norm_x_l2 = r8vec_norm_l2(n, x)
    print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
      % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
    #
    #  Terminate.
    #
    print ''
    print 'TEST_NULL_RIGHT:'
    print '  Normal end of execution.'

    return
Beispiel #9
0
def test_llt ( ):

#*****************************************************************************80
#
#% TEST_LLT tests LLT factors.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    09 April 2015
#
#  Author:
#
#    John Burkardt
#
  from dif2           import dif2
  from dif2           import dif2_llt
  from givens         import givens
  from givens         import givens_llt
  from kershaw        import kershaw
  from kershaw        import kershaw_llt
  from lehmer         import lehmer
  from lehmer         import lehmer_llt
  from minij          import minij
  from minij          import minij_llt
  from moler1         import moler1
  from moler1         import moler1_llt
  from moler3         import moler3
  from moler3         import moler3_llt
  from oto            import oto
  from oto            import oto_llt
  from pascal2        import pascal2
  from pascal2        import pascal2_llt
  from wilson         import wilson
  from wilson         import wilson_llt
  from r8_uniform_ab  import r8_uniform_ab
  from r8mat_is_llt   import r8mat_is_llt
  from r8mat_norm_fro import r8mat_norm_fro

  print ''
  print 'TEST_LLT'
  print '  A = a test matrix of order M by M'
  print '  L is an M by N lower triangular Cholesky factor.'
  print ''
  print '  ||A|| = Frobenius norm of A.'
  print '  ||A-LLT|| = Frobenius norm of A-L*L\'.'
  print ''
  print '  Title                    M     N      ',
  print '||A||            ||A-LLT||'
  print ''
#
#  DIF2
#
  title = 'DIF2'
  m = 5
  n = 5
  a = dif2 ( m, n )
  l = dif2_llt ( n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  GIVENS
#
  title = 'GIVENS'
  m = 5
  n = 5
  a = givens ( m, n )
  l = givens_llt ( n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  KERSHAW
#
  title = 'KERSHAW'
  m = 4
  n = 4
  a = kershaw ( )
  l = kershaw_llt ( )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  LEHMER
#
  title = 'LEHMER'
  m = 5
  n = 5
  a = lehmer ( n, n )
  l = lehmer_llt ( n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  MINIJ
#
  title = 'MINIJ'
  m = 5
  n = 5
  a = minij ( n, n )
  l = minij_llt ( n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  MOLER1
#
  title = 'MOLER1'
  m = 5
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = moler1 ( alpha, m, n )
  l = moler1_llt ( alpha, n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  MOLER3
#
  title = 'MOLER3'
  m = 5
  n = 5
  a = moler3 ( m, n )
  l = moler3_llt ( n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  OTO
#
  title = 'OTO'
  m = 5
  n = 5
  a = oto ( m, n )
  l = oto_llt ( n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  PASCAL2
#
  title = 'PASCAL2'
  m = 5
  n = 5
  a = pascal2 ( n )
  l = pascal2_llt ( n )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  WILSON
#
  title = 'WILSON'
  m = 4
  n = 4
  a = wilson ( )
  l = wilson_llt ( )
  error_frobenius = r8mat_is_llt ( m, n, a, l )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  Terminate.
#
  print ''
  print 'TEST_LLT:'
  print '  Normal end of execution.'

  return
Beispiel #10
0
def r8mat_is_eigen_left(n, k, a, x, lam):

    #*****************************************************************************80
    #
    ## R8MAT_IS_EIGEN_LEFT determines the error in a left eigensystem.
    #
    #  Discussion:
    #
    #    An R8MAT is a matrix of real values.
    #
    #    This routine computes the Frobenius norm of
    #
    #      X * A - LAMBDA * X
    #
    #    where
    #
    #      A is an N by N matrix,
    #      X is an K by N matrix (each of K columns is an eigenvector)
    #      LAMBDA is a K by K diagonal matrix of eigenvalues.
    #
    #    This routine assumes that A, X and LAMBDA are all real.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    17 March 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    #  Parameters:
    #
    #    Input, integer N, the order of the matrix.
    #
    #    Input, integer K, the number of eigenvectors.
    #    K is usually 1 or N.
    #
    #    Input, real A(N,N), the matrix.
    #
    #    Input, real X(K,N), the K eigenvectors.
    #
    #    Input, real LAM(K), the K eigenvalues.
    #
    #    Output, real VALUE, the Frobenius norm of X * A - LAM * X.
    #
    from r8mat_mm import r8mat_mm
    from r8mat_norm_fro import r8mat_norm_fro

    c = r8mat_mm(k, n, n, x, a)

    for i in range(0, k):
        for j in range(0, n):
            c[i, j] = c[i, j] - lam[i] * x[i, j]

    value = r8mat_norm_fro(k, n, c)

    return value
Beispiel #11
0
def test_plu ( ):

#*****************************************************************************80
#
## TEST_PLU tests the PLU factors.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    07 April 2014
#
#  Author:
#
#    John Burkardt
#
  import numpy as np
  from bodewig          import bodewig
  from bodewig          import bodewig_plu
  from borderband       import borderband
  from borderband       import borderband_plu
  from dif2             import dif2
  from dif2             import dif2_plu
  from gfpp             import gfpp
  from gfpp             import gfpp_plu
  from givens           import givens
  from givens           import givens_plu
  from i4_uniform_ab    import i4_uniform_ab
  from kms              import kms
  from kms              import kms_plu
  from lehmer           import lehmer
  from lehmer           import lehmer_plu
  from maxij            import maxij
  from maxij            import maxij_plu
  from minij            import minij
  from minij            import minij_plu
  from moler1           import moler1
  from moler1           import moler1_plu
  from moler3           import moler3
  from moler3           import moler3_plu
  from oto              import oto
  from oto              import oto_plu
  from pascal2          import pascal2
  from pascal2          import pascal2_plu
  from plu              import plu
  from plu              import plu_plu
  from r8_uniform_ab    import r8_uniform_ab
  from r8mat_is_plu     import r8mat_is_plu
  from r8mat_norm_fro   import r8mat_norm_fro
  from r8vec_uniform_ab import r8vec_uniform_ab
  from vand2            import vand2
  from vand2            import vand2_plu
  from wilson           import wilson
  from wilson           import wilson_plu

  print ''
  print 'TEST_PLU'
  print '  A = a test matrix of order M by N'
  print '  P, L, U are the PLU factors.'
  print ''
  print '  ||A|| = Frobenius norm of A.'
  print '  ||A-PLU|| = Frobenius norm of A-P*L*U.'
  print ''
  print '  Title                    M     N         ',
  print '||A||        ||A-PLU||'
  print ''
#
#  BODEWIG
#
  title = 'BODEWIG'
  m = 4
  n = 4
  a = bodewig ( )
  p, l, u = bodewig_plu ( )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  BORDERBAND
#
  title = 'BORDERBAND'
  m = 5
  n = 5
  a = borderband ( n )
  p, l, u = borderband_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  DIF2
#
  title = 'DIF2'
  m = 5
  n = 5
  a = dif2 ( m, n )
  p, l, u = dif2_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  GFPP
#
  title = 'GFPP'
  m = 5
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = gfpp ( n, alpha )
  p, l, u = gfpp_plu ( n, alpha )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  GIVENS
#
  title = 'GIVENS'
  m = 5
  n = 5
  a = givens ( m, n )
  p, l, u = givens_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  KMS
#
  title = 'KMS'
  m = 5
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = kms ( alpha, m, n )
  p, l, u = kms_plu ( alpha, n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  LEHMER
#
  title = 'LEHMER'
  m = 5
  n = 5
  a = lehmer ( m, n )
  p, l, u = lehmer_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  MAXIJ
#
  title = 'MAXIJ'
  m = 5
  n = 5
  a = maxij ( m, n )
  p, l, u = maxij_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  MINIJ
#
  title = 'MINIJ'
  m = 5
  n = 5
  a = minij ( n, n )
  p, l, u = minij_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  MOLER1
#
  title = 'MOLER1'
  m = 5
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = moler1 ( alpha, n, n )
  p, l, u = moler1_plu ( alpha, n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  MOLER3
#
  title = 'MOLER3'
  m = 5
  n = 5
  a = moler3 ( m, n )
  p, l, u = moler3_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  OTO
#
  title = 'OTO'
  m = 5
  n = 5
  a = oto ( m, n )
  p, l, u = oto_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  PASCAL2
#
  title = 'PASCAL2'
  m = 5
  n = 5
  a = pascal2 ( n )
  p, l, u = pascal2_plu ( n )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  PLU
#
  title = 'PLU'
  m = 5
  n = 5
  pivot = np.zeros ( n )
  seed = 123456789
  for i in range ( 0, n ):
    i4_lo = i
    i4_hi = n - 1
    pivot[i], seed = i4_uniform_ab ( i4_lo, i4_hi, seed )
  a = plu ( n, pivot )
  p, l, u = plu_plu ( n, pivot )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  VAND2
#
  title = 'VAND2'
  m = 4
  n = 4
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  x, seed = r8vec_uniform_ab ( m, r8_lo, r8_hi, seed )
  a = vand2 ( m, x )
  p, l, u = vand2_plu ( m, x )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  WILSON
#
  title = 'WILSON'
  m = 4
  n = 4
  a = wilson ( )
  p, l, u = wilson_plu ( )
  error_frobenius = r8mat_is_plu ( m, n, a, p, l, u )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  print '  %-20s  %4d  %4d  %14g  %14g' \
    % ( title, m, n, norm_a_frobenius, error_frobenius )
#
#  Terminate.
#
  print ''
  print 'TEST_PLU:'
  print '  Normal end of execution.'

  return
def test_solution ( ):

#*****************************************************************************80
#
## TEST_SOLUTION tests the linear solution computations.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    10 March 2015
#
#  Author:
#
#    John Burkardt
#
  import numpy as np

  from a123              import a123
  from a123              import a123_rhs
  from a123              import a123_solution
  from bodewig           import bodewig
  from bodewig           import bodewig_rhs
  from bodewig           import bodewig_solution
  from dif2              import dif2
  from dif2              import dif2_rhs
  from dif2              import dif2_solution
  from frank             import frank
  from frank             import frank_rhs
  from frank             import frank_solution
  from poisson           import poisson
  from poisson           import poisson_rhs
  from poisson           import poisson_solution
  from r8mat_is_solution import r8mat_is_solution
  from r8mat_norm_fro    import r8mat_norm_fro
  from wilk03            import wilk03
  from wilk03            import wilk03_rhs
  from wilk03            import wilk03_solution
  from wilk04            import wilk04
  from wilk04            import wilk04_rhs
  from wilk04            import wilk04_solution
  from wilson            import wilson
  from wilson            import wilson_rhs
  from wilson            import wilson_solution

  print ''
  print 'TEST_SOLUTION'
  print '  Compute the Frobenius norm of the solution error:'
  print '    A * X - B'
  print '  given MxN matrix A, NxK solution X, MxK right hand side B.'
  print ''
  print '  Title                    M     N     K       ||A||',
  print '            ||A*X-B||'
  print ''
#
#  A123 matrix.
#
  title = 'A123'
  m = 3
  n = 3
  k = 1
  a = a123 ( )
  b = a123_rhs ( )
  x = a123_solution ( )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  BODEWIG matrix.
#
  title = 'BODEWIG'
  m = 4
  n = 4
  k = 1
  a = bodewig ( )
  b = bodewig_rhs ( )
  x = bodewig_solution ( )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  DIF2 matrix.
#
  title = 'DIF2'
  m = 10
  n = 10
  k = 2
  a = dif2 ( m, n )
  b = dif2_rhs ( m, k )
  x = dif2_solution ( n, k )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  FRANK matrix.
#
  title = 'FRANK'
  m = 10
  n = 10
  k = 2
  a = frank ( n )
  b = frank_rhs ( m, k )
  x = frank_solution ( n, k )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  POISSON matrix.
#
  title = 'POISSON'
  nrow = 4
  ncol = 5
  m = nrow * ncol
  n = nrow * ncol
  k = 1
  a = poisson ( nrow, ncol )
  b = poisson_rhs ( nrow, ncol, k )
  x = poisson_solution ( nrow, ncol, k )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  WILK03 matrix.
#
  title = 'WILK03'
  m = 3
  n = 3
  k = 1
  a = wilk03 ( )
  b = wilk03_rhs ( )
  x = wilk03_solution ( )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  WILK04 matrix.
#
  title = 'WILK04'
  m = 4
  n = 4
  k = 1
  a = wilk04 ( )
  b = wilk04_rhs ( )
  x = wilk04_solution ( )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  WILSON matrix.
#
  title = 'WILSON'
  m = 4
  n = 4
  k = 1
  a = wilson ( )
  b = wilson_rhs ( )
  x = wilson_solution ( )
  error_frobenius = r8mat_is_solution ( m, n, k, a, x, b )
  norm_frobenius = r8mat_norm_fro ( n, n, a )
  print '  %-20s  %4d  %4d  %4d  %14g  %14g' \
    % ( title, m, n, k, norm_frobenius, error_frobenius )
#
#  Terminate.
#
  print ''
  print 'TEST_SOLUTION'
  print '  Normal end of execution.'

  return
def r8mat_is_eigen_left ( n, k, a, x, lam ):

#*****************************************************************************80
#
## R8MAT_IS_EIGEN_LEFT determines the error in a left eigensystem.
#
#  Discussion:
#
#    An R8MAT is a matrix of real values.
#
#    This routine computes the Frobenius norm of
#
#      X * A - LAMBDA * X
#
#    where
#
#      A is an N by N matrix,
#      X is an K by N matrix (each of K columns is an eigenvector)
#      LAMBDA is a K by K diagonal matrix of eigenvalues.
#
#    This routine assumes that A, X and LAMBDA are all real.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    17 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer N, the order of the matrix.
#
#    Input, integer K, the number of eigenvectors.
#    K is usually 1 or N.
#
#    Input, real A(N,N), the matrix.
#
#    Input, real X(K,N), the K eigenvectors.
#
#    Input, real LAM(K), the K eigenvalues.
#
#    Output, real VALUE, the Frobenius norm of X * A - LAM * X.
#
  from r8mat_mm import r8mat_mm
  from r8mat_norm_fro import r8mat_norm_fro

  c = r8mat_mm ( k, n, n, x, a )

  for i in range ( 0, k ):
    for j in range ( 0, n ):
      c[i,j] = c[i,j] - lam[i] * x[i,j]

  value = r8mat_norm_fro ( k, n, c )

  return value
def r8mat_is_eigen_right ( n, k, a, x, lam ):

#*****************************************************************************80
#
## R8MAT_IS_EIGEN_RIGHT determines the error in a right eigensystem.
#
#  Discussion:
#
#    An R8MAT is a matrix of real values.
#
#    This routine computes the Frobenius norm of
#
#      A * X - X * LAMBDA
#
#    where
#
#      A is an N by N matrix,
#      X is an N by K matrix (each of K columns is an eigenvector)
#      LAMBDA is a K by K diagonal matrix of eigenvalues.
#
#    This routine assumes that A, X and LAMBDA are all real.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    11 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer N, the order of the matrix.
#
#    Input, integer K, the number of eigenvectors.
#    K is usually 1 or N.
#
#    Input, real A(N,N), the matrix.
#
#    Input, real X(N,K), the K eigenvectors.
#
#    Input, real LAM(K), the K eigenvalues.
#
#    Output, real VALUE, the Frobenius norm
#    of the difference matrix A * X - X * LAM, which would be exactly zero
#    if X and LAM were exact eigenvectors and eigenvalues of A.
#
  from r8mat_mm import r8mat_mm
  from r8mat_norm_fro import r8mat_norm_fro

  c = r8mat_mm ( n, n, k, a, x )

  for j in range ( 0, k ):
    for i in range ( 0, n ):
      c[i,j] = c[i,j] - lam[j] * x[i,j]

  value = r8mat_norm_fro ( n, k, c )

  return value
def test_null_left ( ):

#*****************************************************************************80
#
## TEST_NULL_LEFT tests left null vectors.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    17 March 2015
#
#  Author:
#
#    John Burkardt
#
  from a123                import a123
  from a123                import a123_null_left
  from cheby_diff1         import cheby_diff1
  from cheby_diff1         import cheby_diff1_null_left
  from creation            import creation
  from creation            import creation_null_left
  from dif1                import dif1
  from dif1                import dif1_null_left
  from dif1cyclic          import dif1cyclic
  from dif1cyclic          import dif1cyclic_null_left
  from dif2cyclic          import dif2cyclic
  from dif2cyclic          import dif2cyclic_null_left
  from eberlein            import eberlein
  from eberlein            import eberlein_null_left
  from fibonacci1          import fibonacci1
  from fibonacci1          import fibonacci1_null_left
  from lauchli             import lauchli
  from lauchli             import lauchli_null_left
  from line_adj            import line_adj
  from line_adj            import line_adj_null_left
  from moler2              import moler2
  from moler2              import moler2_null_left
  from one                 import one
  from one                 import one_null_left
  from r8_uniform_ab       import r8_uniform_ab
  from r8mat_is_null_left  import r8mat_is_null_left
  from r8mat_norm_fro      import r8mat_norm_fro
  from r8vec_norm_l2       import r8vec_norm_l2
  from ring_adj            import ring_adj
  from ring_adj            import ring_adj_null_left
  from rosser1             import rosser1
  from rosser1             import rosser1_null_left
  from zero                import zero
  from zero                import zero_null_left

  print ''
  print 'TEST_NULL_LEFT'
  print '  A = a test matrix of order M by N'
  print '  x = an M vector, candidate for a left null vector.'
  print ''
  print '  ||A|| = Frobenius norm of A.'
  print '  ||x|| = L2 norm of x.'
  print '  ||A''*x||/||x|| = L2 norm of A\'*x over L2 norm of x.'
  print ''
  print '  Title                    M     N      ',
  print '||A||            ||x||        ||A\'*x||/||x||'
  print ''
#
#  A123
#
  title = 'A123'
  m = 3
  n = 3
  a = a123 ( )
  x = a123_null_left ( )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  CHEBY_DIFF1
#
  title = 'CHEBY_DIFF1'
  m = 5
  n = m
  a = cheby_diff1 ( n )
  x = cheby_diff1_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  CREATION
#
  title = 'CREATION'
  m = 5
  n = m
  a = creation ( m, n )
  x = creation_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  DIF1
#
  title = 'DIF1'
  m = 5
  n = 5
  a = dif1 ( m, n )
  x = dif1_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  DIF1CYCLIC
#
  title = 'DIF1CYCLIC'
  m = 5
  n = m
  a = dif1cyclic ( n )
  x = dif1cyclic_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  DIF2CYCLIC
#
  title = 'DIF2CYCLIC'
  m = 5
  n = 5
  a = dif2cyclic ( n )
  x = dif2cyclic_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  EBERLEIN
#
  title = 'EBERLEIN'
  m = 5
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = eberlein ( alpha, n )
  x = eberlein_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  FIBONACCI1
#
  title = 'FIBONACCI1'
  m = 5
  n = m
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  f1, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  f2, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = fibonacci1 ( n, f1, f2 )
  x = fibonacci1_null_left ( m, n, f1, f2 )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  LAUCHLI
#
  title = 'LAUCHLI'
  m = 6
  n = m - 1
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = lauchli ( alpha, m, n )
  x = lauchli_null_left ( alpha, m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  LINE_ADJ
#
  title = 'LINE_ADJ'
  m = 7
  n = m
  a = line_adj ( n )
  x = line_adj_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  MOLER2
#
  title = 'MOLER2'
  m = 5
  n = m
  a = moler2 ( )
  x = moler2_null_left ( )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  ONE
#
  title = 'ONE'
  m = 5
  n = 5
  a = one ( m, n )
  x = one_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  RING_ADJ
#  N must be a multiple of 4 for there to be a null vector.
#
  title = 'RING_ADJ'
  m = 12
  n = 12
  a = ring_adj ( m, n )
  x = ring_adj_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  ROSSER1
#
  title = 'ROSSER1'
  m = 8
  n = 8
  a = rosser1 ( )
  x = rosser1_null_left ( )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  ZERO
#
  title = 'ZERO'
  m = 5
  n = 5
  a = zero ( m, n )
  x = zero_null_left ( m, n )
  error_l2 = r8mat_is_null_left ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( m, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  Terminate.
#
  print ''
  print 'TEST_NULL_LEFT:'
  print '  Normal end of execution.'

  return
def r8mat_is_eigen_right(n, k, a, x, lam):

    #*****************************************************************************80
    #
    ## R8MAT_IS_EIGEN_RIGHT determines the error in a right eigensystem.
    #
    #  Discussion:
    #
    #    An R8MAT is a matrix of real values.
    #
    #    This routine computes the Frobenius norm of
    #
    #      A * X - X * LAMBDA
    #
    #    where
    #
    #      A is an N by N matrix,
    #      X is an N by K matrix (each of K columns is an eigenvector)
    #      LAMBDA is a K by K diagonal matrix of eigenvalues.
    #
    #    This routine assumes that A, X and LAMBDA are all real.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    11 March 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    #  Parameters:
    #
    #    Input, integer N, the order of the matrix.
    #
    #    Input, integer K, the number of eigenvectors.
    #    K is usually 1 or N.
    #
    #    Input, real A(N,N), the matrix.
    #
    #    Input, real X(N,K), the K eigenvectors.
    #
    #    Input, real LAM(K), the K eigenvalues.
    #
    #    Output, real VALUE, the Frobenius norm
    #    of the difference matrix A * X - X * LAM, which would be exactly zero
    #    if X and LAM were exact eigenvectors and eigenvalues of A.
    #
    from r8mat_mm import r8mat_mm
    from r8mat_norm_fro import r8mat_norm_fro

    c = r8mat_mm(n, n, k, a, x)

    for j in range(0, k):
        for i in range(0, n):
            c[i, j] = c[i, j] - lam[j] * x[i, j]

    value = r8mat_norm_fro(n, k, c)

    return value
def test_null_right ( ):

#*****************************************************************************80
#
## TEST_NULL_RIGHT tests right null vectors.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    12 March 2015
#
#  Author:
#
#    John Burkardt
#
  from a123                 import a123
  from a123                 import a123_null_right
  from archimedes           import archimedes
  from archimedes           import archimedes_null_right
  from cheby_diff1          import cheby_diff1
  from cheby_diff1          import cheby_diff1_null_right
  from creation             import creation
  from creation             import creation_null_right
  from dif1                 import dif1
  from dif1                 import dif1_null_right
  from dif1cyclic           import dif1cyclic
  from dif1cyclic           import dif1cyclic_null_right
  from dif2cyclic           import dif2cyclic
  from dif2cyclic           import dif2cyclic_null_right
  from fibonacci1           import fibonacci1
  from fibonacci1           import fibonacci1_null_right
  from hamming              import hamming
  from hamming              import hamming_null_right
  from line_adj             import line_adj
  from line_adj             import line_adj_null_right
  from moler2               import moler2
  from moler2               import moler2_null_right
  from neumann              import neumann
  from neumann              import neumann_null_right
  from one                  import one
  from one                  import one_null_right
  from r8_uniform_ab        import r8_uniform_ab
  from r8mat_is_null_right  import r8mat_is_null_right
  from r8mat_norm_fro       import r8mat_norm_fro
  from r8vec_norm_l2        import r8vec_norm_l2
  from ring_adj             import ring_adj
  from ring_adj             import ring_adj_null_right
  from rosser1              import rosser1
  from rosser1              import rosser1_null_right
  from zero                 import zero
  from zero                 import zero_null_right

  print ''
  print 'TEST_NULL_RIGHT'
  print '  A = a test matrix of order M by N'
  print '  x = an N vector, candidate for a right null vector.'
  print ''
  print '  ||A|| = Frobenius norm of A.'
  print '  ||x|| = L2 norm of x.'
  print '  ||A*x||/||x|| = L2 norm of A*x over L2 norm of x.'
  print ''
  print '  Title                    M     N      ',
  print '||A||            ||x||        ||A*x||/||x||'
  print ''
#
#  A123
#
  title = 'A123'
  m = 3
  n = 3
  a = a123 ( )
  x = a123_null_right ( )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  ARCHIMEDES
#
  title = 'ARCHIMEDES'
  m = 7
  n = 8
  a = archimedes ( )
  x = archimedes_null_right ( )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  CHEBY_DIFF1
#
  title = 'CHEBY_DIFF1'
  m = 5
  n = m
  a = cheby_diff1 ( n )
  x = cheby_diff1_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  CREATION
#
  title = 'CREATION'
  m = 5
  n = m
  a = creation ( m, n )
  x = creation_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  DIF1
#  Only has null vectors for N odd.
#
  title = 'DIF1'
  m = 5
  n = m
  a = dif1 ( m, n )
  x = dif1_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  DIF1CYCLIC
#
  title = 'DIF1CYCLIC'
  m = 5
  n = m
  a = dif1cyclic ( n )
  x = dif1cyclic_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  DIF2CYCLIC
#
  title = 'DIF2CYCLIC'
  m = 5
  n = m
  a = dif2cyclic ( n )
  x = dif2cyclic_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  FIBONACCI1
#
  title = 'FIBONACCI1'
  m = 5
  n = m
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  f1, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  f2, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  a = fibonacci1 ( n, f1, f2 )
  x = fibonacci1_null_right ( m, n, f1, f2 )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  HAMMING
#
  title = 'HAMMING'
  m = 5
  n = ( 2 ** m ) - 1
  a = hamming ( m, n )
  x = hamming_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  LINE_ADJ
#
  title = 'LINE_ADJ'
  m = 7
  n = m
  a = line_adj ( n )
  x = line_adj_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  MOLER2
#
  title = 'MOLER2'
  m = 5
  n = 5
  a = moler2 ( )
  x = moler2_null_right ( )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  NEUMANN
#
  title = 'NEUMANN'
  row_num = 5
  col_num = 5
  m = row_num * col_num
  n = row_num * col_num
  a = neumann ( row_num, col_num )
  x = neumann_null_right ( row_num, col_num )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  ONE
#
  title = 'ONE'
  m = 5
  n = 5
  a = one ( m, n )
  x = one_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  RING_ADJ
#  N must be a multiple of 4 for there to be a null vector.
#
  title = 'RING_ADJ'
  m = 12
  n = 12
  a = ring_adj ( m, n )
  x = ring_adj_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  ROSSER1
#
  title = 'ROSSER1'
  m = 8
  n = 8
  a = rosser1 ( )
  x = rosser1_null_right ( )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  ZERO
#
  title = 'ZERO'
  m = 5
  n = 5
  a = zero ( m, n )
  x = zero_null_right ( m, n )
  error_l2 = r8mat_is_null_right ( m, n, a, x )
  norm_a_frobenius = r8mat_norm_fro ( m, n, a )
  norm_x_l2 = r8vec_norm_l2 ( n, x )
  print '  %-20s  %4d  %4d  %14g  %14g  %10.2g' \
    % ( title, m, n, norm_a_frobenius, norm_x_l2, error_l2 )
#
#  Terminate.
#
  print ''
  print 'TEST_NULL_RIGHT:'
  print '  Normal end of execution.'

  return