Fast way for matrix multiplication in Python -
does know fast way compute matrices such as:
z{i,j} = \sum_{p,k,l,q} \frac{a_{ip} b_{pk} c_{kl} d_{lq} e_{qj} }{a_p - b_q - c}
for normal matrix multiplication use numpy.dot(a,b),
got divide elements $a_p$
, $b_q$
.
any suggestions?
any suggestions on how compute
$$ c_{i,j} = \sum _p = \frac{e_{i,p} b_{p,j}}{m_p} $$
will of great well.
note (e[i, p] * b[p, j]) / m[p]
equal e[i, p] * (b[p, j] / m[p])
, can divide m
b
before calling np.dot
.
def f(e, b, m): b = np.asarray(b) # matrix m = np.asarray(m).reshape((b.shape[0], 1)) # row vector return np.dot(e, b / m) # m broadcasted match b
Comments
Post a Comment