From a2eb47d50831451d874ad04a6d81e2a315fd3234 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Wed, 26 Jun 2013 16:31:31 +0200 Subject: [PATCH] [src] Vorkond verbessert [src] Zeitmessung optimiert --- src/A_plots.m | 19 +++++++++++-------- src/compute.m | 46 ++++++++++++++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/A_plots.m b/src/A_plots.m index 66278ca..57022e1 100644 --- a/src/A_plots.m +++ b/src/A_plots.m @@ -31,7 +31,7 @@ leg3 = {}; leg4 = {}; sym = {}; -rows = 13; +rows = 14; for i = 1:length(files) @@ -98,7 +98,8 @@ for i = 1:length(files) ['cond ' l0 l1{i}]... }'; leg4 = {leg4{:}... - ['Zeit ' l0 l1{i}]... + ['Zeit aufbauen ' l0 l1{i}]... + ['Zeit loesen ' l0 l1{i}]... }'; sym = {sym{:} type2sym(data(1,[2+(i-1)*rows]))}'; end @@ -304,14 +305,16 @@ print('-r600','-depsc',[printt '_cond.eps']) %% Plotte Zeit figure(8) i=0; -loglog(repmat(X(:,i+1),1,1),[... - G_D(:,2+11+rows*i)... - ],type2sym(i+1),'color', type2color(i+1,:)); +loglog(... + X(:,i+1),G_D(:,2+11+rows*i),type2sym(i*3+1),... + X(:,i+1),G_D(:,2+12+rows*i),type2sym(i*3+2),... + 'color', type2color(i+1,:)); hold on for i = 1:step-1 -loglog(repmat(X(:,i+1),1,1),[... - G_D(:,2+11+rows*i)... - ],type2sym(i+1),'color', type2color(i+1,:)); +loglog(... + X(:,i+1),G_D(:,2+11+rows*i),type2sym(i*3+1),... + X(:,i+1),G_D(:,2+12+rows*i),type2sym(i*3+2),... + 'color', type2color(i+1,:)); end % loglog(X(:,1),[7*X(:,1).^(-1/2),3*X(:,1).^(-1/4),2*X(:,1).^(-3/4)],'-.') hold off diff --git a/src/compute.m b/src/compute.m index 8cae628..b0455b4 100644 --- a/src/compute.m +++ b/src/compute.m @@ -26,6 +26,8 @@ end kap3 = 0; +tic + %times mal verfeinern oder bis Elementanzahl fuer times > 40 for j = 1:times %beende Schleife wenn Elementanzahl erreicht @@ -84,18 +86,25 @@ for j = 1:times if(~vcon) %Loesung berechnen x_fine = V_fine\b_fine; - con = cond(V_fine); + else %Vorkonditionierte Loesung! - D = diag(diag(V_fine.^(-1/2))); - - A = D * V_fine * D; - c = D*b_fine; - y = A\c; - x_fine = D*y; - con = cond(A); + D = diag(V_fine).^(-1/2); + for k = 1:length(V_fine) + for l = 1:length(V_fine) + V_fine(k,l) = V_fine(k,l)*D(k)*D(l); + end + end + c = D.*b_fine; + y = V_fine\c; + x_fine = D.*y; end + solve_time = toc; + + %Konditionszahl aufstellen + con = cond(V_fine); + clear V_fine % \tilde \mu ( \Rho h -h + L_2 ) @@ -108,12 +117,15 @@ for j = 1:times if(~vcon) x = V\b; else - D = diag(diag(V.^(-1/2))); - - A = D * V * D; - c = D*b; - y = A\c; - x = D*y; + D = diag(V).^(-1/2); + for k = 1:length(V) + for l = 1:length(V) + V(k,l) = V(k,l)*D(k)*D(l); + end + end + c = D.*b; + y = V\c; + x = D.*y; end clear V @@ -172,7 +184,8 @@ for j = 1:times end_time = toc - start_time; disp(['Relative Zeit ' num2str(100*(build_time - start_time)/end_time)... '% absolute Zeit ' t2str(build_time - start_time)]); - end_time = build_time - start_time; + time_build = build_time - start_time; + time_sovle = solve_time - build_time; dataS = [dataS ... typ(i) ... berechnet mit Typ @@ -187,7 +200,8 @@ for j = 1:times sqrt(sum(tmu2))... tilde mu 2 xe_fine... (kappa) kap3 ... kappa 3 - end_time ... benoetigte Zeit (Aufbauen, Berechnen) + time_build ... benoetigte Zeit (Aufbauen) + time_solve ... benoetigte Zeit (Berechnen) ]; end -- 2.47.3