#! /usr/bin/python3 # =================================================================== # test numpy zeros, identity, and array matrix functions # =================================================================== import numpy as np print() print('====zeros================================') m1 = np.zeros((3,3)) print() print(m1) print(type(m1)) m1[0][0] = 1.0 m1[1][1] = 1.0 m1[2][2] = 1.0 print() print(m1) print(type(m1)) m2 = np.zeros((4,4)) print() print(m2) print(type(m2)) m2[0][0] = 1.0 m2[1][1] = 1.0 m2[2][2] = 1.0 m2[3][3] = 1.0 print() print(m2) print(type(m2)) print() print('====identity=============================') m3 = np.identity(3) print() print(m3) print(type(m3)) m4 = np.identity(4) print() print(m4) print(type(m4)) print() print('====np.array=============================') print('unnecessary operation, already ndarray') m5 = np.array(np.identity(4)) print() print(m5) print(type(m5))