From 9844b36346a7c43e5d921580a01e8af4ad72316e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 12 Nov 2004 00:50:18 +0000
Subject: [PATCH] Fix compilation bustage with older gcc versions + fix non-gsl
 compilation problem

---
 Common/AdaptiveViews.cpp | 18 +++++-----
 Common/GmshMatrix.h      | 78 ++++++++++++++++++++++------------------
 Common/Views.h           |  6 ++--
 3 files changed, 55 insertions(+), 47 deletions(-)

diff --git a/Common/AdaptiveViews.cpp b/Common/AdaptiveViews.cpp
index d1035ab1a9..9401c08435 100644
--- a/Common/AdaptiveViews.cpp
+++ b/Common/AdaptiveViews.cpp
@@ -187,7 +187,7 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
   std::set<_point>::iterator it  = _point::all_points.begin();
   std::set<_point>::iterator ite = _point::all_points.end();
 
-  clock_t c0 = clock();
+  double c0 = Cpu();
 
   const int N = _coefs->size1();
   Double_Vector val ( N ), res(_point::all_points.size());
@@ -208,7 +208,7 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
   _Interpolate->mult(val,res);
   _Geometry->mult(xyz,XYZ);
   
-  clock_t c1 = clock();
+  double c1 = Cpu();
 
   int kk=0;
   for ( ; it !=ite ; ++it)
@@ -232,7 +232,7 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
       kk++;
     }
 
-  clock_t c2 = clock();
+  double c2 = Cpu();
 
   std::list<_triangle*>::iterator itt  = _triangle::all_triangles.begin();
   std::list<_triangle*>::iterator itte = _triangle::all_triangles.end();
@@ -248,7 +248,7 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
   else
     _triangle::Error ( max-min, tol );
  
-  clock_t c3 = clock();
+  double c3 = Cpu();
   itt  = _triangle::all_triangles.begin();
   for ( ;itt != itte ; itt++)
     {
@@ -272,12 +272,12 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
 	  view->NbST++;
 	}
     }
-  clock_t c4 = clock();
+  double c4 = Cpu();
 
-  t0 += (double)(c1-c0)/CLOCKS_PER_SEC;
-  t1 += (double)(c2-c1)/CLOCKS_PER_SEC;
-  t2 += (double)(c3-c2)/CLOCKS_PER_SEC;
-  t3 += (double)(c4-c3)/CLOCKS_PER_SEC;
+  t0 += c1-c0;
+  t1 += c2-c1;
+  t2 += c3-c2;
+  t3 += c4-c3;
 
 }
 
diff --git a/Common/GmshMatrix.h b/Common/GmshMatrix.h
index 0658f54879..0d42e70dbf 100644
--- a/Common/GmshMatrix.h
+++ b/Common/GmshMatrix.h
@@ -2,89 +2,97 @@
 #define _GMSH_BOOSTMATRIX_
 
 template <class SCALAR>
-class Gmsh_Matrix
+class Gmsh_Vector
 {
 private:
-  int r,c;
+  int r;
 public:
-  inline int size1() const {return r;}
-  inline int size2() const {return c;}
+  inline int size() const {return r;}
   SCALAR *data;
-  ~Gmsh_Matrix() {delete [] data;}
-  Gmsh_Matrix(int R,int C)
-    : r(R),c(C)
+  ~Gmsh_Vector() {delete [] data;}
+  Gmsh_Vector(int R)
+    : r(R)
   {
-    data = new SCALAR [r*c];
+    data = new SCALAR [r];
     scal(0);
   }
-  Gmsh_Matrix(const Gmsh_Matrix<SCALAR> &other)
-    : r(other.r),c(other.c)
+  Gmsh_Vector(const Gmsh_Vector<SCALAR> &other)
+    : r(other.r)
   {
-    data = new double [r*c];
+    data = new double [r];
     copy ( other.data ) ;
   }
-  inline SCALAR operator () (int i, int j) const
+  inline SCALAR operator () (int i) const
   {
-    return data[i+r*j];
+    return data[i];
   }
-  inline SCALAR & operator () (int i, int j)
+  inline SCALAR & operator () (int i)
   {
-    return data[i+r*j];
+    return data[i];
   }
-  inline Gmsh_Matrix operator *(const Gmsh_Matrix<SCALAR> & other)
+  inline SCALAR operator *(const Gmsh_Vector<SCALAR> & other)
   {
     throw;
   }
   inline void scal ( const SCALAR s)
   {
-    for (int i=0;i<r*c;++i)data[i]*=s;
+    for (int i=0;i<r;++i)data[i]*=s;
   }
   inline void copy ( const SCALAR **other)
   {
-    for (int i=0;i<r*c;++i)data[i]=other.data[i];
+    for (int i=0;i<r;++i)data[i]=other.data[i];
   }
 };
 
 template <class SCALAR>
-class Gmsh_Vector
+class Gmsh_Matrix
 {
 private:
-  int r;
+  int r,c;
 public:
-  inline int size() const {return r;}
+  inline int size1() const {return r;}
+  inline int size2() const {return c;}
   SCALAR *data;
-  ~Gmsh_Vector() {delete [] data;}
-  Gmsh_Vector(int R)
-    : r(R)
+  ~Gmsh_Matrix() {delete [] data;}
+  Gmsh_Matrix(int R,int C)
+    : r(R),c(C)
   {
-    data = new SCALAR [r];
+    data = new SCALAR [r*c];
     scal(0);
   }
-  Gmsh_Vector(const Gmsh_Vector<SCALAR> &other)
-    : r(other.r)
+  Gmsh_Matrix(const Gmsh_Matrix<SCALAR> &other)
+    : r(other.r),c(other.c)
   {
-    data = new double [r];
+    data = new double [r*c];
     copy ( other.data ) ;
   }
-  inline SCALAR operator () (int i) const
+  inline SCALAR operator () (int i, int j) const
   {
-    return data[i];
+    return data[i+r*j];
   }
-  inline SCALAR & operator () (int i)
+  inline SCALAR & operator () (int i, int j)
   {
-    return data[i];
+    return data[i+r*j];
   }
-  inline SCALAR operator *(const Gmsh_Vector<SCALAR> & other)
+  inline Gmsh_Matrix operator *(const Gmsh_Matrix<SCALAR> & other)
   {
     throw;
   }
   inline void scal ( const SCALAR s)
   {
-    for (int i=0;i<r;++i)data[i]*=s;
+    for (int i=0;i<r*c;++i)data[i]*=s;
   }
   inline void copy ( const SCALAR **other)
   {
-    for (int i=0;i<r;++i)data[i]=other.data[i];
+    for (int i=0;i<r*c;++i)data[i]=other.data[i];
+  }
+  inline void mult(const Gmsh_Matrix<SCALAR> & x, const Gmsh_Matrix<SCALAR> & b)
+  {
+    throw;
+  }
+  inline void mult (const Gmsh_Vector<SCALAR> & x, Gmsh_Vector<SCALAR> & b )
+  {
+    throw;
   }
 };
 
diff --git a/Common/Views.h b/Common/Views.h
index 9c80122189..5330603146 100644
--- a/Common/Views.h
+++ b/Common/Views.h
@@ -25,7 +25,8 @@
 #include "VertexArray.h"
 #include "SmoothNormals.h"
 #include "GmshMatrix.h"
-#include<list>
+#include <list>
+
 #define VIEW_NB_ELEMENT_TYPES  (8*3)
 #define VIEW_MAX_ELEMENT_NODES  8
 #define VAL_INF 1.e200
@@ -77,8 +78,7 @@ public:
 
   inline double V () const
   {
-    static const double THIRD = 1./3.;
-    return (p[0]->val + p[1]->val + p[2]->val)*THIRD;    
+    return (p[0]->val + p[1]->val + p[2]->val)/3.;    
   }
   void print ()
   {
-- 
GitLab