-
Notifications
You must be signed in to change notification settings - Fork 2
Vector Algebra
Sergey Duyunov edited this page Nov 2, 2019
·
1 revision
The value can be matrix, vector, or number.
If the value is matrix, then multiplication is possible only by row-matrix.
v = Vector[1, 2, 3]
m = Matrix[[4, 5, 6]]
v * m
# => Matrix[[4, 5, 6], [8, 10, 12], [12, 15, 18]]
If the value is a vector, then multiplication is possible only by a vector of length 1.
v1 = Vector[1, 2, 3]
v2 = Matrix[2]
v1 * v2
# => Vector[2, 4, 6]
If the value is a number, each element of the vector is multiplied by that number
v1 = Vector[1, 2, 3]
v1 * 2
# => Vector[2, 4, 6]
Vectors addition.
v1 = Vector[1, 2, 3]
v2 = vector[3, 2, 0]
v1 + v2
# => Vector[4, 4, 3]
Addition with assignment.
Vector subtraction.
Subtraction with assignment.