getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5447 - /trunk/getfem/src/bgeot_geometric_trans.cc


From: andriy . andreykiv
Subject: [Getfem-commits] r5447 - /trunk/getfem/src/bgeot_geometric_trans.cc
Date: Thu, 27 Oct 2016 12:58:03 -0000

Author: andrico
Date: Thu Oct 27 14:58:02 2016
New Revision: 5447

URL: http://svn.gna.org/viewcvs/getfem?rev=5447&view=rev
Log:
fixing another DEFINE_STATIC_THREAD_LOCAL usage

Modified:
    trunk/getfem/src/bgeot_geometric_trans.cc

Modified: trunk/getfem/src/bgeot_geometric_trans.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_geometric_trans.cc?rev=5447&r1=5446&r2=5447&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_geometric_trans.cc   (original)
+++ trunk/getfem/src/bgeot_geometric_trans.cc   Thu Oct 27 14:58:02 2016
@@ -28,10 +28,25 @@
 
 namespace bgeot {
 
-  DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, __aux1)
-  DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, __aux2)
-  DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, __aux3)
-  DEFINE_STATIC_THREAD_LOCAL(std::vector<int>, __ipvt_aux)
+std::vector<scalar_type>& __aux1(){
+  DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, v);
+  return v;
+}
+
+std::vector<scalar_type>& __aux2(){
+  DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, v);
+  return v;
+}
+
+std::vector<scalar_type>& __aux3(){
+  DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, v);
+  return v;
+}
+
+std::vector<int>& __ipvt_aux(){
+  DEFINE_STATIC_THREAD_LOCAL(std::vector<int>, vi);
+  return vi;
+}
   
   // Optimized lu_factor for small square matrices
   size_type lu_factor(scalar_type *A, std::vector<int> &ipvt,
@@ -123,23 +138,23 @@
     default:
       {
        size_type NN = N*N;
-       if (__aux1.size() < NN) __aux1.resize(N*N);
-       std::copy(A, A+NN, __aux1.begin());
-       __ipvt_aux.resize(N);
-       lu_factor(&(*(__aux1.begin())), __ipvt_aux, N);
-       return lu_det(&(*(__aux1.begin())), __ipvt_aux, N);
+       if (__aux1().size() < NN) __aux1().resize(N*N);
+       std::copy(A, A+NN, __aux1().begin());
+       __ipvt_aux().resize(N);
+       lu_factor(&(*(__aux1().begin())), __ipvt_aux(), N);
+       return lu_det(&(*(__aux1().begin())), __ipvt_aux(), N);
       }
     }
   }
 
   void lu_inverse(const scalar_type *LU, const std::vector<int> &ipvt,
                  scalar_type *A, size_type N) {
-    __aux2.resize(N); gmm::clear(__aux2);
-    __aux3.resize(N);
+    __aux2().resize(N); gmm::clear(__aux2());
+    __aux3().resize(N);
     for(size_type i = 0; i < N; ++i) {
-      __aux2[i] = scalar_type(1);
-      bgeot::lu_solve(LU, ipvt, A+i*N, &(*(__aux2.begin())), int(N));
-      __aux2[i] = scalar_type(0);
+      __aux2()[i] = scalar_type(1);
+      bgeot::lu_solve(LU, ipvt, A+i*N, &(*(__aux2().begin())), int(N));
+      __aux2()[i] = scalar_type(0);
     }
   }
 
@@ -177,14 +192,14 @@
     default:
       {
        size_type NN = N*N;
-       if (__aux1.size() < NN) __aux1.resize(NN);
-       std::copy(A, A+NN, __aux1.begin());
-       __ipvt_aux.resize(N);
-       size_type info = lu_factor(&(*(__aux1.begin())), __ipvt_aux, N);
+       if (__aux1().size() < NN) __aux1().resize(NN);
+       std::copy(A, A+NN, __aux1().begin());
+       __ipvt_aux().resize(N);
+       size_type info = lu_factor(&(*(__aux1().begin())), __ipvt_aux(), N);
        if (doassert) GMM_ASSERT1(!info, "Non invertible matrix, pivot = "
                                  << info);
-       if (!info) lu_inverse(&(*(__aux1.begin())), __ipvt_aux, A, N);
-       return lu_det(&(*(__aux1.begin())), __ipvt_aux, N);
+       if (!info) lu_inverse(&(*(__aux1().begin())), __ipvt_aux(), A, N);
+       return lu_det(&(*(__aux1().begin())), __ipvt_aux(), N);
       }
     }
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]