Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How python Implements Matrix Operation
How python Implements Matrix Operation
Import and use of 1.numpy

Data 1=mat (zero ((

)))

# Create a 3*3 null matrix, where the parameter of null function is tuple type (3,3).

data 2 = mat(one((

)))

# Create a 2*4 1 matrix. By default, it is floating-point data. If necessary, you can use dtype=int.

data3=mat(random.rand(

))

# The random module here uses the random module in numpy. Random. rand (2,2) creates a two-dimensional array, which needs to be converted into #matrix.

data4=mat(random.randint(

10

, size = (

)))

# Generate a random integer matrix of 3*3 between 0- 10. If you need to specify a lower bound, you can add an additional parameter.

data5=mat(random.randint(

, size = (

))

# Generate a random integer matrix between 2 and 8.

data6=mat(eye(

, data type =

Internationalorganizations (same as international organizations)

))

# Generate a 2*2 diagonal matrix

a 1=[

]; A2=mat (diagnosis (a 1))

# Generate diagonal matrix with diagonal 1, 2, 3.