Created
September 7, 2010 19:08
-
-
Save certik/568879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import zeros, dot, diag, tensordot | |
from numpy.random import random | |
n = 6 | |
m = 4 | |
b = random((n, m)) | |
d = random((m, m)) | |
bdb = zeros(n, 'd') | |
for i in xrange(n): | |
bdb[i] = dot(b[i,:], dot(d, b[i, :])) | |
print bdb | |
bd = dot(b, d) | |
bdb = diag(dot(bd, b.T)) | |
print bdb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment