線性代數向量乘法
Prerequisite: Linear Algebra | Defining a Vector
先決條件: 線性代數| 定義向量
Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a matrix in n-dimensional space with only one column. In linear algebra, there are two types of multiplication:
線性代數是使用向量空間和矩陣的線性方程組的數學分支。 換句話說,向量是n維空間中只有一列的矩陣。 在線性代數中,有兩種類型的乘法:
Scalar Multiplication
標量乘法
Cross Multiplication
交叉乘法
In a scalar product, each component of the vector is multiplied by the same a scalar value. As a result, the vector’s length is increased by scalar value.?
在標量積中,向量的每個分量都乘以相同的標量值。 結果,向量的長度增加了標量值。
For example: Let a vector a = [4, 9, 7], this is a 3 dimensional vector (x,y and z)
例如:令向量a = [4、9、7],這是3維向量(x,y和z)
So, a scalar product will be given as?b = c*a
因此,標量積將給出為b = c * a
Where c is a constant scalar value (from the set of all real numbers R). The length vector b is c times the length of vector a.
其中c是常數標量值(來自所有實數R的集合)。 長度矢量b是向量a的長度c倍。
向量標量乘法的Python代碼 (Python code for Scalar Multiplication of Vector)
# Vectors in Linear Algebra Sequnce (5)
# Scalar Multiplication of Vector
def scalar(c, a):
b = []
for i in range(len(a)):
b.append(c*a[i])
return b
a = [3, 5, -5, 8] # This is a 4 dimensional vector
print("Vector a = ", a)
c = int(input("Enter the value of scalar multiplier: "))
# The vector b will have the same dimensions
# but the overall magnitute is c times a
print("Vector (b = c*a) = ", scalar(c, a))
Output
輸出量
Vector a = [3, 5, -5, 8]
Enter the value of scalar multiplier: 3
Vector (b = c*a) = [9, 15, -15, 24]
翻譯自: https://www.includehelp.com/python/scalar-multiplication-of-vector.aspx
線性代數向量乘法