I have a matrix A and a tensor b of size (1,3) - so a vector of size 3.

I want to compute

C = b1 * A + b2 * A^2 + b3 * A^3 where ^n is the n-th power of A.

At the end, C should have the same shape as A. How can I do this efficiently?

I have a matrix A and a tensor b of size (1,3) - so a vector of size 3.

I want to compute

C = b1 * A + b2 * A^2 + b3 * A^3 where ^n is the n-th power of A.

At the end, C should have the same shape as A. How can I do this efficiently?

`C = b[:,0]* A + b[:,1]* A**2 + b[:,2]* A**3`