#! /usr/bin/env python # def r8st_print ( m, n, nst, ist, jst, ast, title ): #*****************************************************************************80 # ## R8ST_PRINT prints an R8ST matrix. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 26 September 2018 # # Author: # # John Burkardt # # Parameters: # # Input, integer M, the number of rows. # # Input, integer N, the number of columns. # # Input, integer NST, the number of nonzeros. # # Input, integer IST(NST), JST(NST), the row and column indices. # # Input, real AST(NST), the nonzero values. # # Input, string TITLE, a title. # print ( '' ) print ( title ) print ( ' %d rows by %d columns' % ( m, n ) ) print ( '' ); for k in range ( 0, nst ): print ( ' %8d %8d %8d %16.8f' % ( k, ist[k], jst[k], ast[k] ) ) return def r8st_print_test ( ): #*****************************************************************************80 # ## R8ST_PRINT_TEST tests R8ST_PRINT. # # 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: # # 26 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_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' R8ST_PRINT print an R8ST matrix.' ) r8st_print ( m, n, nst, ist, jst, ast, ' R8ST Matrix data:' ) # # Terminate. # print ( '' ) print ( 'R8ST_PRINT_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8st_print_test ( ) timestamp ( )