techascent / tech.ml.dataset

A Clojure high performance data processing system
Eclipse Public License 1.0
680 stars 35 forks source link

do we have dot product ? #359

Closed usametov closed 1 year ago

usametov commented 1 year ago

Hi, you mentioned once in one of the releases that this lib has an implementation of dot-product for vectors and matrices. But I could not find it in documentation . Could you, please, add index for that? Sorry for bothering.

usametov commented 1 year ago

OK, I found it. It is here: https://github.com/cnuernber/dtype-next/blob/5e81b0d32ad2f47479a698a244805b5f1abc06f8/src/tech/v3/datatype/functional/vecopt.clj#L48

harold commented 1 year ago

Indeed!

> (tech.v3.datatype.functional/dot-product [1 2 3] [4 5 6])
32.0
harold commented 1 year ago

Also, without the lib (in Clojure):

> (reduce + (map * [1 2 3] [4 5 6]))
32

This, of course, behaves differently in terms of types and performance, but may also be useful in some cases.