Basic Operations
Vector Equality
Let x∈Rn and y∈Rn with:
Then x=y, if and only if:
That is, the corresponding elements of x and y are equal.
Vector Addition
Vector addition x+y (sum of vectors) is defined by:
x+y=x0x1...xn−1+y0y1...yn−1=x0+y0x1+y1...xn−1+yn−1
In other words, the vectors are added element-wise, yielding a new vector of the same size.
Geometric Interpretation
In this interpretation, let x∈Rn and y∈Rn. These 2 vectors actually lie in a plane and if we view them in that plane, we can observe the result of doing x+y. If lay the vectors "heel to toe" , e.g. if we lay vector y 's heel (where y starts) to toe of x (where x ends), x+y can be given by going from heel of x to toe of y. Vice-versa is also true.
Another geometric interpretation is, if we lay y's heel to toe of x or we lay x's heel to toe of y, this would create a parallelogram. The result of x+yis given by the diagonal of the parallelogram. This is known as the parallelogram method.
Vector Scaling
Scaling a vector is same as stretching the vector. Let x∈Rn and α∈R. Then, vector scaling is given by:
Vector Subtraction
Let x∈Rn and y∈Rn. Then, vector subtraction can be given by:
Geometric Interpretation
Taking the negative of y means it points in the opposite direction. Now, we have two vectors x and −y that are heel to toe. x−y can be given by going from heel of x to toe of −y.
Same as for Vector Addition, the parallelogram method can be applied here as well. x−y is the other diagonal of the parallelogram.
Scaled Vector Addition
One of the most commonly encountered operations when implementing more complex linear algebra operations is the scaled vector addition, which (given x∈Rn and y∈Rn)computes to:
It is often referred to as the AXPY operation, which stands for alpha times x plus y. We emphasize that it is typically used in situations where the output vector overwrites the input vector y.
Counting Flops & Memops
Consider the following scaled vector addition:
Now, imagine all the data for this scaled vector addition starts by being stored in the main memory of a computer. Further, in order to compute, data must be brought into registers and there are only a few registers available.
Now, we know that the scaling factor 2 in the above example is going to be used many times. So, we store it in a register and keep it there during the entire computation. This costs us 1 memory operation (memops).
Further, for each pair of one element from x and one element from y, we need to read these elements and write the result back to y. That means 2 memops for reading, 1 more for writing.
Finally, for each pair of elements from x and y, we perform a multiplication and then an addition. That would be 2 floating point operations (flops).
Now, if the size of the vectors is n, then we would have to do 3n+1memops and 2n flops.
Vector Function
A vector (valued) function is a mathematical function of one or more scalars and/or vectors whose output is a vector.
For example,
Another example can be,
The AXPY and DOT operations are also examples of vector functions.
Vector Functions That Map a Vector to a Vector
We will now focus on vector functions as functions that map a vector to another vector:
For example,
Another example can be,
Do note the following:
f:Rn→Rm,λ∈Randx∈Rn, then f(λx)=λf(x)happens sometimes.
f:Rn→Rmandx,y∈Rn, then f(x+y)=f(x)+f(y) happens sometimes.
Matrix Product
For given matrices A and B, their product is given by:
Hadamard Product
Hadamard product is element-wise multiplication. Following equations provide details of how the this product operation is calculated for given matrices A and B:
Dot (Inner) Product
The dot (inner) product between two vectors a and b is given by:
Alternatively,
Cost
The cost of a dot product with vectors of size n is 2n memops and 2n flops.
Transpose
The transpose of a matrix A is given by:
Inverse
The following equation provides the deifnition of inverse of a matrix:
Not all square matrices have an inverse.
For such cases, and non-square matrices, "pseudoinverse" is defined.
Last updated
