# Optimising iterative solution of small system

**URL:** <https://discourse.julialang.org/t/optimising-iterative-solution-of-small-system/112885>\
**Category:** Performance\
**Tags:** linearalgebra\
**Created:** [April 12, 2024, 3:59pm UTC](https://discourse.julialang.org/t/optimising-iterative-solution-of-small-system/112885 "2024-04-12T15:59:48Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [April 12, 2024, 4:32pm UTC](https://discourse.julialang.org/t/optimising-iterative-solution-of-small-system/112885/4 "2024-04-12T16:32:05Z")

</div>

> [@alemelis](#):
>
> ```julia
> while norm(n.F)>1e-5
> n.U .+= n.J \ (-n.F)
> 
> ```

It looks like you aren’t updating `n.J` in this loop? If so, you can just compute its LU factorization once and re-use it.

Also, it seems like it would be a lot easier, and possibly faster, to use `SVector` and `SArray` rather than `MVector` and `MArray` in this code. Then you can ditch all the “in-place” operations, write in a more natural style, and it still won’t allocate.

---

_[View the full topic](https://discourse.julialang.org/t/optimising-iterative-solution-of-small-system/112885)._
