Path: news.mathworks.com!not-for-mail From: "ghasem " <shaban_sadeghi@yahoo.com> Newsgroups: comp.soft-sys.matlab Subject: Re: how solve a tridiagonal equation system when we are in three dimensional space? Date: Sun, 14 Apr 2013 11:35:08 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 65 Message-ID: <kke49c$gbr$1@newscl01ah.mathworks.com> References: <kkbdpr$63p$1@newscl01ah.mathworks.com> <kkbh4o$ei2$1@newscl01ah.mathworks.com> <kkbj2k$j6o$1@newscl01ah.mathworks.com> <kkbkl7$n87$1@newscl01ah.mathworks.com> <kkbnbg$he$1@newscl01ah.mathworks.com> <kkboh0$3ep$1@newscl01ah.mathworks.com> <kkbrvs$c6m$1@newscl01ah.mathworks.com> <kkbvi0$l32$1@newscl01ah.mathworks.com> <kkc3hg$1uc$1@newscl01ah.mathworks.com> <kkdi7s$166$1@newscl01ah.mathworks.com> <kkdo1j$flu$1@newscl01ah.mathworks.com> <kkdtfs$stp$1@newscl01ah.mathworks.com> <kkdudr$1t2$1@newscl01ah.mathworks.com> Reply-To: "ghasem " <shaban_sadeghi@yahoo.com> NNTP-Posting-Host: www-01-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1365939308 16763 172.30.248.46 (14 Apr 2013 11:35:08 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sun, 14 Apr 2013 11:35:08 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 4223132 Xref: news.mathworks.com comp.soft-sys.matlab:793495 > Why you should do it repeatly? > > >> A = rand(50,70,200); > >>tic; B = permute(A,[2 1 3]); B = reshape(B, 70, []); toc > Elapsed time is 0.007224 seconds. > > It's 60000 faster than 8 minutes. A peanut in the ocean. > > Please post the small example running code when asking the question. I can't afford to constantly guess what exactly _you_ do. > > Bruno ================================== sorry Bruno,you are right.I write small example fro my code: first step: I calculate: aq(i,j,k),bq(i,j,k),cq(i,j,k), that q=u,v,w,x,y,z and i=1:50,j=1:70,k=1:110. second step: preallocate U,V,W,X,Y,Z =>ie : = zeros(50,70,110) third step: I have a time loop that within this loop,I have to solve Ax=b for U,V,W,X,Y,Z unknowns. and also,RHS of this six systems of Ax=b,are depend on new values of two other unknowns. ============================== i.e,one section from my code is as following: for time =1:10000 % for X: fx(1:nx,2:ny,2:nz) = coeff1* (W(1:nx,2:ny,2:nz) - W (1:nx,1:ny-1,2:nz))... +coeff2* (V(1:nx,2:ny,2:nz) - V (1:nx,2:ny,1:nz-1)); fx2 = permute(fx ,[2,1,3]); fx3 = reshape(fx2,[ny+1,nx*(nz+1)]); for k=1:nxnze Ax2 = sparse(i(:), j(:), Ax(:,k), ny+1, ny+1); X1(:,k) = Ax2 \ fX3(:,k); end X3 = reshape(X2,[ny+1,nx,(nz+1)]); X = permute(X3,[2 1 3]); ============================== this was Ax=f for X unknown. now,suppose I have five other tridiagonal system. forth step: % now after Ax=f for x =U,V,W,X,Y,Z , I have to calculate smaller section,aslo. % for example,for X,I have to calculate as following,again: fx4(:,1:10,:) = coeff3*(U(:,2:11,:) - U(:,1:10,:)); fx5 = permute(fx4 ,[2,1,3]); fx6 = reshape(fx5 ,[10 ,nx*(nz+1)]); for k=1:nxnze Ax4 = sparse(ii(:), jj(:) , Ax3(:,k) ,10 ,10); X4 (:,k) = A_ex4 \ fx6(:,k); end X5 = reshape(X4 ,[10 , nx , (nz+1)]); X6 = permute(X5 ,[2 1 3]); % X(:, 2:11 ,:) = X(: , 2:11 ,:) + X6 ; end % related to for time=... % NOW suppose I have same procedure for U,V,W,Y,Z.and all of these calculations are within for-loop of time.So,I want to use from best method for Ax=f.such that my program to be fast. what is your idea that my program to be fast? Mr,Bruno,can I have your email?I want to tell you that what is my purpose. best regard... ghasem...