Simplexus  1.0
Création d'un pavage par des simplexes de dimension N et visualisation graphique en dimension 2.
mathutil.hpp
Go to the documentation of this file.
1 #ifndef _MATHUTIL_H
2 #define _MATHUTIL_H
3 
11 #include <cstddef>
12 #include <cstdlib>
13 #include <iostream>
14 #include <cmath>
15 #include <vector>
16 
25 template <unsigned int N> struct Factorial
26 { enum { valeur = N*Factorial<N-1>::valeur};};
27 template <> struct Factorial<0>
28 { enum {valeur =1}; };
29 
38 double determinant(std::vector<std::vector<double>> det);
39 
48 inline bool isInteger(char* &s){
49  if (s == nullptr)
50  return false;
51  if (( !isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))
52  return false;
53  char *p;
54  strtol (s, &p, 10);
55  return (*p==0);
56 }
57 
67  template <unsigned int N>
68  inline double Pow(double x)
69  {return x*Pow<N-1>(x);}
70 
71  template <>
72  inline double Pow<0>(double)
73  {return 1.0;}
74 
82 constexpr double pi(){return std::atan(1)*4;}
83 
84 #endif
Calcul de la Factorial de N.
Definition: mathutil.hpp:25
double Pow(double x)
Calcul de Pow.
Definition: mathutil.hpp:68
double Pow< 0 >(double)
Definition: mathutil.hpp:72
double determinant(std::vector< std::vector< double >> det)
Calcul d'un déterminant.
Definition: mathutil.cpp:7
constexpr double pi()
Calcul de pi.
Definition: mathutil.hpp:82
bool isInteger(char *&s)
Determine si une chaine de caractere est un entier.
Definition: mathutil.hpp:48