Created
October 27, 2017 11:41
-
-
Save csgillespie/441e087da6498a0ac81a465995d298a1 to your computer and use it in GitHub Desktop.
Revisions
-
csgillespie created this gist
Oct 27, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ ##R version 3.4.2 (2017-09-28) ##Platform: x86_64-pc-linux-gnu (64-bit) ##Running under: Ubuntu 16.04.3 LTS bm_prog_toeplitz = function() { N = 3000 ans = rep(0, N*N) dim(ans) = c(N, N) system.time({ for (j in 1:N) { for (k in 1:N) { ans[k,j] = abs(j - k) + 1 } } } ) } ## Takes around 7 seconds bm_prog_toeplitz() ## Around 2 seconds N = 3000 ans = rep(0, N*N) dim(ans) = c(N, N) system.time({ for (j in 1:N) { for (k in 1:N) { ans[k,j] = abs(j - k) + 1 } } })