From 867dd051b2be688606f16cfebc3e8d6a8d2d551b Mon Sep 17 00:00:00 2001
From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be>
Date: Wed, 1 Sep 2010 12:48:35 +0000
Subject: [PATCH] dg : faster integrals on boundary

---
 Solver/functionDerivator.cpp | 18 ++++++++++--------
 Solver/functionDerivator.h   |  4 ++--
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Solver/functionDerivator.cpp b/Solver/functionDerivator.cpp
index 79e99bccce..adbd0070bb 100644
--- a/Solver/functionDerivator.cpp
+++ b/Solver/functionDerivator.cpp
@@ -1,19 +1,21 @@
 #include "functionDerivator.h"
 #include "function.h"
 
-void functionDerivator::compute() {
+const fullMatrix<double> &functionDerivator::compute() {
   _xRef = _x.get();
   _fRef = _f.get();
-  _dfdx = fullMatrix<double>(_fRef.size1(),_fRef.size2()*_xRef.size2());
+  _dfdx.resize(_fRef.size1(),_fRef.size2()*_xRef.size2(), false);
   for (int j=0;j<_xRef.size2();j++) {
-    _xDx = _xRef;
+    fullMatrix<double> &x =_x.set();
     for (int i=0;i<_fRef.size1();i++)
-      _xDx(i,j) += _epsilon;
-    _x.set()=_xDx;
+      x(i,j) += _epsilon;
     const fullMatrix<double> &f = _f.get();
-    for (int i=0; i<_fRef.size1(); i++) 
-      for (int k=0; k<_fRef.size2(); k++) 
+    for (int k=0; k<_fRef.size2(); k++) 
+      for (int i=0; i<_fRef.size1(); i++) 
         _dfdx(i, k*_xRef.size2()+j) = (f(i,k)-_fRef(i,k))/_epsilon;
+    for (int i=0;i<_fRef.size1();i++)
+      x(i,j) = _xRef(i,j);
   }
-  _x.set()=_xRef;
+  _x.set();
+  return _dfdx;
 };
diff --git a/Solver/functionDerivator.h b/Solver/functionDerivator.h
index ad651e5160..1793a31930 100644
--- a/Solver/functionDerivator.h
+++ b/Solver/functionDerivator.h
@@ -6,7 +6,7 @@
 
 class functionDerivator {
   dataCacheDouble &_f,&_x;
-  fullMatrix<double> _fRef, _xRef,_xDx, _dfdx;
+  fullMatrix<double> _fRef, _xRef, _dfdx;
   double _epsilon;
   public:
   functionDerivator (dataCacheDouble &f, dataCacheDouble &x, double epsilon):
@@ -14,7 +14,7 @@ class functionDerivator {
     _x(x),
     _epsilon(epsilon)
     {}
-  void compute();
+  const fullMatrix<double> &compute();
   inline double get(int iQP, int iF, int iX) 
   {
     return _dfdx(iQP, iF*_xRef.size2()+iX);
-- 
GitLab