Linked by snydeq on Mon 25th Oct 2010 21:23 UTC
Permalink for comment 447252
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
Features
Linked by Thom Holwerda on 05/21/13 21:38 UTC
Linked by Thom Holwerda on 05/20/13 11:29 UTC
Linked by Thom Holwerda on 05/18/13 21:33 UTC
Linked by David Adams on 05/16/13 4:23 UTC
Linked by Thom Holwerda on 05/11/13 21:41 UTC
Linked by Thom Holwerda on 05/08/13 14:22 UTC
Linked by Thom Holwerda on 05/02/13 15:28 UTC
Linked by Thom Holwerda on 04/29/13 21:06 UTC
Linked by Thom Holwerda on 04/24/13 22:24 UTC
Linked by Thom Holwerda on 04/18/13 11:21 UTC
More Features »
Sponsored Links



Member since:
2006-01-19
A = rand(5); % Create a random 5x5 matrix.
B = A * A.'; % Multiply by its transpose.
C = sum(B, 2); % Sum rows.
D = (A * diag(C)).^2 % Multiply each column by the row sum, then square each element.
from numpy import *
from numpy.random import *
a = random_integers(1,10,(5,5))
b = dot(a, a.transpose())
c = b.sum(axis=0)
d = square(dot(a, diag(c)))
OK, so 4 lines, plus 2 imports.
Note to prospective hecklers - I learned numpy 15 minutes ago and haven't thought about linear algebra in years. I am sure there is a better way to do this.