# Matrix performance

**URL:** <https://discourse.julialang.org/t/matrix-performance/5527>\
**Category:** General Usage\
**Tags:** performance\
**Created:** [August 23, 2017, 2:45pm UTC](https://discourse.julialang.org/t/matrix-performance/5527 "2017-08-23T14:45:09Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 23, 2017, 5:49pm UTC](https://discourse.julialang.org/t/matrix-performance/5527/22 "2017-08-23T17:49:33Z")

</div>

As a general comment on your code, you want to loop with the innermost index in the tightest loop since Julia arrays are column major.

---

<div class="post-metadata">

**Author:** ![bdeonovic](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdeonovic/32/3928_2.png) [@bdeonovic](https://discourse.julialang.org/u/bdeonovic)\
**Post date:** [August 23, 2017, 5:50pm UTC](https://discourse.julialang.org/t/matrix-performance/5527/23 "2017-08-23T17:50:05Z")

</div>

Yeah I was trying to debug before optimizing. Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 23, 2017, 5:50pm UTC](https://discourse.julialang.org/t/matrix-performance/5527/24 "2017-08-23T17:50:58Z")

</div>

Well, your original question was about performance.

---

<div class="post-metadata">

**Author:** ![bdeonovic](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdeonovic/32/3928_2.png) [@bdeonovic](https://discourse.julialang.org/u/bdeonovic)\
**Post date:** [August 23, 2017, 5:52pm UTC](https://discourse.julialang.org/t/matrix-performance/5527/25 "2017-08-23T17:52:05Z")

</div>

I was trying to debug differences between using matrix notation and for-loop notation and first thing I was confused about was the timing difference and then later discovered they weren’t even giving same results.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 23, 2017, 6:26pm UTC](https://discourse.julialang.org/t/matrix-performance/5527/26 "2017-08-23T18:26:06Z")

</div>

> [@bdeonovic](#):
>
> so static meaning the size of array is assumed to not change?

Static in the sense that the array size is known at compile-time, not at runtime, allowing the compiler to specialize the code for the array length (e.g. completely unrolling small loops).

[Previous page](https://discourse.julialang.org/t/matrix-performance/5527.md?page=1)
