Starting diary file "diary-2016-03-09.txt" on Wed Mar 09 2016 12:29 PM. Dcoeff = .01; k = 100; dt = .01; t_end = 3.0; U = mydiffusion(Dcoeff, @S, @B, @U0, k, dt, t_end, 1); Hit space to begin simulation. tic; U = mydiffusion(Dcoeff, @S, @B, @U0, k, dt, t_end, 0); toc Elapsed time is 11.861771 seconds. edit mydiffusion edit bslashtx edit mydiffusion % use chol() and do triangular solves inside the loop U = mydiffusion2(Dcoeff, @S, @B, @U0, k, dt, t_end, 1); Hit space to begin simulation. % I left out the part where it was still slow because % we were transposing R inside the loop every time! tic; U = mydiffusion2(Dcoeff, @S, @B, @U0, k, dt, t_end, 0); toc Elapsed time is 3.725698 seconds. profile clear profile on tic; U = mydiffusion2(Dcoeff, @S, @B, @U0, k, dt, t_end, 0); toc Elapsed time is 5.505217 seconds. profile viewer clear clc load choleskyexample whos Name Size Bytes Class Attributes A 5x5 200 double p 1x5 40 double A A = 4 -1 0 0 -1 -1 4 -1 -1 0 0 -1 4 -1 0 0 -1 -1 4 0 -1 0 0 0 4 nnz(A) ans = 15 R = chol(A) R = 2.0000 -0.5000 0 0 -0.5000 0 1.9365 -0.5164 -0.5164 -0.1291 0 0 1.9322 -0.6556 -0.0345 0 0 0 1.8176 -0.0491 0 0 0 0 1.9313 nnz(R) ans = 13 p p = 5 1 2 3 4 AA = A(p,p) AA = 4 -1 0 0 0 -1 4 -1 0 0 0 -1 4 -1 -1 0 0 -1 4 -1 0 0 -1 -1 4 nnz(AA) ans = 15 RR = chol(AA) RR = 2.0000 -0.5000 0 0 0 0 1.9365 -0.5164 0 0 0 0 1.9322 -0.5175 -0.5175 0 0 0 1.9319 -0.6563 0 0 0 0 1.8170 R R = 2.0000 -0.5000 0 0 -0.5000 0 1.9365 -0.5164 -0.5164 -0.1291 0 0 1.9322 -0.6556 -0.0345 0 0 0 1.8176 -0.0491 0 0 0 0 1.9313 A2 = laplacian2d_sparse2(100); whos Name Size Bytes Class Attributes A 5x5 200 double A2 10000x10000 873608 double sparse AA 5x5 200 double R 5x5 200 double RR 5x5 200 double ans 1x1 8 double p 1x5 40 double spy(A2) nnz(A2) ans = 49600 R = chol(A2); spy(R) nnz(R) ans = 1000099 help amd AMD Approximate minimum degree permutation. P = AMD(A) returns the approximate minimum degree permutation vector ... p = amd(A2); size(p) ans = 1 10000 p p = ... AA = A2(p,p); nnz(AA) ans = 49600 nnz(A2) ans = 49600 spy(AA),shg RR = chol(AA); nnz(RR) ans = 206332 nnz(AA) ans = 49600 spy(RR),shg figure,spy(AA),shg clc % now edit mydiffusion to incorporate the amd() permutation Dcoeff = .01; k = 100; dt = .01; t_end = 3.0; U = mydiffusion(Dcoeff, @S, @B, @U0, k, dt, t_end, 1); Hit space to begin simulation. tic; U = mydiffusion(Dcoeff, @S, @B, @U0, k, dt, t_end, 0); toc Elapsed time is 1.170288 seconds. diary off