]> https://gitweb.dealii.org/ - dealii.git/commitdiff
move thread mutex 5154/head
authorDenis Davydov <davydden@gmail.com>
Wed, 27 Sep 2017 14:47:01 +0000 (16:47 +0200)
committerDenis Davydov <davydden@gmail.com>
Wed, 27 Sep 2017 17:16:42 +0000 (19:16 +0200)
source/lac/lapack_full_matrix.cc

index 28961749ad4224237143e13233d570ed8ba9f1f2..dc71210063864e1b9a89d534fd63edc28b919de4 100644 (file)
@@ -178,8 +178,6 @@ LAPACKFullMatrix<number>::vmult (
   const Vector<number> &v,
   const bool            adding) const
 {
-  Threads::Mutex::ScopedLock lock (mutex);
-
   const int mm = this->n_rows();
   const int nn = this->n_cols();
   const number alpha = 1.;
@@ -199,6 +197,7 @@ LAPACKFullMatrix<number>::vmult (
     }
     case svd:
     {
+      Threads::Mutex::ScopedLock lock (mutex);
       AssertDimension(v.size(), this->n_cols());
       AssertDimension(w.size(), this->n_rows());
       // Compute V^T v
@@ -213,6 +212,7 @@ LAPACKFullMatrix<number>::vmult (
     }
     case inverse_svd:
     {
+      Threads::Mutex::ScopedLock lock (mutex);
       AssertDimension(w.size(), this->n_cols());
       AssertDimension(v.size(), this->n_rows());
       // Compute U^T v
@@ -238,8 +238,6 @@ LAPACKFullMatrix<number>::Tvmult (
   const Vector<number> &v,
   const bool            adding) const
 {
-  Threads::Mutex::ScopedLock lock (mutex);
-
   const int mm = this->n_rows();
   const int nn = this->n_cols();
   const number alpha = 1.;
@@ -259,6 +257,7 @@ LAPACKFullMatrix<number>::Tvmult (
     }
     case svd:
     {
+      Threads::Mutex::ScopedLock lock (mutex);
       AssertDimension(w.size(), this->n_cols());
       AssertDimension(v.size(), this->n_rows());
 
@@ -271,21 +270,22 @@ LAPACKFullMatrix<number>::Tvmult (
       // Multiply with V
       gemv("T", &nn, &nn, &alpha, &svd_vt->values[0], &nn, &work[0], &one, &beta, w.val, &one);
       break;
-      case inverse_svd:
-      {
-        AssertDimension(v.size(), this->n_cols());
-        AssertDimension(w.size(), this->n_rows());
-
-        // Compute V^T v
-        work.resize(std::max(mm,nn));
-        gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, &work[0], &one);
-        // Multiply by singular values
-        for (size_type i=0; i<wr.size(); ++i)
-          work[i] *= wr[i];
-        // Multiply with U
-        gemv("N", &mm, &mm, &alpha, &svd_u->values[0], &mm, &work[0], &one, &beta, w.val, &one);
-        break;
-      }
+    }
+    case inverse_svd:
+    {
+      Threads::Mutex::ScopedLock lock (mutex);
+      AssertDimension(v.size(), this->n_cols());
+      AssertDimension(w.size(), this->n_rows());
+
+      // Compute V^T v
+      work.resize(std::max(mm,nn));
+      gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, &work[0], &one);
+      // Multiply by singular values
+      for (size_type i=0; i<wr.size(); ++i)
+        work[i] *= wr[i];
+      // Multiply with U
+      gemv("N", &mm, &mm, &alpha, &svd_u->values[0], &mm, &work[0], &one, &beta, w.val, &one);
+      break;
     }
     default:
       Assert (false, ExcState(state));

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.