How to reset the elements of a 3x3 matrix without any memory allocation?

Some of those allocations are you allocating an input array to write into A, some of those came from running @time in the global scope, and some came from A[:] .= B making a view that did an allocating reshape of the matrix A to a vector (though the allocation is small because the underlying buffer of values is reused). There was a thread yesterday pointing out this allocating reshape happening for views of matrices. vec(A) does reshape(A, length(A)) so that does the small allocations too.

1 Like