operations, and two arrays of the same shape, at this time any arithmetic operation will be applied to the element levelData1 = Np.arange (1, 6)Data2 = Np.ones (5). Astype (Np.int32)Print (' \ndata1: '),Print (DATA1)Print (' data2: '),Print (DATA2)Print (' data1 * data2: '),Print (DATA1 * data2)Print (' Data1 + data2: '),Print (data1 + data2)# 3, array and array operations, and the shape of the two array is not the same, when the NumPy broadcast (broadcast) mechanism is enabled# HTTP://BAIJIAHA
described below. The first is the index:#-*-encoding:utf-8-*-import NumPy as Npimport pandas as Pdimport Matplotlib.pyplot as Pltfrom pandas import Series,dataf Rame#series has a reindex function that can rearrange the index so that the order of elements changes obj = Series ([1,2,3,4],index=[' A ', ' B ', ' C ', ' d ']) #注意这里的reindex并不改变obj的值, Get a "copy" #fill_value is obviously filled with the value of the empty index #print obj.reindex ([' A ', ' C ', ' d ', ' B ', ' e '],fill_value = 0) #
with a radius of 1 and the center is (0, 0,
0). Then, we set glortho (-1.5, 1.5,-1.5, 1.5,-10,
10); indicates that the entire sphere is installed in a frame with a width and height of 3. If you set glortho (0.0, 1.5,-1.5, 1.5,-10,
10); indicates to use a frame with a width of 1.5 and a height of 3 to bring in the right of the entire sphere. If glortho (0.0, 1.5, 0.0, 1.5,-10,
10); indicates that the upper right corner of the sphere is installed in a frame with a width and height of 1.5. The pre
storage space in the BLOB has been requested * @pa RAM Top * The allocated but unshaped output blobs of the to is shaped by reshape * @param the top-level data, blob objects to construct but the storage empty No application, * specific space size to be based on bottom blob size and LAYER_PARAM_ common decision, specific in the reshape function reality * * Checks that number of bottom and top B
LOBs is c
glortho. Suppose there is a sphere with a radius of 1 and the center is (0, 0, 0). Then, we set glortho (-1.5, 1.5,-1.5, 1.5,-10, 10); indicates that the entire sphere is installed in a frame with a width and height of 3. If glortho (0.0, 1.5,-1.5, 1.5,-10, 10) is set, a frame with a width of 1.5 and a height of 3 is used to bring in the right of the entire sphere; if glortho (0.0, 1.5, 0.0, 1.5,-10, 10) is set, the upper right corner of the sphere is installed in a frame with a width and heigh
terms of height and width. For example: if we use the GLUT library to create a form: Glutinitwindowsize (500, 500); Then use Glutreshapefunc (reshape); The reshape code is as follows:void reshape (int width, int height){Glviewport (0, 0, (Glsizei) width, (glsizei) height);Glmatrixmodel (gl_projection);Glloadidentity ();Glortho (-1.5, 1.5,-1.5, 1.5,-10, 10);....}
screen in terms of height and width.For example: if we use the GLUT library to create a form: Glutinitwindowsize (500, 500); Then use Glutreshapefunc (reshape); The reshape code is as follows:void reshape (int width, int height){Glviewport (0, 0, (Glsizei) width, (glsizei) height);Glmatrixmodel (gl_projection);Glloadidentity ();Glortho (-1.5, 1.5,-1.5, 1.5,-10,
a layer drop, you will soon be able to know what the device is. However, the function is not limited to the layer where the device is located. For example, there is a ping on the vro, and Ping is an Application Layer Program. Can you say that the router is a layer-7 device? This is not the case. These are only auxiliary functions, and the main functions are concentrated on three layers. The main function of a layer-1 device is to enlarge and shaping signals. We can think that the device is just
scene are displayed to the screen in terms of height and width.For example: if we use the GLUT library to create a form: Glutinitwindowsize (500, 500), then use Glutreshapefunc (reshape); The reshape code is as follows:void reshape (int width, int height){Glviewport (0, 0, (Glsizei) width, (glsizei) height);Glmatrixmodel (gl_projection);Glloadidentity ();Glortho
)Nchannels: number of channels in the matrix (number of channels in the matrix: 1, 2, 4)J: column number (which column do you want to access)C: Channel Number (the value of the channel you want to access)
The above method can also be used to access the matrix of a single channel, but the nchannels value is 1 and C = 0.
Reshape of the matrix The Reshape of a matrix is a conversion between the matrix channel
(stats04 (k, 1: COL), stats03 (k, 1: COL ));
Comp04 = [comp04; t];
EndConnection struct or CELL ARRAY
The operations for connecting to a struct array or cell are similar to those for operating a common matrix.
For example, generate a 3x8 struct matrix S, each of which has the following fields: X, Y, and Z. Connect the second structure array S2.
Generate a 3-by-8 structure matrix s:
For k = 1:24
S (K) = struct ('x', 10 * k, 'y', 10 * k + 1, 'z', 10 * k + 2 );
End
S =
freedom are adjustable (the default is N)
A.STD (), A.var ()
3.4991427521608776, 12.244
Min, max
Minimum value and maximum value
Argmin, Argmax
Indexes with minimum and maximum elements, respectively
A.argmin (), A.argmax ()
0, 4
Diff
Diff (A, n=1, axis=-1), the difference between the last and the previous one, the parameter n represents the N-round operation, the multidimensional array, which can be controlled by axis
(arr2.data) of the byte size of each element in the array) # buffer of the actual array element # NumPy comes with many data types, such as int16 and int32. np is available for values. int16 # NumPy is converted to print (np. int32 (12.123 ))
How to create an array:
Print ("------------ method for creating an array ------------") print (np. ones (2, 3, 4), dtype = np. int16) # print (np. empty (2, 3) # if it is an empty multi-digit group, only the memory is allocated and not initialized. Theref
;>>ImportNumPy as NP2>>> a = Np.matrix ([[1,2,3],[5,5,6],[7,9,9]])3>>> a**-1#inverse matrix of a4Matrix ([[-0.6, 0.6,-0.2 ],5[-0.2,-0.8, 0.6 ],6[0.66666667, 0.33333333,-0.33333333]])7>>> A * a**-1#The product of the inverse matrix of A and a, the result is the unit array8Matrix ([[[1.00000000e+00, 0.00000000e+00, 0.00000000e+00],9[4.44089210e-16, 1.00000000e+00, 4.44089210e-16],Ten[0.00000000e+00, -4.44089210e-16, 1.00000000e+00]])If you do not use a matrix object and you think of a
, 3, 4]])#In[98]:m.shape#out[98]: (1, 4)#and here is the two-dimensional array.#Note the difference between in[93] and in[96], more pair of brackets!! #N = a.shape[0] Number of rows for array A, H = o.shape[1] Number of columns for array O#In each of the following functions, both alpha and beta arrays are n*h two-dimensional arrays, that is, horizontal coordinates are time, portrait is statedefForwardalgo (a,b,pi,o): N= A.shape[0]#number of rows in array aM = a.shape[1]#number of columns in arra
IndexThe array index form in NumPy is consistent with Python. Such as:Np.arange (10)Print x[2] #单个元素, forward index from the go. Note that the subscript is starting from 0.Print X[-2] #从后往前索引. The subscript for the last element is-1Print X[2:5] #多个元素, left closed right open, default step value is 1Print x[:-7] #多个元素, from the back forward, developed the end position, using the default step valuePrint X[1:7:2] #指定步长值X.shape= (2,5) #x的shape属性被重新赋值, the requirement is that the number of elements is
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.