CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsTypeTools.cpp
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
34 
36 operator<(const CepsHash3& h31, const CepsHash3& h32)
37 {
38  return h31.h1<h32.h1 or (h31.h1==h32.h1 and
39  (h31.h2<h32.h2 or (h31.h2==h32.h2 and
40  h31.h3<h32.h3)));
41 }
42 
43 std::ostream&
44 operator<<(std::ostream& os, const CepsHash3& h)
45 {
46  os << "(" << h.h1 << ", " << h.h2 << ", " << h.h3 << ")";
47  return os;
48 }
49 
52 {
53  CepsHash3 res;
54  res.h1 = CepsSHash(std::round(xyz[0]/CEPS_HASH3_PRECISION));
55  res.h2 = CepsSHash(std::round(xyz[1]/CEPS_HASH3_PRECISION));
56  res.h3 = CepsSHash(std::round(xyz[2]/CEPS_HASH3_PRECISION));
57  return res;
58 }
59 
60 void
62 {
63  CEPS_ABORT_IF(std::isnan(value) or std::isinf(value),
64  "Detected NaN or Infty: " << message
65  );
66 }
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
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.
#define CEPS_HASH3_PRECISION
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
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
CepsHash3 getHash3(const CepsReal3D &xyz)
Get a triple hash from real coordinates.
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.