Python small white matrices matrix Note (updating)

Source: Internet
Author: User

Matrix

#python学习之矩阵matrix 2018.4.18#-*-coding:utf-8-*-from numpy import *import numpy as Npimport Matha=np.matrix (' 1 2 7;3 4 8;5 6 9 ') #矩阵的换行必须使用分号隔开, the internal data must be in string form and the elements must be separated by a space between the print (Np.matrix ([[[] 1,2],[3,4])) M=np.asmatrix (a) #将输入的a解释为矩阵m, and modify a value in M m[0,0]=5b=np.array ([[[1,5],[3,2]]) #矩阵中的数据可以为数组对象print (a) print (b) print (m)
#复制矩阵n =m.copy () print (n) #检测一下m和n中所有对应元素是否相等, equal return true.# all requires all elements to be equal to any as long as there is an equal to c= (m==n). All () d= (m==n). any () print ( c) #行与列print (M.all (axis=0)) print (M.all (Axis=1)) #转化为float对象print (M.astype (float)) #返回从小到大排序后的矩阵每行的数的索引构成的矩阵print ( M.argsort ()) #<=12 returns a >=32 return 32print (M.clip (12,32)) #矩阵对象的属性 # Matrix. T transpose: Returns the Matrix's transpose matrix # Matrix. H Hermitian (conjugate) Transpose: Returns the conjugate element matrix of the complex matrix # Matrix. I inverse: Returns the inverse matrix of the matrix # Matrix. A Base array: Returns the matrix based on the array # Matrix object method: # All ([axis, out]): Determines whether all elements of the matrix are true along a given axis (not 0 is true) # any ([axis, out]): Determines whether the matrix element is true along the direction of the given axis, As long as one element is true. # Argmax ([axis, out]): Returns the index of the largest element (the position of the largest element) along the direction of the given axis. # argmin ([axis, out]): Returns the index of the smallest element (the position of the smallest element) along the direction of the given axis # argsort ([axis, kind , order]): Returns the sorted index matrix # Astype (dtype[, order, casting, Subok, copy]): The matrix data is copied and the data type is the specified data type # Byteswap (inplace) Swap the By TES of the array elements# choose (choices[, out, mode]): A new data matrix (indexed from choices given) # Clip (A_min, a_max[, out]): Returns a new moment based on the given index Array, the element larger than the given element is A_max, the smaller is a_min# compress (condition[, axis, out]): Returns the matrix that satisfies the condition # CONJ (): Returns the complex number of the conjugate complex # conjugate () : Returns the conjugate complex element of all complex numbers # copy ([order]): Copies a matrix and assigns it to another object, B=a.copy () # Cumprod ([axis, Dtype, out]): Returns the element accumulation matrix along the specified axis # cumsum ([axis, Dtype, out]): Returns the element accumulation along the specified axis and the matrix # diagonal ([Offset, axis1, Axis2]): Returns the data of the diagonal in The Matrix # dot (b[, out]): Two dot multiplication of matrices # dump (file): stores the matrix as specified Files can be pickle.loads () or numpy.loads () such as: A.dump (' D:\\a.txt ') # dumps (): The data of the matrix is dumped into a string. # Fill (value): Fills all elements in the matrix with the specified value# flatten ([order]): Transforms the matrix into a one-dimensional form, but still a matrix object # Geta (): Returns itself, but returns as Ndarray # getA1 () : Returns a flattened (one-dimensional) array (ndarray) # Geth (): Returns its own conjugate complex transpose matrix # Geti (): Returns the inverse matrix of itself # Gett (): Returns itself to the transpose matrix # max ([axis, out]): Returns the maximum value of the specified axis # mean ([ Axis, Dtype, out]): Returns its mean value in the direction of the given axis # min ([axis, out]): Returns the minimum value of the specified axis # nonzero (): Returns the index matrix of a non-0 element # prod ([axis, Dtype, out]): Returns the specified axis square type, The product of the matrix element. # PTP ([axis, out]): Returns the maximum value minus the minimum value for the specified axis direction. # put (indices, values[, mode]): Replace the value of the given index (indices) position of the matrix with the given value # ravel ([ Order]): Returns an array that is a one-dimensional array or a flat array # repeat (repeats[, axis]): Repeating the elements in the matrix, repeating the matrix elements in the specified axis direction, repeats the number of repetitions # reshape (shape[, order]) : Change the size of the matrix, such as: reshape ([2,3]) # resize (new_shape[, Refcheck]): Change the size of the data # round ([decimals, out]): Returns the matrix after the specified precision, the specified number of digits is rounded, and if 1, retains a decimal # searchsorted (v[, side, Sorter]): Search V in the matrix index position # sort ([axis, kind, order]): Sort matrices or Sort by axis # squeeze ([axis]): Remove the axis of length 1 # std ([axis, Dtype, out, Ddof]): Returns the standard deviation of the element along the direction of the specified axis. # sum ([axis, Dtype, out]) : Returns the sum of its elements in the direction of the specified axis # swapaxes (Axis1, AXIS2): Swaps data on two axes. # Take (indices[, axis, out, mode]): Extracts the data at the specified index location and returns it as a one-dimensional array or matrix ( Depends on axis) # tofile (fid[, Sep, format]): Writes data in the matrix to the file in binary # tolist (): Converts the matrix to a list form # tostring ([order]): Converts a matrix into a python string. # Trace ([Offset, axis1, Axis2, Dtype, out]): Returns the sum of the diagonal elements # Transpose (*axes): Returns the Matrix's transpose matrix without changing the original matrix # var ([axis, Dtype, out, Ddof]): Returns the variance of the matrix element in the direction of the specified axis # view ([Dtype, type]): Generates the same data, but the type is a matrix of the specified new type.

Python small white matrices matrix Note (updating)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.