tag:blogger.com,1999:blog-24082283.post7032078399765575663..comments2024-02-07T05:26:45.500-05:00Comments on Yu-Sung Su's Blog: Smart programming saves computing timesYu-Sung Suhttp://www.blogger.com/profile/16723440380040533242noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-24082283.post-22416977717328826582008-06-24T03:10:00.000-04:002008-06-24T03:10:00.000-04:00Interesting! Thanks for the input! Indeed, it is ...Interesting! <BR/><BR/>Thanks for the input! Indeed, it is faster!Yu-Sung Suhttps://www.blogger.com/profile/16723440380040533242noreply@blogger.comtag:blogger.com,1999:blog-24082283.post-57177213372251792462008-06-24T01:56:00.000-04:002008-06-24T01:56:00.000-04:00Usex.mat z.mat will reduce 2 matrix computation.sh...Use<BR/>x.mat <- matrix(x, ncol=n, nrow=n)<BR/>z.mat <- matrix(z, ncol=n, nrow=n)<BR/>will reduce 2 matrix computation.<BR/>should be more quick.<BR/>result:<BR/>> x <- rnorm(5000)<BR/>> y <- rnorm(5000)<BR/>> system.time(testch(x,y))<BR/> user system elapsed <BR/> 5.34 0.83 6.22 <BR/>> system.time(test2(x,y))<BR/> user system elapsed <BR/> 5.07 1.18 16.64 <BR/><BR/><BR/>spolihttps://www.blogger.com/profile/17091235299700375750noreply@blogger.comtag:blogger.com,1999:blog-24082283.post-75752124759492957162008-06-22T10:47:00.000-04:002008-06-22T10:47:00.000-04:00Thanks. Corrected!Thanks. Corrected!Yu-Sung Suhttps://www.blogger.com/profile/16723440380040533242noreply@blogger.comtag:blogger.com,1999:blog-24082283.post-49474146374325807392008-06-22T10:43:00.000-04:002008-06-22T10:43:00.000-04:00mat x.mat z.mat x.mat z.mat D.matmat <- matrix(1, n, n)<BR/>x.mat <- x * mat<BR/>z.mat <- x * mat # z here<BR/>x.mat <- x.mat - t(x.mat)<BR/>z.mat <- z.mat - t(x.mat) # z.mat here<BR/>D.mat <- x.mat^2/z.mat^2Anonymousnoreply@blogger.com