]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Specialize LAPACKFullMatrix::vmult (etc.) interface
authorMatthias Maier <tamiko@43-1.org>
Fri, 10 Apr 2015 22:33:36 +0000 (00:33 +0200)
committerMatthias Maier <tamiko@43-1.org>
Sat, 11 Apr 2015 09:25:17 +0000 (11:25 +0200)
include/deal.II/lac/full_matrix.templates.h
include/deal.II/lac/lapack_full_matrix.h
include/deal.II/lac/vector.h
source/lac/lapack_full_matrix.cc
source/lac/lapack_full_matrix.inst.in

index e1a113dcd11b0f547b2f09abda4c042fbb33e764..03b4609358945e2d445373f62f84b7ecd1ef1f0c 100644 (file)
 #define __deal2__full_matrix_templates_h
 
 
-//TODO: this file has a lot of operations between matrices and matrices or matrices and vectors of different precision. we should go through the file and in each case pick the more accurate data type for intermediate results. currently, the choice is pretty much random. this may also allow us some operations where one operand is complex and the other is not
+// TODO: this file has a lot of operations between matrices and matrices or
+// matrices and vectors of different precision. we should go through the
+// file and in each case pick the more accurate data type for intermediate
+// results. currently, the choice is pretty much random. this may also allow
+// us some operations where one operand is complex and the other is not
 
 #include <deal.II/base/config.h>
 #include <deal.II/base/template_constraints.h>
index ddd45f1cf9722b55a6c7afc52804fc3c22320e37..b9a90ae9880e65b6192a74cadadac21f809a5b62 100644 (file)
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2005 - 2014 by the deal.II authors
+// Copyright (C) 2005 - 2015 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -146,14 +146,14 @@ public:
                const size_type cols);
 
   /**
-   * Return the dimension of the range space.
+   * Return the dimension of the codomain (or range) space.
    *
    * @note The matrix is of dimension $m \times n$.
    */
   unsigned int m () const;
 
   /**
-   * Return the number of the range space.
+   * Return the dimension of the domain space.
    *
    * @note The matrix is of dimension $m \times n$.
    */
@@ -193,7 +193,7 @@ public:
    * <li> If #state is LAPACKSupport::svd or LAPACKSupport::inverse_svd, this
    * function first multiplies with the right transformation matrix, then with
    * the diagonal matrix of singular values or their reciprocal values, and
-   * finally with the left trandformation matrix.
+   * finally with the left transformation matrix.
    * </ul>
    *
    * The optional parameter <tt>adding</tt> determines, whether the result is
@@ -205,20 +205,31 @@ public:
    *
    * @note Source and destination must not be the same vector.
    *
-   * @note This template only exists for compile-time compatibility with
-   * FullMatrix. Implementation is only available for
-   * <tt>VECTOR=Vector&lt;number&gt;</tt>
+   * @note The template with @tref number2 only exists for compile-time
+   * compatibility with FullMatrix. Only the case @tref number2 = @tref
+   * number is implemented due to limitations in the underlying LAPACK
+   * interface
    */
-  template <class VECTOR>
-  void vmult(VECTOR &dst, const VECTOR &src, const bool adding = false) const;
+  template <typename number2>
+  void vmult (Vector<number2>       &w,
+              const Vector<number2> &v,
+              const bool             adding = false) const;
+
+  void vmult (Vector<number>       &w,
+              const Vector<number> &v,
+              const bool            adding = false) const;
 
   /**
    * Adding Matrix-vector-multiplication.  <i>w += A*v</i>
    *
    * See the documentation of vmult() for details on the implementation.
    */
-  template <class VECTOR>
-  void vmult_add (VECTOR &w, const VECTOR &v) const;
+  template <typename number2>
+  void vmult_add (Vector<number2>       &w,
+                  const Vector<number2> &v) const;
+
+  void vmult_add (Vector<number>       &w,
+                  const Vector<number> &v) const;
 
   /**
    * Transpose matrix-vector-multiplication.
@@ -232,27 +243,25 @@ public:
    *
    * See the documentation of vmult() for details on the implementation.
    */
-  template <class VECTOR>
-  void Tvmult (VECTOR &w, const VECTOR &v,
+  template <typename number2>
+  void Tvmult (Vector<number2>       &w,
+               const Vector<number2> &v,
+               const bool             adding=false) const;
+
+  void Tvmult (Vector<number>       &w,
+               const Vector<number> &v,
                const bool            adding=false) const;
 
   /**
-   * Adding transpose matrix-vector-multiplication.  <i>w +=
-   * A<sup>T</sup>*v</i>
+   * Adding transpose matrix-vector-multiplication.
+   * <i>w += A<sup>T</sup>*v</i>
    *
    * See the documentation of vmult() for details on the implementation.
    */
-  template <class VECTOR>
-  void Tvmult_add (VECTOR &w, const VECTOR &v) const;
+  template <typename number2>
+  void Tvmult_add (Vector<number2>       &w,
+                   const Vector<number2> &v) const;
 
-  void vmult (Vector<number>   &w,
-              const Vector<number> &v,
-              const bool            adding=false) const;
-  void vmult_add (Vector<number>       &w,
-                  const Vector<number> &v) const;
-  void Tvmult (Vector<number>       &w,
-               const Vector<number> &v,
-               const bool            adding=false) const;
   void Tvmult_add (Vector<number>       &w,
                    const Vector<number> &v) const;
 
@@ -738,38 +747,52 @@ LAPACKFullMatrix<number>::fill (
 
 
 template <typename number>
-template <class VECTOR>
-inline void
-LAPACKFullMatrix<number>::vmult(VECTOR &, const VECTOR &, bool) const
+template <typename number2>
+void
+LAPACKFullMatrix<number>::vmult (Vector<number2> &,
+                                 const Vector<number2> &,
+                                 const bool) const
 {
-  Assert(false, ExcNotImplemented());
+  Assert(false,
+         ExcMessage("LAPACKFullMatrix<number>::vmult must be called with a "
+                    "matching Vector<double> vector type."));
 }
 
 
 template <typename number>
-template <class VECTOR>
-inline void
-LAPACKFullMatrix<number>::vmult_add(VECTOR &, const VECTOR &) const
+template <typename number2>
+void
+LAPACKFullMatrix<number>::vmult_add (Vector<number2> &,
+                                     const Vector<number2> &) const
 {
-  Assert(false, ExcNotImplemented());
+  Assert(false,
+         ExcMessage("LAPACKFullMatrix<number>::vmult_add must be called with a "
+                    "matching Vector<double> vector type."));
 }
 
 
 template <typename number>
-template <class VECTOR>
-inline void
-LAPACKFullMatrix<number>::Tvmult(VECTOR &, const VECTOR &, bool) const
+template <typename number2>
+void
+LAPACKFullMatrix<number>::Tvmult (Vector<number2> &,
+                                  const Vector<number2> &,
+                                  const bool) const
 {
-  Assert(false, ExcNotImplemented());
+  Assert(false,
+         ExcMessage("LAPACKFullMatrix<number>::Tvmult must be called with a "
+                    "matching Vector<double> vector type."));
 }
 
 
 template <typename number>
-template <class VECTOR>
-inline void
-LAPACKFullMatrix<number>::Tvmult_add(VECTOR &, const VECTOR &) const
+template <typename number2>
+void
+LAPACKFullMatrix<number>::Tvmult_add (Vector<number2> &,
+                                      const Vector<number2> &) const
 {
-  Assert(false, ExcNotImplemented());
+  Assert(false,
+         ExcMessage("LAPACKFullMatrix<number>::Tvmult_add must be called with a "
+                    "matching Vector<double> vector type."));
 }
 
 
index a44067ba2eae97ea3f6b9c326b0aa46c2801a2a9..304cdc0d33837524ac52ff102b0aca3ae2d2ceab 100644 (file)
@@ -955,7 +955,7 @@ protected:
   /**
    * LAPACK matrices need access to the data.
    */
-  friend class LAPACKFullMatrix<Number>;
+  template <typename Number2> friend class LAPACKFullMatrix;
 
   /**
    * VectorView will access the pointer.
index a7ab7759a8fa754b746aac591042e0e2ed8509cd..74cde57dc850d199d050241d9630e12923be5eff 100644 (file)
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2005 - 2014 by the deal.II authors
+// Copyright (C) 2005 - 2015 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -247,6 +247,24 @@ LAPACKFullMatrix<number>::Tvmult (
 }
 
 
+template <typename number>
+void
+LAPACKFullMatrix<number>::vmult_add (Vector<number>       &w,
+                                     const Vector<number> &v) const
+{
+  vmult(w, v, true);
+}
+
+
+template <typename number>
+void
+LAPACKFullMatrix<number>::Tvmult_add (Vector<number>       &w,
+                                      const Vector<number> &v) const
+{
+  Tvmult(w, v, true);
+}
+
+
 template <typename number>
 void
 LAPACKFullMatrix<number>::mmult(LAPACKFullMatrix<number>       &C,
@@ -958,31 +976,6 @@ LAPACKFullMatrix<number>::compute_generalized_eigenvalues_symmetric (
 }
 
 
-// template <typename number>
-// LAPACKFullMatrix<number>::()
-// {}
-
-
-template <typename number>
-void
-LAPACKFullMatrix<number>::vmult_add (
-  Vector<number>       &w,
-  const Vector<number> &v) const
-{
-  vmult(w, v, true);
-}
-
-
-template <typename number>
-void
-LAPACKFullMatrix<number>::Tvmult_add (
-  Vector<number>       &w,
-  const Vector<number> &v) const
-{
-  Tvmult(w, v, true);
-}
-
-
 template <typename number>
 void
 LAPACKFullMatrix<number>::print_formatted (
index d366afef61a08faaf4e00ce0ea691150b3d9df35..1b2958d53f9b2e926355e5a03980519800d99fa6 100644 (file)
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2013 - 2014 by the deal.II authors
+// Copyright (C) 2013 - 2015 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //

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.