159 lines
3.6 KiB
C++
159 lines
3.6 KiB
C++
|
|
// This file is part of the Herezh++ application.
|
|
//
|
|
// The finite element software Herezh++ is dedicated to the field
|
|
// of mechanics for large transformations of solid structures.
|
|
// It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600)
|
|
// INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) <https://www.irdl.fr/>.
|
|
//
|
|
// Herezh++ is distributed under GPL 3 license ou ultérieure.
|
|
//
|
|
// Copyright (C) 1997-2022 Université Bretagne Sud (France)
|
|
// AUTHOR : Gérard Rio
|
|
// E-MAIL : gerardrio56@free.fr
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License,
|
|
// or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
// See the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
//
|
|
// For more information, please consult: <https://herezh.irdl.fr/>.
|
|
|
|
#include "MathUtil.h"
|
|
|
|
#ifndef MATHUTIL_H_deja_inclus
|
|
|
|
|
|
// minimum de deux doubles
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
double MiN(double a,double b)
|
|
{ if (a > b)
|
|
return b;
|
|
else
|
|
return a;
|
|
};
|
|
|
|
// maximum de deux doubles
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
double MaX(double a,double b)
|
|
{ if (a > b)
|
|
return a;
|
|
else
|
|
return b;
|
|
};
|
|
|
|
// minimum de deux entiers
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
int MiN(int a,int b)
|
|
{ if (a > b)
|
|
return b;
|
|
else
|
|
return a;
|
|
};
|
|
|
|
// maximum de deux entiers
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
int MaX(int a,int b)
|
|
{ if (a > b)
|
|
return a;
|
|
else
|
|
return b;
|
|
};
|
|
|
|
|
|
|
|
// minimum des valeurs absolues de deux doubles
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
double DabsMiN(double a,double b)
|
|
{ if (Dabs(a) < Dabs(b)) {return Dabs(a);}
|
|
else {return Dabs(b);};
|
|
};
|
|
|
|
// maximum des valeurs absolues de deux doubles
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
double DabsMaX(double a,double b)
|
|
{ if (Dabs(a) < Dabs(b)) {return Dabs(b);}
|
|
else {return Dabs(a);};
|
|
};
|
|
|
|
// maximum des valeurs absolues de 3 doubles
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
double DabsMaX(double a,double b,double c)
|
|
{double A = Dabs(a);
|
|
double B = Dabs(b);
|
|
double C = Dabs(c);
|
|
if (A < B )
|
|
{if (B < C) {return C;}
|
|
else {return B;};
|
|
}
|
|
else
|
|
{if (A < C) {return C;}
|
|
else {return A;};
|
|
}
|
|
};
|
|
|
|
|
|
|
|
// minimum des valeurs absolues de deux entiers
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
int DabsMiN(int a,int b)
|
|
{ if (Dabs(a) < Dabs(b)) {return Dabs(a);}
|
|
else {return Dabs(b);};
|
|
};
|
|
|
|
// maximum des valeurs absolues de deux entiers
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
int DabsMaX(int a,int b)
|
|
{ if (Dabs(a) < Dabs(b)) {return Dabs(b);}
|
|
else {return Dabs(a);};
|
|
};
|
|
|
|
// maximum des valeurs absolu d'un tableau de n réels
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
double DabsMaxiTab(double * tab, int n)
|
|
{ double maxi = Dabs(tab[0]);
|
|
for (int i=1; i<n;i++)
|
|
if (maxi < Dabs(tab[i])) maxi = Dabs(tab[i]);
|
|
return maxi;
|
|
};
|
|
|
|
// maximum des valeurs absolu d'un tableau de n entier relatifs
|
|
#ifndef MISE_AU_POINT
|
|
inline
|
|
#endif
|
|
int DabsMaxiTab(int * tab, int n)
|
|
{ int maxi = Dabs(tab[0]);
|
|
for (int i=1; i<n;i++)
|
|
if (maxi < Dabs(tab[i])) maxi = Dabs(tab[i]);
|
|
return maxi;
|
|
};
|
|
|
|
#endif
|