Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Mathematical Operation method of NumPy Array

Shulou Source: shulou.com Published: 2022-06-02 04:43:34 10月03日 Update

This article mainly explains "the mathematical operation of NumPy array". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the mathematical operation of NumPy array.

Background introduction

Today, we learn to use numpy's built-in mathematical operation method and the basic arithmetic operator to learn the mathematical operation of the array, which involves the basic operation knowledge of the vector matrix of linear algebra (unfamiliar children's shoes will repair it later). Let's start with:

Getting started exampl

The following is the execution process in Jupyter Notebook:

The code is as follows:

# using the numpy array for mathematical operations import numpy as npx = np.array ([[1pjue 2], [3pr 4]]) y = np.array ([[5pc6], [7pc8]]) # addition # using the operator array addition x + y # using the np.add () method to add z = np.add (x) z # subtraction x-ynp.subtract (x Y) # multiplication operation x * ynp.multiply (XMague y) # Division operation x / ynp.divide (XMague y) # take the square root np.sqrt (x) v = np.array ([9LJ 10]) w = np.array ([11LJ 13]) # use np.dot () for matrix operation # his function returns the dot product of two arrays. For a two-dimensional vector, it is equivalent to matrix multiplication. # for 1Mel D array, it is the inner product of the vector. For an N-dimensional array, it is the product of the last axis of an and the penultimate axis of b. V.dot (w) # is equivalent to (9: 11) + (10: 13) np.dot (vMagne w) np.dot (XMague y) # the array transposed xx.Tnp.sum (x) # 1+3+2+4np.sum (xmeme axisym0) # line phase plus result np.sum (xPoweraxishui 1) # column to add the result, I believe you have a deeper understanding of the "mathematical operation method of NumPy array", might as well come to the actual operation! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Operations arrays mathematics methods learning content vectors matrices multiplication results operators practical deeper next two algebra interest inner product subtraction function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS Docker Shulou Tech Info Microsoft