On Tue, Dec 24, 2013 at 5:17 PM, Eric Martin <[email protected]>wrote:

> Also, its (marginally but consistently) faster in Julia to just call
> "copy(T)" rather than "full(Tridiagonal(map(i -> diag(T, i), -1:1)...))",
> which seems odd to me because "copy" should be O(N^2) and the other method
> (only copying the sub, main, and super diagonals) is O(N), where N is the
> dimension of a square matrix.


Both do work proportional to the number of elements in the matrix, which is
O(N^2). The copy is a *lot* simpler, however. All it does is a memcpy,
which is not much slower than just filling the matrix with zeros:

julia> A = randn(10000,10000);

julia> @time copy(A);
elapsed time: 0.432631311 seconds (800450296 bytes allocated)

julia> @time zeros(10000,10000);
elapsed time: 0.365747207 seconds (800000128 bytes allocated)

Reply via email to