Here is a simple finite-difference example: Seemingly unnecessary allocation within for loop - #8 by stevengj
You can find lots of more sophisticated implementations by searching.
Here is a simple finite-difference example: Seemingly unnecessary allocation within for loop - #8 by stevengj
You can find lots of more sophisticated implementations by searching.