python 向量二范数_向量的范数| 使用Python的线性代数

python 向量二范数

Prerequisite:

先决条件:

  • Defining Vector using Numpy

    使用Numpy定义向量

Here, we are going to learn how to find the norm of a vector using an inbuilt function in numpy library?

在这里,我们将学习如何使用numpy库中的内置函数找到向量的范数?

向量范数的Python代码 (Python code for norm of the vector)

# Linear Algebra Learning Sequence
# Outer Product Property I

import numpy as np

a = np.array([2, 4, 8, 7, 7, 9, -6])
b = np.array([2, 3, 1, 7, 8])

#outer product in both order
ma = np.linalg.norm(a)
mb = np.linalg.norm(b)

print('A : ', a)
print('B : ', b)
print('\n\nNorm of A : ', ma)
print('\n\nNorm of B : ', mb)

Output:

输出:

A :  [ 2  4  8  7  7  9 -6]
B :  [2 3 1 7 8]


Norm of A :  17.291616465790582


Norm of B :  11.269427669584644


翻译自: https://www.includehelp.com/python/norm-of-the-vector.aspx

python 向量二范数

你可能感兴趣的:(python 向量二范数_向量的范数| 使用Python的线性代数)