]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make PCG solver a bit faster by not initializing memory that will be
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 9 Apr 1999 14:44:26 +0000 (14:44 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 9 Apr 1999 14:44:26 +0000 (14:44 +0000)
overwritten soon anyway.

git-svn-id: https://svn.dealii.org/trunk@1114 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/solver_cg.h
deal.II/lac/include/lac/solver_gmres.h

index e7e8cf6b60669b242116f1d24bde6249e23eb2b2..5cd18d96412888a4905e3a7319fd715b2dba09a4 100644 (file)
@@ -83,11 +83,22 @@ SolverPCG<Matrix,Vector>::solve (const Matrix &A,
   SolverControl::State conv=SolverControl::iterate;
   
                                   // Memory allocation
-  Vr  = memory.alloc(); Vector& g  = *Vr; g.reinit(x);
-  Vp  = memory.alloc(); Vector& h  = *Vp; h.reinit(x);
-  Vz  = memory.alloc(); Vector& d  = *Vz; d.reinit(x);
-  VAp = memory.alloc(); Vector& Ad = *VAp; Ad.reinit(x);
-
+  Vr  = memory.alloc();
+  Vp  = memory.alloc();
+  Vz  = memory.alloc();
+  VAp = memory.alloc();
+                                  // define some aliases for simpler access
+  Vector& g  = *Vr; 
+  Vector& h  = *Vp; 
+  Vector& d  = *Vz; 
+  Vector& Ad = *VAp;
+                                  // resize the vectors, but do not set
+                                  // the values since they'd be overwritten
+                                  // soon anyway.
+  g.reinit(x.size(), true);
+  h.reinit(x.size(), true);
+  d.reinit(x.size(), true);
+  Ad.reinit(x.size(), true);
                                   // Implementation taken from the DEAL
                                   // library
   int  it=0;
index 1f2536164c81b62cce42a7fc2a5b81b317b8ecdc..c5a7ad833d534c31b19e42e332685461831142a0 100644 (file)
@@ -146,12 +146,14 @@ SolverGMRES<Matrix,Vector>::solve (const Matrix& A,
 
                                   // allocate an array of n_tmp_vectors
                                   // temporary vectors from the VectorMemory
-                                  // object
+                                  // object; resize them but do not set their
+                                  // values since they will be overwritten soon
+                                  // anyway.
   vector<Vector*> tmp_vectors (n_tmp_vectors, 0);
   for (unsigned int tmp=0; tmp<n_tmp_vectors; ++tmp)
     {
       tmp_vectors[tmp] = memory.alloc();
-      tmp_vectors[tmp]->reinit (x.size());
+      tmp_vectors[tmp]->reinit (x.size(), true);
     };
 
                                   // number of the present iteration; this

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.