def i4mat_data_read_test ( ): #*****************************************************************************80 # ## I4MAT_DATA_READ_TEST tests I4MAT_DATA_READ. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 October 2014 # # Author: # # John Burkardt # from i4mat_print import i4mat_print print '' print 'I4MAT_DATA_READ_TEST:' print ' Test I4MAT_DATA_READ, which reads data from an I4MAT.' m = 5 n = 3 filename = 'i4mat_write_test.txt' a = i4mat_data_read ( filename, m, n ) i4mat_print ( m, n, a, ' Data read from file:' ) return
def i4mat_indicator_test ( ): #*****************************************************************************80 # ## I4MAT_INDICATOR_TEST tests I4MAT_INDICATOR. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 03 December 2014 # # Author: # # John Burkardt # from i4mat_print import i4mat_print print '' print 'I4MAT_INDICATOR_TEST' print ' I4MAT_INDICATOR creates an "indicator" I4MAT.' m = 5 n = 4 a = i4mat_indicator ( m, n ) i4mat_print ( m, n, a, ' The indicator matrix:' ) print '' print 'I4MAT_INDICATOR_TEST' print ' Normal end of execution.' return
def i4mat_data_read_test(): #*****************************************************************************80 # ## I4MAT_DATA_READ_TEST tests I4MAT_DATA_READ. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 October 2014 # # Author: # # John Burkardt # from i4mat_print import i4mat_print print '' print 'I4MAT_DATA_READ_TEST:' print ' Test I4MAT_DATA_READ, which reads data from an I4MAT.' m = 5 n = 3 filename = 'i4mat_write_test.txt' a = i4mat_data_read(filename, m, n) i4mat_print(m, n, a, ' Data read from file:') return
def pord_check_test ( ): #*****************************************************************************80 # ## PORD_CHECK_TEST tests PORD_CHECK. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 30 May 2015 # # Author: # # John Burkardt # import numpy as np from i4mat_print import i4mat_print n = 10 a = np.array ( [ \ [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], \ [ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 ], \ [ 1, 0, 1, 1, 0, 0, 0, 0, 0, 0 ], \ [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], \ [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ], \ [ 0, 0, 0, 1, 0, 1, 0, 1, 0, 0 ], \ [ 1, 0, 1, 1, 0, 1, 1, 1, 0, 1 ], \ [ 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 ], \ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], \ [ 1, 0, 1, 1, 0, 0, 0, 1, 0, 1 ] ] ) print '' print 'PORD_CHECK_TEST' print ' PORD_CHECK checks a partial ordering.' i4mat_print ( n, n, a, ' The partial ordering matrix:' ) ierror = pord_check ( n, a ) print '' print ' CHECK FLAG = %d' % ( ierror ) print ' 0 means no error.' print ' 1 means illegal value of N.' print ' 2 means some A(I,J) and A(J,I) are both nonzero.' # # Terminate. # print '' print 'PORD_CHECK_TEST:' print ' Normal end of execution.' return
def pord_check_test(): #*****************************************************************************80 # ## PORD_CHECK_TEST tests PORD_CHECK. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 30 May 2015 # # Author: # # John Burkardt # import numpy as np from i4mat_print import i4mat_print n = 10 a = np.array ( [ \ [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], \ [ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 ], \ [ 1, 0, 1, 1, 0, 0, 0, 0, 0, 0 ], \ [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], \ [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ], \ [ 0, 0, 0, 1, 0, 1, 0, 1, 0, 0 ], \ [ 1, 0, 1, 1, 0, 1, 1, 1, 0, 1 ], \ [ 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 ], \ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], \ [ 1, 0, 1, 1, 0, 0, 0, 1, 0, 1 ] ] ) print '' print 'PORD_CHECK_TEST' print ' PORD_CHECK checks a partial ordering.' i4mat_print(n, n, a, ' The partial ordering matrix:') ierror = pord_check(n, a) print '' print ' CHECK FLAG = %d' % (ierror) print ' 0 means no error.' print ' 1 means illegal value of N.' print ' 2 means some A(I,J) and A(J,I) are both nonzero.' # # Terminate. # print '' print 'PORD_CHECK_TEST:' print ' Normal end of execution.' return
def sphere_llt_grid_lines_test ( ): #*****************************************************************************80 # ## SPHERE_LLT_GRID_LINES_TEST tests SPHERE_LLT_GRID_LINES. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 21 May 2015 # # Author: # # John Burkardt # from i4mat_print import i4mat_print from sphere_llt_grid_line_count import sphere_llt_grid_line_count lat_num = 3 long_num = 4 print '' print 'SPHERE_LLT_GRID_LINES_TEST' print ' SPHERE_LLT_GRID_LINES computes grid lines' print ' on a sphere in 3D.' print '' print ' Number of latitudes is %d' % ( lat_num ) print ' Number of longitudes is %d' % ( long_num ) line_num = sphere_llt_grid_line_count ( lat_num, long_num ) print '' print ' Number of line segments is %d' % ( line_num ) line = sphere_llt_grid_lines ( lat_num, long_num, line_num ) i4mat_print ( line_num, 2, line, ' Grid line vertices:' ) # # Terminate. # print '' print 'SPHERE_LLT_GRID_LINES_TEST:' print ' Normal end of execution.' return
def i4mat_min_test(): #*****************************************************************************80 # ## I4MAT_MIN_TEST tests I4MAT_MIN. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 18 October 2014 # # Author: # # John Burkardt # from i4mat_print import i4mat_print from i4mat_uniform_ab import i4mat_uniform_ab print '' print 'I4MAT_MIN_TEST' print ' For an I4MAT:' print ' I4MAT_MIN returns the minimum entry.' m = 5 n = 7 a = 0 b = 10 seed = 123456789 x, seed = i4mat_uniform_ab(m, n, a, b, seed) i4mat_print(m, n, x, ' The matrix:') x_min = i4mat_min(m, n, x) print '' print ' Minimum entry = %d' % (x_min) # # Terminate. # print '' print 'I4MAT_MIN_TEST' print ' Normal_end of execution.' return
def i4mat_min_test ( ): #*****************************************************************************80 # ## I4MAT_MIN_TEST tests I4MAT_MIN. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 18 October 2014 # # Author: # # John Burkardt # from i4mat_print import i4mat_print from i4mat_uniform_ab import i4mat_uniform_ab print '' print 'I4MAT_MIN_TEST' print ' For an I4MAT:' print ' I4MAT_MIN returns the minimum entry.' m = 5 n = 7 a = 0 b = 10 seed = 123456789 x, seed = i4mat_uniform_ab ( m, n, a, b, seed ) i4mat_print ( m, n, x, ' The matrix:' ) x_min = i4mat_min ( m, n, x ) print '' print ' Minimum entry = %d' % ( x_min ) # # Terminate. # print '' print 'I4MAT_MIN_TEST' print ' Normal_end of execution.' return
def i4mat_uniform_ab_test(): #*****************************************************************************80 # ## I4MAT_UNIFORM_AB_TEST tests I4MAT_UNIFORM_AB. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 31 October 2014 # # Author: # # John Burkardt # from i4mat_print import i4mat_print import numpy as np m = 5 n = 4 a = -1 b = +5 seed = 123456789 print '' print 'I4MAT_UNIFORM_AB_TEST' print ' I4MAT_UNIFORM_AB computes a random R8MAT.' print '' print ' %d <= X <= %d' % (a, b) print ' Initial seed is %d' % (seed) v, seed = i4mat_uniform_ab(m, n, a, b, seed) i4mat_print(m, n, v, ' Random I4MAT:') # # Terminate. # print '' print 'I4MAT_UNIFORM_AB_TEST:' print ' Normal end of execution.' return
def i4mat_uniform_ab_test ( ): #*****************************************************************************80 # ## I4MAT_UNIFORM_AB_TEST tests I4MAT_UNIFORM_AB. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 31 October 2014 # # Author: # # John Burkardt # from i4mat_print import i4mat_print import numpy as np m = 5 n = 4 a = -1 b = +5 seed = 123456789 print '' print 'I4MAT_UNIFORM_AB_TEST' print ' I4MAT_UNIFORM_AB computes a random R8MAT.' print '' print ' %d <= X <= %d' % ( a, b ) print ' Initial seed is %d' % ( seed ) v, seed = i4mat_uniform_ab ( m, n, a, b, seed ) i4mat_print ( m, n, v, ' Random I4MAT:' ) # # Terminate. # print '' print 'I4MAT_UNIFORM_AB_TEST:' print ' Normal end of execution.' return
def stirling2_test(): #*****************************************************************************80 # ## STIRLING2_TEST tests STIRLING2. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 26 February 2015 # # Author: # # John Burkardt # import numpy as np import platform from i4mat_print import i4mat_print print('') print('STIRLING2_TEST:') print(' Python version: %s' % (platform.python_version())) print( ' Test STIRLING2, which returns Stirling numbers of the second kind.') m = 8 n = 8 s2 = stirling2(m, n) i4mat_print(m, n, s2, ' Stirling2 matrix:') # # Terminate. # print('') print('STIRLING2_TEST:') print(' Normal end of execution.') return
def stirling1_test ( ): #*****************************************************************************80 # ## STIRLING1_TEST tests STIRLING1. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 26 February 2015 # # Author: # # John Burkardt # import numpy as np from i4mat_print import i4mat_print print '' print 'STIRLING1_TEST:' print ' Test STIRLING1, which returns Stirling numbers of the first kind.' m = 8 n = 8 s1 = stirling1 ( m, n ) i4mat_print ( m, n, s1, ' Stirling1 matrix:' ) print '' print 'STIRLING1_TEST:' print ' Normal end of execution.' return
def stirling2_test ( ): #*****************************************************************************80 # ## STIRLING2_TEST tests STIRLING2. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 26 February 2015 # # Author: # # John Burkardt # import numpy as np from i4mat_print import i4mat_print print '' print 'STIRLING2_TEST:' print ' Test STIRLING2, which returns Stirling numbers of the second kind.' m = 8 n = 8 s2 = stirling2 ( m, n ) i4mat_print ( m, n, s2, ' Stirling2 matrix:' ) print '' print 'STIRLING2_TEST:' print ' Normal end of execution.' return
def i4mat_u1_inverse_test ( ): #*****************************************************************************80 # ## I4MAT_U1_INVERSE_TEST tests I4MAT_U1_INVERSE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 25 May 2015 # # Author: # # John Burkardt # import numpy as np from i4mat_mm import i4mat_mm from i4mat_print import i4mat_print n = 6 # # Each row of this definition is a COLUMN of the matrix. # a = np.array ( [ [ 1, 2, 0, 5, 0, 75 ], \ [ 0, 1, 0, 0, 0, 0 ], \ [ 0, 0, 1, 3, 0, 0 ], \ [ 0, 0, 0, 1, 0, 6 ], \ [ 0, 0, 0, 0, 1, 4 ], \ [ 0, 0, 0, 0, 0, 1 ] ] ) print '' print 'I4MAT_U1_INVERSE_TEST' print ' I4MAT_U1_INVERSE inverts a unit upper triangular matrix.' i4mat_print ( n, n, a, ' The original matrix:' ) b = i4mat_u1_inverse ( n, a ) i4mat_print ( n, n, b, ' The inverse matrix:' ) c = i4mat_mm ( n, n, n, a, b ) i4mat_print ( n, n, c, ' The product:' ) # # Terminate. # print '' print 'I4MAT_U1_INVERSE_TEST:' print ' Normal end of execution.' return
def i4mat_u1_inverse_test(): #*****************************************************************************80 # ## I4MAT_U1_INVERSE_TEST tests I4MAT_U1_INVERSE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 25 May 2015 # # Author: # # John Burkardt # import numpy as np from i4mat_mm import i4mat_mm from i4mat_print import i4mat_print n = 6 # # Each row of this definition is a COLUMN of the matrix. # a = np.array ( [ [ 1, 2, 0, 5, 0, 75 ], \ [ 0, 1, 0, 0, 0, 0 ], \ [ 0, 0, 1, 3, 0, 0 ], \ [ 0, 0, 0, 1, 0, 6 ], \ [ 0, 0, 0, 0, 1, 4 ], \ [ 0, 0, 0, 0, 0, 1 ] ] ) print '' print 'I4MAT_U1_INVERSE_TEST' print ' I4MAT_U1_INVERSE inverts a unit upper triangular matrix.' i4mat_print(n, n, a, ' The original matrix:') b = i4mat_u1_inverse(n, a) i4mat_print(n, n, b, ' The inverse matrix:') c = i4mat_mm(n, n, n, a, b) i4mat_print(n, n, c, ' The product:') # # Terminate. # print '' print 'I4MAT_U1_INVERSE_TEST:' print ' Normal end of execution.' return
def i4mat_mm_test(): #*****************************************************************************80 # ## I4MAT_MM_TEST tests I4MAT_MM. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 25 May 2015 # # Author: # # John Burkardt # import numpy as np from i4mat_print import i4mat_print n1 = 3 n2 = 2 n3 = 4 # # Each row of this definition is a COLUMN of the matrix. # a = np.array ( [ [ 11, 12 ], \ [ 21, 22 ], \ [ 31, 32 ] ] ) b = np.array ( [ [ 11, 12, 13, 14 ], \ [ 21, 22, 23, 24 ] ] ) print '' print 'I4MAT_MM_TEST' print ' I4MAT_MM multiplies two I4MAT\'s' i4mat_print(n1, n2, a, ' Matrix A:') i4mat_print(n2, n3, b, ' Matrix B:') c = i4mat_mm(n1, n2, n3, a, b) i4mat_print(n1, n3, c, ' C = A*B:') # # Terminate. # print '' print 'I4MAT_MM_TEST:' print ' Normal end of execution.' return