added trace_sum for efficiency

This commit is contained in:
James Hensman 2013-03-11 18:56:37 +00:00
parent 129bb3924e
commit cb082898d3
2 changed files with 10 additions and 3 deletions

View file

@ -14,6 +14,13 @@ import types
#import scipy.lib.lapack.flapack
import scipy as sp
def trace_dot(a,b):
"""
efficiently compute the trace of the matrix product of a and b
"""
assert a.shape==b.T.shape
return np.dot(a.flatten(),b.T.flatten())
def mdot(*args):
"""Multiply all the arguments using matrix product rules.
The output is equivalent to multiplying the arguments one by one