import sys import numpy as np import argparse # Arguments parser my_parser = argparse.ArgumentParser() my_parser.add_argument('-b', action='store', type=float, nargs='+', required=True, help='The vector b in rowmajor format: numbers separated by space') my_parser.add_argument('-A', action='store', type=float, nargs='+', required=True, help='The matrix A in rowmajor format: numbers separated by space') args = my_parser.parse_args() # Extracting matrix A and vecor b from the input arguments A=np.array(args.A) b=np.array(args.b) # Checking the compatibility of size of A and b n=np.size(b) if np.size(A) != n*n: print('\n=====ERROR=====\n' 'Matrix A and vector b are not compatible in size.\n' '===============\n') exit() A=A.reshape((n,n)) print(A)