CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsTypeTools.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
31 #pragma once
32 
33 #include <ostream>
34 #include <tuple>
35 
37 
39 namespace ceps
40 {
41 
43  namespace hash
44  {
46  template <class _Type>
47  constexpr CepsHash
48  get (_Type const& i)
49  {
50  return std::hash<_Type> {}(i);
51  }
52 
54  template <class _Type1, class _Type2>
55  constexpr CepsHash
56  get (_Type1 const& i, _Type2 const& j)
57  {
58  return get<_Type1> (i) ^ (get<_Type2> (j) << 1);
59  }
60 
62  template <class _Arg0, class... _Args>
63  constexpr CepsHash
64  get (_Arg0 const& arg0, _Args const&...args)
65  {
66  return get (arg0, get (args...));
67  }
68 
69  } // namespace hash
70 } // namespace ceps
71 
74 struct CepsHash3
75 {
80 };
81 
82 #define CEPS_HASH3_PRECISION 1.e-12
83 
86 operator<(const CepsHash3& h31, const CepsHash3& h32);
87 
89 std::ostream&
90 operator<<(std::ostream& os, const CepsHash3& h);
91 
92 namespace ceps
93 {
94  namespace hash
95  {
97  CepsHash3
98  getHash3(const CepsReal3D& xyz);
99  }
100 
102  void
103  checkNanOrInf(CepsReal v, CepsString message = "");
104 
105 
106 }
CepsBool operator<(const CepsHash3 &h31, const CepsHash3 &h32)
Comparator for two CepsHash3, in order to use them in a map.
std::ostream & operator<<(std::ostream &os, const CepsHash3 &h)
Display a triple hash.
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
CepsSize CepsHash
Hashes for distributed data.
Definition: CepsTypes.hpp:220
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
int64_t CepsSHash
Hashes for coordinates.
Definition: CepsTypes.hpp:221
CepsArray3< CepsReal > CepsReal3D
Three real scalars, used like this for compatibility in polynomials.
Definition: CepsTypes.hpp:178
constexpr CepsHash get(_Type const &i)
get a hash from a single value
CepsHash3 getHash3(const CepsReal3D &xyz)
Get a triple hash from real coordinates.
A namespace for all utility methods.
void checkNanOrInf(CepsReal v, CepsString message="")
Stops if value is NaN or infty.
A triple hash to be used for coordinates (multiplied *10^12 then truncated)
CepsSHash h2
Hash for y.
CepsSHash h3
Hash for z.
CepsSHash h1
One hash for each coordinate.