In my code, I have to multiply a matrix A (dimensions 3×3) to a vector b1 (dimensions 3×1), resulting in C. So C = A*b1. Now, I need to repeat this process n times keeping A fixed and updating b to a different (3×1) vector each time. This can be done using loops but I want to avoid it to save computational cost. Instead I want to do it as matrix and vector product. Any ideas?
In my code, I have to multiply a matrix A (dimensions 3×3) to a
Share
You need to build a matrix of
bvectors, eg fornequal to 4:Then:
provides the solution of size 3×4 in this case. If you want the solution in the form of a vector of length 3n by 1, then do:
Can we construct
bMatfor arbitrarynwithout a loop? That depends on what the form of all yourbvectors is. If you let me know in a comment, I can update the answer.