线性代数中两个向量相乘
Prerequisite: Linear Algebra | Defining a Vector
In the python code, we will add two vectors. We can add two vectors only and only if the both the vectors are in the same dimensional space. For our code, we consider the vectors in 4-dimensional space.
在python代码中,我们将添加两个向量。 仅当两个向量都在同一维空间中时,我们才可以添加两个向量。 对于我们的代码,我们考虑4维空间中的向量。
Python代码添加两个向量 (Python code to add two vectors)
#Vectors in Linear Algebra
a = [3, 5, -5, 8]
b = [4, 7, 9, -4]
print("Vector a = ", a)
print("Vector b = ", b)
# This is a 4 dimensional vector
# a list in python is a vector in linear algebra
# adding vectors
sum = []
for i in range(len(a)):
sum.append(a[i] + b[i])
print("Vector Addition = ", sum)
# This is how we can print a vector in python
Output
输出量
Vector a = [3, 5, -5, 8]
Vector b = [4, 7, 9, -4]
Vector Addition = [7, 12, 4, 4]
翻译自: https://www.includehelp.com/python/adding-two-vectors.aspx
线性代数中两个向量相乘
本文介绍了线性代数中4维向量的加法运算,通过Python代码演示了两个4维向量相加的过程。文章强调了向量加法的前提条件——两个向量必须处于同一维空间中。
2828

被折叠的 条评论
为什么被折叠?



