线性代数中两个向量相乘_加两个向量| Python的线性代数

线性代数中两个向量相乘

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

线性代数中两个向量相乘

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值