#! /usr/bin/env python3 # def r8st_print_some ( row1, row2, col1, col2, nst, ist, jst, ast, title ): #*****************************************************************************80 # ## R8ST_PRINT_SOME prints some of an R8ST file. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 27 September 2018 # # Author: # # John Burkardt # # Parameters: # # Input, integer ROW1, ROW2, the first and last rows to print. # # Input, integer COL1, COL2, the first and last columns to print. # # Input, integer NST, the number of nonzeros. # # Input, integer IST(NST), COL(NST), the row and column indices. # # Input, real A(NST), the nonzero values. # # Input, string TITLE, a title. # print ( '' ) print ( title ) print ( '' ) for k in range ( 0, nst ): if ( row1 <= ist[k] and ist[k] <= row2 and col1 <= jst[k] and jst[k] <= col2 ): print ( ' %8d %8d %8d %16.8f' % ( k, ist[k], jst[k], ast[k] ) ) return def r8st_print_some_test ( ): #*****************************************************************************80 # ## R8ST_PRINT_SOME_TEST tests R8ST_PRINT_SOME. # # Discussion: # # The matrix is: # # 11 12 0 0 15 # 21 22 0 0 0 # 0 0 33 0 35 # 0 0 0 44 0 # 51 0 53 0 55 # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 27 September 2018 # # Author: # # John Burkardt # import numpy as np import platform m = 5 n = 5 nst = 11 ast = np.array ( [ 51.0, 12.0, 11.0, 33.0, 15.0, 53.0, 55.0, 22.0, 35.0, 44.0, 21.0 ] ) ist = np.array ( [ 5, 1, 1, 3, 1, 5, 5, 2, 3, 4, 2 ] ) jst = np.array ( [ 1, 2, 1, 3, 5, 3, 5, 2, 5, 4, 1 ] ) print ( '' ) print ( 'R8ST_PRINT_SOME_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' R8ST_PRINT_SOME prints some of an R8ST matrix.' ) row1 = 3 row2 = 4 col1 = 3 col2 = 5 r8st_print_some ( row1, row2, col1, col2, nst, ist, jst, ast, ' R8ST Matrix data:' ) # # Terminate. # print ( '' ) print ( 'R8ST_PRINT_SOME_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8st_print_some_test ( ) timestamp ( )