fast element-wise product

106 views
Skip to first unread message

Iakov D.

unread,
Nov 29, 2016, 1:18:07 PM11/29/16
to gonum-dev
Hi,
Is there any routine in gonum (planned?) which allows fast element-wise multiplication of vectors?
Also known as Hadamard product.
It is implemented in GSL under name gsl_vector_mul and v?mul in Intel MKL.
Apparently code generated by golang is not vectorized and is rather slow.

Thanks,
Iakov

Vladimír Chalupecký

unread,
Dec 1, 2016, 8:32:44 AM12/1/16
to gonum-dev
Hi,

In mat64 there are
func (*Dense) MulElem(a, b Matrix)
func (*Dense) DivElem(a, b Matrix)
for element-wise multiplication and division of matrices, and there are
func (*Vector) MulElemVec(a, b *Vector)
func (*Vector) DivElemVec(a, b *Vector)
for the same operations on vectors.

MKL is fast but the Go compiler is steadily improving, so we face a shining future. We are trying to have the most frequently used operations in assembly on x86_64, there is a big PR on github waiting for review. We welcome any help.

Cheers,

Vladimir
Reply all
Reply to author
Forward
0 new messages