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 Iimport numpy as npa = np.array([2, 4, 8, 7, 7, 9, -6])b = np.array([2, 3, 1, 7, 8])#outer product in both orderma = np.linalg.norm(a)mb = np.linalg.norm(b)print('A : ', a)print('B : ', b)print('nnNorm of A : ', ma)print('nnNorm of B : ', mb)Output:
输出:
A : [ 2 4 8 7 7 9 -6]B : [2 3 1 7 8]Norm of A : 17.291616465790582Norm of B : 11.269427669584644翻译自: https://www.includehelp.com/python/norm-of-the-vector.aspx
python 向量二范数