I have written a python program that takes in numbers from a text file and generates two matrices. The size of these matrices are very large.
For example, matrix 1 is 5 * X and matrix 2 is X * 5 where X is a random number between 0 and 160
I have tried the following to multiply the matrices and used smaller numbers to verify the multiplication:
result = np.dot(matrix1,matrix2)
result = matrix1.dot(matrix2)
result = np.multiply(matrix1, matrix2[:, None])
These three ways do work when the dimensions of both matrixes are equal to each other. So, a 5 * 5 matrix multiplied by a 5 * 5 matrix will work. My code throws and error when it tries to multiply matrixes who's dimensions are not equal to each other. For example a 5 * 4 matrix multiplied by a 3 * 5 matrix will throw an error that always points to one of the three methods I have shown above
How am I able to multiply two matrixes of different dimensions?
m x n
followed byn x k
.5 x 4
followed by3 x 5
does not meet that condition. – Quang Hoang