NumPy of the scientific calculation of Python

Source: Internet
Author: User

1.np.logspace (start,stop,num): a function representation means that geometric series num is generated between (Start,stop)

eg

 as npprint np.logspace (1,4,4)

The result is: [10.  100.1000. 10000.]

2. Np.fromstring (' admin ', dtype=np.int8): The function is to replace the string with the corresponding ASCII value

 as npprint np.fromstring ('admin', dtype= np.int8)

The result is: [97 100 109 105 110]

3. Customize your own data type:

Import NumPy as NP

Student = Np.dtype ({' names ': [' name ', ' age '], ' formats ': [' S32 ', ' I ']})
Print Student
Xiaoming = Np.array ([(' Gong ', ')], dtype=student)
Print Xiaoming
Print xiaoming[0][' name ']
Print xiaoming[0][' age ']

Results:

[(' Name ', ' S32 '), (' Age ', ' <i4 ')]
[(' Gong ', 12)]

Gong

12

4. Generate a one-dimensional array in a linear form:

 as npprint np.linspace (0,4,6)

Results: [0. 0.8 1.6 2.4 3.2 4. ]

5. Use Frompyfun for accelerated scientific calculations

 as npdef func (A, b):     return A += Np.linspace (1460.61  1) print  FX (x)

Results:

[1.6 2.2 2.8000000000000003 3.4 4.0 4.6]

6. Np.dot ([1,2],[2,3]) computes the inner product (matrix multiplication) of the matrix

Results: 8

7.np.inner (A, b) is the sum of the column vectors

8.np.outer (A, b) multiplies the row vectors.

NumPy of the scientific calculation of Python

Related Article

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.