]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Have another scale function that scales each element individually.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 23 Apr 2001 23:16:10 +0000 (23:16 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 23 Apr 2001 23:16:10 +0000 (23:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@4473 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/2001/c-3-1.html
deal.II/lac/include/lac/vector.h
deal.II/lac/include/lac/vector.templates.h

index 169aeb6aa5233b237219bb8068bce24b865dd198..89b4301971e607a2616056a481fe7c8d9173d7bb 100644 (file)
@@ -234,8 +234,17 @@ documentation, etc</a>.
 <h3>lac</h3>
 
 <ol>
+  <li> <p>
+       New: There is now a function <code
+       class="member">Vector::scale(Vector)</code>
+       that scales each element of the vector by the corresponding
+       element of the argument.
+       <br>
+       (WB 2001/04/23)
+       </p>
+
   <li> <p> Changed: Solver functions <code class="member">solve</code>
-       are void now. If the solver has not converged within the
+       return void now. If the solver has not converged within the
        maximum number of iterations or encounters a breakdown, it
        throws an exception of type <code
        class="class">SolverControl::NoConvergence</code> instead of
index 723648035f34a546c1fe53b9983ae266ba0f3986..424702455ba1e7780e8918937a9024d722b847cc 100644 (file)
@@ -364,11 +364,22 @@ class Vector
               const Number c, const Vector<Number>& X);
     
                                     /**
-                                     * Scale each element of the vector by the
-                                     * given factor.
+                                     * Scale each element of the
+                                     * vector by the given factor.
                                      */
 //TODO:[?] Why not have an operator *= instead of/in addition to `scale'?    
     void scale (const Number factor);
+
+                                    /**
+                                     * Scale each element of this
+                                     * vector by the corresponding
+                                     * element in the argument. This
+                                     * function is mostly meant to
+                                     * simulate multiplication (and
+                                     * immediate re-assignment) by a
+                                     * diagonal scaling matrix.
+                                     */
+    void scale (const Vector<Number> &scaling_factors);
     
                                     /**
                                      *  U=a*V. Replacing.
index bb45b600b09c08f320ad23614a4e5e2e8d91bacf..d6442e10aeaff464771e006ffb0314f318dff2b3 100644 (file)
@@ -452,17 +452,35 @@ void Vector<Number>::sadd (const Number x, const Number a,
 }
 
 
+
 template <typename Number>
 void Vector<Number>::scale (const Number factor)
 {
   Assert (dim!=0, ExcEmptyVector());
 
-  iterator ptr=begin(), eptr=end();
+  iterator             ptr  = begin();
+  const const_iterator eptr = end();
   while (ptr!=eptr)
     *ptr++ *= factor;
 }
 
 
+
+template <typename Number>
+void Vector<Number>::scale (const Vector<Number> &s)
+{
+  Assert (dim!=0, ExcEmptyVector());
+  Assert (dim == s.dim, ExcDimensionMismatch(dim, s.dim));
+  
+  iterator             ptr  = begin();
+  const_iterator       sptr = s.begin();
+  const const_iterator eptr = end();
+  while (ptr!=eptr)
+    *ptr++ *= *sptr++;
+}
+
+
+
 template <typename Number>
 void Vector<Number>::equ (const Number a, const Vector<Number>& u,
                          const Number b, const Vector<Number>& v)

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.