diff --git a/PYTHON/Display/print_array.py b/PYTHON/Display/print_array.py index c3aa137..29c5e98 100644 --- a/PYTHON/Display/print_array.py +++ b/PYTHON/Display/print_array.py @@ -1,10 +1,17 @@ #========================================================================== -def print_array(a): +def print_array(*args): #-------------------------------------------------------------------------- + if len((args)) == 1: + a = args[0] + format = "%7.2f" + else: + a = args[0] + format = args[1] + print('Array ['+('%d' %a.shape[0])+']') rows = a.shape[0] for i in range(0,rows): - print('%15.8e ' %a[i]) + print(format %a[i]) return # end of function \ No newline at end of file diff --git a/PYTHON/Display/print_matrix.py b/PYTHON/Display/print_matrix.py index ebe1264..21803a5 100644 --- a/PYTHON/Display/print_matrix.py +++ b/PYTHON/Display/print_matrix.py @@ -1,17 +1,21 @@ #========================================================================== -def print_matrix(a): +def print_matrix(*args): #-------------------------------------------------------------------------- + if len((args)) == 1: + a = args[0] + format = "%7.2f" + else: + a = args[0] + format = args[1] + print('Matrix['+('%d' %a.shape[0])+']['+('%d' %a.shape[1])+']') rows = a.shape[0] cols = a.shape[1] for i in range(0,rows): for j in range(0,cols): - if a[i,j] == 0: - print(' . ', end='') - else: - print(('%7.2f' %a[i,j]), end='') + print((format %a[i,j]), end='') print('') print('')