Say I have a matrix like this:
matrix1 = [[11,12,13,14,15,16,17],[21,22,23,24,25,26,27],[31,32,33,34,35,36,37], [41,42,43,44,45,46,47],[51,52,53,54,55,56,57],[61,62,63,64,65,66,67], [71,72,73,74,75,76,77]]
and I want to make a function that will take in two matrices and do point multiplication. (not using numpy)
I saw some things when using zip, but this does not seem to work for me. I think this is because my list consists of lists, not one list.
My code is:
def pointwise_product(a_matrix, a_second_matrix): # return m[i][j] = a_matrix[i][j] x a_second_matrix[i][j] return [i*j for i,j in zip(a_matrix,a_second_matrix)]
As both arguments, Matrix1 can be connected. the second function, called display_matrix, will take this function and display each list item in new lines, but this is beyond the scope of this question.
I assume that I will need some sort of lists or lambda functions, but I'm just too new to python to fully understand them.