# file: lecture_04/rank.py # # revision history: # # 20230906 (JP): initial version # # This file contains an implementation of a method to compute the rank # of a matrix. # The input to this program is a text file containing a comma-separated # list of matrix values: # # python eg.py # #------------------------------------------------------------------------------ # import required system modules # import os import sys import numpy as np #------------------------------------------------------------------------------ # # main program # #------------------------------------------------------------------------------ # load a matrix from a file # mat = np.loadtxt(sys.argv[1], dtype='f', delimiter=',') print("matrix:") print(mat) # compute the rank # print("rank is %d" % (np.linalg.matrix_rank(mat))) # # end of file