Suppose I want to compute the quadratic form x^T A y
, where x
and y
are NumPy vectors, and I have stored A
as a SciPy csc_matrix
for efficiency.
It seems that one way to perform the computation is
(x * A).dot(y)
since SciPy uses *
for matrix products, and NumPy uses .dot
instead.
While this approach gives me the correct answer, it seems rather counter-intuitive to me, and I wonder if there's a more readable/efficient approach?
x @ A @ y
. – Paul Panzer