]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement operator*= for vectors and block vectors.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 14 Aug 2001 09:08:25 +0000 (09:08 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 14 Aug 2001 09:08:25 +0000 (09:08 +0000)
git-svn-id: https://svn.dealii.org/trunk@4878 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_vector.h
deal.II/lac/include/lac/vector.h

index cf3742122d70899103702c87f6ae474bc933dff2..20c75c26cf8511971f6c57527006cd55c3f5e3c5 100644 (file)
@@ -441,6 +441,16 @@ class BlockVector
                                      */
     void scale (const Number factor);
     
+                                    /**
+                                     * Scale each element of the
+                                     * vector by a constant
+                                     * value. This operator is an
+                                     * alias to the @ref{scale}
+                                     * function, except that it
+                                     * returns a reference to itself.
+                                     */
+    BlockVector<Number> & operator *= (const Number factor);
+
                                     /**
                                      *  U=a*V. Replacing.
                                      */
@@ -605,6 +615,16 @@ Number& BlockVector<Number>::operator() (const unsigned int i)
 
 
 
+template <typename Number>
+inline
+BlockVector<Number> & BlockVector<Number>::operator *= (const Number factor) 
+{
+  scale (factor);
+  return *this;
+};
+
+
+
 template <typename Number>
 inline
 Vector<Number> &
index 60bd884573bd43d51d5c02e3b5382ad91ee4165e..7533548e7d3080a025e4ad091016a27210ec2845 100644 (file)
@@ -377,9 +377,18 @@ class Vector
                                      * 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 the
+                                     * vector by a constant
+                                     * value. This operator is an
+                                     * alias to the @ref{scale}
+                                     * function, except that it
+                                     * returns a reference to itself.
+                                     */
+    Vector<Number> & operator *= (const Number factor);
+    
                                     /**
                                      * Scale each element of this
                                      * vector by the corresponding
@@ -560,6 +569,7 @@ Vector<Number>::Vector (const unsigned int n) :
 }
 
 
+
 template <typename Number>
 inline
 Vector<Number>::~Vector ()
@@ -572,6 +582,7 @@ Vector<Number>::~Vector ()
 }
 
 
+
 template <typename Number>
 inline
 void Vector<Number>::reinit (const unsigned int n, const bool fast)
@@ -597,6 +608,7 @@ void Vector<Number>::reinit (const unsigned int n, const bool fast)
 }
 
 
+
 template <typename Number>
 inline
 void Vector<Number>::clear ()
@@ -606,6 +618,7 @@ void Vector<Number>::clear ()
 }
 
 
+
 template <typename Number>
 inline
 unsigned int Vector<Number>::size () const
@@ -614,6 +627,7 @@ unsigned int Vector<Number>::size () const
 }
 
 
+
 template <typename Number>
 inline
 typename Vector<Number>::iterator 
@@ -623,6 +637,7 @@ Vector<Number>::begin ()
 };
 
 
+
 template <typename Number>
 inline
 typename Vector<Number>::const_iterator 
@@ -632,6 +647,7 @@ Vector<Number>::begin () const
 };
 
 
+
 template <typename Number>
 inline
 typename Vector<Number>::iterator
@@ -641,6 +657,7 @@ Vector<Number>::end ()
 };
 
 
+
 template <typename Number>
 inline
 typename Vector<Number>::const_iterator
@@ -650,6 +667,7 @@ Vector<Number>::end () const
 };
 
 
+
 template <typename Number>
 inline
 Number Vector<Number>::operator() (const unsigned int i) const
@@ -659,6 +677,7 @@ Number Vector<Number>::operator() (const unsigned int i) const
 }
 
 
+
 template <typename Number>
 inline
 Number& Vector<Number>::operator() (const unsigned int i)
@@ -669,6 +688,16 @@ Number& Vector<Number>::operator() (const unsigned int i)
 
 
 
+template <typename Number>
+inline
+Vector<Number> & Vector<Number>::operator *= (const Number factor) 
+{
+  scale (factor);
+  return *this;
+};
+
+
+
 /**
  * Global function @p{swap} which overloads the default implementation
  * of the C++ standard library which uses a temporary object. The

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.