public
Last active

  • Download Gist
test.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.