Evan, this is exactly where you should use I, i.e. m = m + λ*I
The reason is that eye(m) will first allocate a dense matrix of size(m,1)^2 elements. Then * will do size(m,1)^2 multiplications of lambda and allocate a new size(m,1)^2 matrix for the result. Finally, size(m,1)^2 additions will be computed for the elements in m and lambda*eye(m). In contrast λ*I will only make a single multiplication, store the result in a tiny stack allocated scalar and only add this to the diagonal of m, i.e. size(m,1) additions. On Mon, Aug 29, 2016 at 6:49 AM, Evan Fields <tarros...@gmail.com> wrote: > > > On Monday, August 29, 2016 at 9:39:19 AM UTC-4, Júlio Hoffimann wrote: >> >> I'd like to understand the existence of eye() in Julia, it is still not >> clear to me. Is it because one wants type stability when updating a matrix >> iteratively? Is this possibly a limitation from the design of the language? >> >> -Júlio >> > > I've used it for things like > m = m + lambda*eye(m) > > >