# Dot product of 2D matrices

**URL:** <https://discourse.julialang.org/t/dot-product-of-2d-matrices/66147>\
**Category:** New to Julia\
**Tags:** linearalgebra\
**Created:** [August 10, 2021, 7:35pm UTC](https://discourse.julialang.org/t/dot-product-of-2d-matrices/66147 "2021-08-10T19:35:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 10, 2021, 7:41pm UTC](https://discourse.julialang.org/t/dot-product-of-2d-matrices/66147/2 "2021-08-10T19:41:52Z")

</div>

> [@jpmorr](#):
>
> dot(transpose(x), y)

Numpy incorrectly calls a bunch of things “dot”, in Julia, matrix multiplication is just `*`:

```julia
x' * y #or transpose(x) * y

```

notice you’re unlikely to get speed up for this because everyone is just calling OpenBLAS routine anyway.

> [@Why matrix multiplication is much slower than PyTorch](https://discourse.julialang.org/t/why-matrix-multiplication-is-much-slower-than-pytorch/63661/4):
>
> also, eh, pytorch default type is float32… In [8]: torch.set\_num\_threads(1) ...: A = torch.randn(1000, 1000, dtype=torch.float64) ...: B = torch.randn(1000, 1000, dtype=torch.float64) ...: %timeit -n 5 torch.matmul(A, B) 43.1 ms ± 810 µs per loop (mean ± std. dev. of 7 runs, 5 loops each) In [9]: torch.set\_num\_threads(1) ...: A = torch.randn(1000, 1000) ...: B = torch.randn(1000, 1000) ...: %timeit -n 5 torch.matmul(A, B) 22.1 ms ± 245 µs per loop (mean ± std. dev. of 7 runs,…

* * *

Also checkout the very fast einsum pkg Tullio.jl (still, not gonna be faster for dense CPU matrix, OpenBLAS is super optimized, partly by hand written architecture specific assembly)

---

_[View the full topic](https://discourse.julialang.org/t/dot-product-of-2d-matrices/66147)._
