Re: [Tutor] How to sum weighted matrices
Numpy apart, you can use lists and loops: >>> matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> matrix2 = [[3, 2, 1], [6, 5, 4], [9, 8, 7]] >>> result = [] >>> w = [1, 2] >>> for x in range(len(matrix)): row =
[Tutor] How to sum weighted matrices
Hello all, I am new to python and numpy. My question is how to sum up N weighted matrices. For example w=[1,2] (N=2 case) m1=[1 2 3, 3 4 5] m2=[3 4 5, 4 5 6] I want to get a matrix Y=w[1]*m1+w[2]*m2 by using a loop. My original problem is like this X=[1 2 3, 3 4 5, 4 5 6]