Gyoto
GyotoUtils.h
Go to the documentation of this file.
1 
8 /*
9  Copyright 2011, 2016, 2026 Thibaut Paumard
10 
11  This file is part of Gyoto.
12 
13  Gyoto is free software: you can redistribute it and/or modify
14  it under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  Gyoto is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 #ifndef __GyotoUtils_H_
28 #define __GyotoUtils_H_
29 
30 #include "GyotoDefs.h"
31 
32 #include <string>
33 #include <string_view>
34 #include <vector>
35 #include <glob.h>
36 
37 namespace Gyoto {
39 
42  void debug(int mode);
43 
45 
48  int debug();
49 
51 
62  void verbose(int mode);
63 
65 
68  int verbose();
69 
71 
83  void convert(double * const x, const std::size_t nelem,
84  const double mass_sun, const double distance_kpc,
85  const std::string unit);
86 
88 
95  bool startsWithCaseInsensitive(std::string_view str, std::string_view prefix);
96 
98 
111  double stringToDouble(const std::string &str);
112 
114 
121  std::string doubleToString(double value);
122 
124 
127  void help(std::string class_name);
128 
130  std::vector<std::string> split(std::string const &src, std::string const &delim);
131 
133  /*
134  boost Bessel function as implemented in
135  #include <boost/math/special_functions/bessel.hpp>
136  are 50% longer than the following, while the following
137  give results accurate at ~1e-6 which is more than enough.
138  */
139  double bessi0(double xx);
140  double bessi1(double xx);
141  double bessk0(double xx);
142  double bessk1(double xx);
143  double bessk(int nn, double xx);
144 
145  double hypergeom (double kappaIndex, double thetae);
146 
148  void cartesianToSpherical(double const cpos[3], double spos[3]);
150  void sphericalToCartesian(double const spos[3], double cpos[3]);
151 
153 
157  // Keep argument names for swig!
158  void matrix4Invert(double ARGOUT_ARRAY2[4][4], double const IN_ARRAY2[4][4]);
159 
161 
169  // Keep argument names for swig!
170  void matrix4CircularInvert(double ARGOUT_ARRAY2[4][4], double const IN_ARRAY2[4][4]);
171 
173 
197  std::vector<std::string> glob(const std::string pattern,
198  int flags = GLOB_NOCHECK | GLOB_NOSORT |
199  GLOB_TILDE | GLOB_BRACE);
200 }
201 
202 #endif
void sphericalToCartesian(double const spos[3], double cpos[3])
Tranform from spherical 3-position to Cartesian 3-position.
double bessk(int nn, double xx)
Modified Bessel function.
void convert(double *const x, const std::size_t nelem, const double mass_sun, const double distance_kpc, const std::string unit)
Convert lengths (deprecated)
void matrix4Invert(double ARGOUT_ARRAY2[4][4], double const IN_ARRAY2[4][4])
Invert 4x4 matrix.
#define size_t
If not defined in <sys/types.h>.
Definition: GyotoConfig.h:424
std::string doubleToString(double value)
Represent double as a C++ string.
void verbose(int mode)
Set verbosity level.
void help(std::string class_name)
Print help on class.
double stringToDouble(const std::string &str)
Interpret C++ string as double.
bool startsWithCaseInsensitive(std::string_view str, std::string_view prefix)
Case-insensitive prefix check for string views.
double bessi1(double xx)
Modified Bessel function I1
void cartesianToSpherical(double const cpos[3], double spos[3])
Tranform from Cartesian 3-position to spherical 3-position.
Gyoto ubiquitous macros and typedefs.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:46
double bessk1(double xx)
Modified Bessel function K1
void debug(int mode)
Set debug mode.
std::vector< std::string > split(std::string const &src, std::string const &delim)
Split string.
double hypergeom(double kappaIndex, double thetae)
Gauss hypergeometric 2F1 term for kappa-distribution synchrotron.
void matrix4CircularInvert(double ARGOUT_ARRAY2[4][4], double const IN_ARRAY2[4][4])
Invert 4x4 circular spacetime metric.
double bessk0(double xx)
Modified Bessel function K0
double bessi0(double xx)
Bessel function computation.
std::vector< std::string > glob(const std::string pattern, int flags=GLOB_NOCHECK|GLOB_NOSORT|GLOB_TILDE|GLOB_BRACE)
Generate pathnames matching a pattern.