]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
scale functions with template argument and for BlockVector
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 25 Sep 2002 22:23:43 +0000 (22:23 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 25 Sep 2002 22:23:43 +0000 (22:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@6519 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_vector.h
deal.II/lac/include/lac/block_vector.templates.h
deal.II/lac/include/lac/vector.h
deal.II/lac/include/lac/vector.templates.h
deal.II/lac/source/block_vector.cc
deal.II/lac/source/vector.cc

index e05aac80366b64fdaebb5dd650b13c735762cc96..49224ee2e1a7a9389bfeeb77ef927fb9c69ed65b 100644 (file)
@@ -1106,6 +1106,14 @@ class BlockVector
                                      */
     BlockVector<Number> & operator *= (const Number factor);
 
+                                    /**
+                                     * Multiply each element of this
+                                     * vector by the corresponding
+                                     * element of @p{v}.
+                                     */
+    template<typename Number2>
+    void scale (const BlockVector<Number2>& v);
+    
                                     /**
                                      *  U=a*V. Assignment.
                                      */
index 930c93e33b828f7808a4e3d4079fd8a481be9cf2..48399e0419a95b56bdecdd9328beb12d69b643dd 100644 (file)
@@ -445,6 +445,21 @@ void BlockVector<Number>::scale (const Number factor)
 }
 
 
+
+template <typename Number>
+template <typename Number2>
+void BlockVector<Number>::scale (const BlockVector<Number2>& v)
+{
+  Assert (num_blocks == v.num_blocks,
+         ExcDimensionMismatch(num_blocks, v.num_blocks));
+  for (unsigned int i=0;i<num_blocks;++i)
+    {
+      components[i].scale(v.block(i));
+    }
+}
+
+
+
 template <typename Number>
 void BlockVector<Number>::equ (const Number a,
                               const BlockVector<Number>& v,
index f963a96aae54a061d0178025fe81eb48bf46f86b..98a813906fe64646e6169c26a8793d89c90425ed 100644 (file)
@@ -421,7 +421,8 @@ class Vector
                                      * immediate re-assignment) by a
                                      * diagonal scaling matrix.
                                      */
-    void scale (const Vector<Number> &scaling_factors);
+    template <typename Number2>
+    void scale (const Vector<Number2> &scaling_factors);
     
                                     /**
                                      *  U=a*V. Assignment.
index 685fc90e0c1cb342bae0c1561f120c1343bf4934..39a15fa6b008131d59dd8f7af04cd60a262af6b9 100644 (file)
@@ -454,14 +454,15 @@ void Vector<Number>::scale (const Number factor)
 
 
 template <typename Number>
-void Vector<Number>::scale (const Vector<Number> &s)
+template <typename Number2>
+void Vector<Number>::scale (const Vector<Number2> &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();
+  typename Vector<Number2>::const_iterator sptr = s.begin();
   while (ptr!=eptr)
     *ptr++ *= *sptr++;
 }
index 9af154837cd81ea44e921413dba0488de7dcd6cb..dff8748811e54e34cc30d13daface57fc887aeab 100644 (file)
@@ -25,6 +25,8 @@ template void BlockVector<double>::equ<double>(const double,
                                               const BlockVector<double>&);
 template void BlockVector<double>::equ<float>(const double,
                                              const BlockVector<float>&);
+template void BlockVector<double>::scale<double>(const BlockVector<double>&);
+template void BlockVector<double>::scale<float>(const BlockVector<float>&);
 
 template class BlockVector<float>;
 template BlockVector<float>& BlockVector<float>::DEAL_II_MEMBER_OP_TEMPLATE_INST operator=<double>(
@@ -37,6 +39,8 @@ template void BlockVector<float>::equ<double>(const float,
                                              const BlockVector<double>&);
 template void BlockVector<float>::equ<float>(const float,
                                             const BlockVector<float>&);
+template void BlockVector<float>::scale<double>(const BlockVector<double>&);
+template void BlockVector<float>::scale<float>(const BlockVector<float>&);
 
 namespace BlockVectorIterators
 {
index 0dfa53a884b96dfc1ce08fbe474236a7d323b896..2b945e8748cf9b5114b3ca785ae9d4a5dcc9c1e0 100644 (file)
@@ -23,6 +23,8 @@ template void Vector<double>::reinit<double>(const Vector<double>&, const bool);
 template void Vector<double>::reinit<float>(const Vector<float>&, const bool);
 template void Vector<double>::equ<double>(const double, const Vector<double>&);
 template void Vector<double>::equ<float>(const double, const Vector<float>&);
+template void Vector<double>::scale<double>(const Vector<double>&);
+template void Vector<double>::scale<float>(const Vector<float>&);
 
 template class Vector<float>;
 template Vector<float>& Vector<float>::DEAL_II_MEMBER_OP_TEMPLATE_INST operator=<double>(const Vector<double>&);
@@ -32,6 +34,8 @@ template void Vector<float>::reinit<double>(const Vector<double>&, const bool);
 template void Vector<float>::reinit<float>(const Vector<float>&, const bool);
 template void Vector<float>::equ<double>(const float, const Vector<double>&);
 template void Vector<float>::equ<float>(const float, const Vector<float>&);
+template void Vector<float>::scale<double>(const Vector<double>&);
+template void Vector<float>::scale<float>(const Vector<float>&);
 
 // see the .h file for why these functions are disabled.
 // template Vector<float>::Vector (const Vector<double>& 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.