/home/runner/work/DiFfRG/DiFfRG/DiFfRG/include/DiFfRG/discretization/coordinates/coordinates.hh Source File#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
coordinates.hh
Go to the documentation of this file.
50 template <typename T> inline constexpr bool is_periodic_coordinate_v = internal::coord_periodic<T>::value;
66 template <typename C, size_t i> inline constexpr bool is_periodic_axis_v = internal::axis_periodic<C, i>::value;
78 std::snprintf(buffer, sizeof(buffer), "%.*g", std::numeric_limits<NT>::max_digits10, double(value));
100 static_assert(sizeof...(Coordinates) > 0, "CoordinatePackND requires at least one coordinate system");
102 static_assert(((Coordinates::dim == 1) && ...), "CoordinatePackND requires all coordinates to have dim 1");
131 return forward_impl(device::make_integer_sequence<int, sizeof...(I)>(), device::forward<I>(i)...);
135 KOKKOS_FORCEINLINE_FUNCTION device::array<ctype, dim> forward(const device::array<IT, dim> &coords) const
141 device::array<ctype, dim> KOKKOS_FORCEINLINE_FUNCTION forward_impl(device::integer_sequence<int, Is...>,
148 template <typename... I> KOKKOS_FORCEINLINE_FUNCTION device::array<ctype, sizeof...(I)> backward(I &&...i) const
151 return backward_impl(device::make_integer_sequence<int, sizeof...(I)>(), device::forward<I>(i)...);
155 device::array<ctype, sizeof...(I)> KOKKOS_FORCEINLINE_FUNCTION backward_impl(device::integer_sequence<int, Is...>,
174 constexpr_for<0, sizeof...(Coordinates), 1>([&](auto i) { size *= device::get<i>(coordinates).size(); });
182 constexpr_for<0, sizeof...(Coordinates), 1>([&](auto i) { sizes[i] = device::get<i>(coordinates).size(); });
187 device::array<size_t, sizeof...(Coordinates)> KOKKOS_INLINE_FUNCTION from_linear_index(size_t s) const
192 idx[sizeof...(Coordinates) - 1 - i] = s % device::get<sizeof...(Coordinates) - 1 - i>(coordinates).size();
201 friend bool operator==(const CoordinatePackND<Coordinates...> &r, const CoordinatePackND<Coordinates2...> &l)
250 SubCoordinates(const Base &base, size_t offset, size_t size) : Base(base), m_offset(offset), m_size(size)
253 if (offset + size > base.size()) throw std::runtime_error("SubCoordinates: offset + size must be <= base.size()");
259 static_assert(dim == 1, "SubCoordinates is a linear index window, which is a per-axis box only for dim == 1.");
282 template <typename IT> KOKKOS_INLINE_FUNCTION device::array<ctype, dim> forward(device::array<IT, dim> i) const
330 : LinearCoordinates1D(LinearCoordinates1D(other.parent_size(), other.start, other.stop), other.size())
359 template <typename IT> NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const { return start + a * x; }
362 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
391 return "LinearCoordinates1D(" + std::to_string(parent_extent) + ", " + internal::round_trip(start) + ", " +
451 template <typename IT> NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const { return start + a * x; }
454 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
485 friend bool operator==(const LinearPeriodicCoordinates1D<NT> &lhs, const LinearPeriodicCoordinates1D<NT2> &rhs)
494 return "LinearPeriodicCoordinates1D(" + std::to_string(grid_extent) + ", " + internal::round_trip(start) + ", " +
528 gem1(grid_extent - 1.), gem1inv(1. / (grid_extent - 1.)), a(bias), b((stop - start) / std::expm1(bias)),
538 : LogarithmicCoordinates1D(LogarithmicCoordinates1D(other.parent_size(), other.start, other.stop, other.bias),
575 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
588 NT KOKKOS_FORCEINLINE_FUNCTION backward_derivative(const NT &y) const { return gem1 / (a * (b + y - c)); }
601 friend bool operator==(const LogarithmicCoordinates1D<NT> &lhs, const LogarithmicCoordinates1D<NT2> &rhs)
611 return "LogarithmicCoordinates1D(" + internal::round_trip(start) + ", " + internal::round_trip(stop) + ", " +
669 FocusedLogCoordinates1D(size_t grid_extent, double start, double stop, double center, double focus)
670 : start(start), stop(stop), center(center), focus(focus), grid_extent(grid_extent), parent_extent(grid_extent)
711 FocusedLogCoordinates1D(other.parent_size(), other.start, other.stop, other.center, other.focus),
752 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
785 friend bool operator==(const FocusedLogCoordinates1D<NT> &lhs, const FocusedLogCoordinates1D<NT2> &rhs)
795 return "FocusedLogCoordinates1D(" + std::to_string(parent_extent) + ", " + internal::round_trip(start) + ", " +
796 internal::round_trip(stop) + ", " + internal::round_trip(center) + ", " + internal::round_trip(focus) +
802 template <typename T> static KOKKOS_FORCEINLINE_FUNCTION T s_of_u(const T u, const T c, const T u0)
812 : start(parent.start), stop(parent.stop), center(parent.center), focus(parent.focus), grid_extent(n),
861 template <typename NT0, typename NT> struct rebind_ctype<LinearPeriodicCoordinates1D<NT0>, NT> {
875 template <typename Coordinates, typename NT> using rebind_ctype_t = typename rebind_ctype<Coordinates, NT>::type;
880 using LogLogCoordinates = CoordinatePackND<LogarithmicCoordinates1D<double>, LogarithmicCoordinates1D<double>>;
881 using LogLinCoordinates = CoordinatePackND<LogarithmicCoordinates1D<double>, LinearCoordinates1D<double>>;
882 using LinLogCoordinates = CoordinatePackND<LinearCoordinates1D<double>, LogarithmicCoordinates1D<double>>;
883 using LinLinCoordinates = CoordinatePackND<LinearCoordinates1D<double>, LinearCoordinates1D<double>>;
885 CoordinatePackND<LogarithmicCoordinates1D<double>, LogarithmicCoordinates1D<double>, LinearCoordinates1D<double>>;
887 CoordinatePackND<LogarithmicCoordinates1D<double>, LinearCoordinates1D<double>, LinearCoordinates1D<double>>;
889 CoordinatePackND<LinearCoordinates1D<double>, LinearCoordinates1D<double>, LinearCoordinates1D<double>>;
893 using FocusedLogLinCoordinates = CoordinatePackND<FocusedLogCoordinates1D<double>, LinearCoordinates1D<double>>;
894 using FocusedLogLinLinCoordinates = CoordinatePackND<FocusedLogCoordinates1D<double>, LinearCoordinates1D<double>,
901 using LogLinLinPeriodicCoordinates = CoordinatePackND<LogarithmicCoordinates1D<double>, LinearCoordinates1D<double>,
Product grid of one-dimensional coordinate systems.
Definition coordinates.hh:94
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, dim > forward(I &&...i) const
The coordinates of the point with indices i (one per axis; may be fractional).
Definition coordinates.hh:128
device::array< size_t, sizeof...(Coordinates)> KOKKOS_INLINE_FUNCTION from_linear_index(size_t s) const
The multi-index of the point with linear index s (row-major, last axis fastest).
Definition coordinates.hh:187
device::array< ctype, sizeof...(I)> KOKKOS_FORCEINLINE_FUNCTION backward_impl(device::integer_sequence< int, Is... >, I &&...i) const
Definition coordinates.hh:155
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Total number of points, the product of the axis sizes.
Definition coordinates.hh:171
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, dim > forward(const device::array< IT, dim > &coords) const
The coordinates of the point with multi-index coords.
Definition coordinates.hh:135
static constexpr size_t dim
Number of axes.
Definition coordinates.hh:108
typename device::tuple_element< i, device::tuple< Coordinates... > >::type coordinate_type
The type of the i-th axis. Used e.g. to query per-axis periodicity, see is_periodic_axis_v.
Definition coordinates.hh:168
std::string to_string() const
"CoordinatePackND(<axis 0>, <axis 1>, ...)"; identifies the grid, e.g. in HDF5 output.
Definition coordinates.hh:215
friend bool operator==(const CoordinatePackND< Coordinates... > &r, const CoordinatePackND< Coordinates2... > &l)
Equal if the axes have the same types and are pairwise equal; false for different axis types.
Definition coordinates.hh:201
const auto & get_coordinates() const
Axis i.
Definition coordinates.hh:162
CoordinatePackND(Coordinates... coordinates)
From the axes.
Definition coordinates.hh:111
CoordinatePackND(const CoordinatePackND< Coordinates2... > &other)
Convert from the same axes in another precision, e.g. float from double.
Definition coordinates.hh:120
device::array< size_t, sizeof...(Coordinates)> KOKKOS_FORCEINLINE_FUNCTION sizes() const
The size of each axis.
Definition coordinates.hh:179
device::array< ctype, dim > KOKKOS_FORCEINLINE_FUNCTION forward_impl(device::integer_sequence< int, Is... >, I &&...i) const
Definition coordinates.hh:141
typename device::tuple_element< 0, device::tuple< Coordinates... > >::type::ctype ctype
Scalar type.
Definition coordinates.hh:106
const device::tuple< Coordinates... > coordinates
Definition coordinates.hh:227
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, sizeof...(I)> backward(I &&...i) const
The (fractional) grid indices of the coordinates i, axis by axis.
Definition coordinates.hh:148
Points on [start, stop] (start > 0), logarithmically spaced and clustered around an interior scale ce...
Definition coordinates.hh:651
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
The multi-index {i} of point i.
Definition coordinates.hh:735
FocusedLogCoordinates1D(const FocusedLogCoordinates1D< NT2 > &other)
Convert from another precision.
Definition coordinates.hh:709
NT KOKKOS_FORCEINLINE_FUNCTION backward_derivative(const NT &y) const
at the coordinate y.
Definition coordinates.hh:766
NT KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
The inverse map: the (fractional) grid index of the coordinate y.
Definition coordinates.hh:758
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Number of points N.
Definition coordinates.hh:775
FocusedLogCoordinates1D prefix(size_t n) const
The first n points of this grid, as a grid of the same type.
Definition coordinates.hh:725
static constexpr size_t dim
One axis.
Definition coordinates.hh:656
friend bool operator==(const FocusedLogCoordinates1D< NT > &lhs, const FocusedLogCoordinates1D< NT2 > &rhs)
Same precision, parameters and number of points (and the same parent, for a prefix).
Definition coordinates.hh:785
std::string to_string() const
"FocusedLogCoordinates1D(N, start, stop, center, focus)"; identifies the grid.
Definition coordinates.hh:793
size_t KOKKOS_FORCEINLINE_FUNCTION parent_size() const
Number of points of the grid this one is a prefix() of; size() unless it is a prefix.
Definition coordinates.hh:732
NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const
The coordinate at grid index x (real values allowed).
Definition coordinates.hh:741
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
As forward(x[0]).
Definition coordinates.hh:752
FocusedLogCoordinates1D(size_t grid_extent, double start, double stop, double center, double focus)
The grid; throws if a parameter is out of range.
Definition coordinates.hh:669
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION sizes() const
{N}.
Definition coordinates.hh:778
Equally spaced points on [start, stop], including both ends.
Definition coordinates.hh:312
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
The multi-index {i} of point i.
Definition coordinates.hh:353
friend bool operator==(const LinearCoordinates1D< NT > &lhs, const LinearCoordinates1D< NT2 > &rhs)
Same precision, parameters and number of points (and the same parent, for a prefix).
Definition coordinates.hh:381
LinearCoordinates1D(const LinearCoordinates1D< NT2 > &other)
Convert from another precision.
Definition coordinates.hh:329
NT KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
The inverse map: the (fractional) grid index of the coordinate y.
Definition coordinates.hh:368
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Number of points N.
Definition coordinates.hh:371
LinearCoordinates1D prefix(size_t n) const
The first n points of this grid, as a grid of the same type.
Definition coordinates.hh:343
std::string to_string() const
"LinearCoordinates1D(N, start, stop)"; identifies the grid, e.g. in HDF5 output.
Definition coordinates.hh:389
LinearCoordinates1D(size_t grid_extent, double start, double stop)
grid_extent points (≥ 2, throws otherwise) from start to stop.
Definition coordinates.hh:320
size_t KOKKOS_FORCEINLINE_FUNCTION parent_size() const
Number of points of the grid this one is a prefix() of; size() unless it is a prefix.
Definition coordinates.hh:350
NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const
The coordinate at grid index x (real values allowed).
Definition coordinates.hh:359
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
As forward(x[0]).
Definition coordinates.hh:362
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION sizes() const
{N}.
Definition coordinates.hh:374
Equally spaced points on a periodic axis of period stop - start; stop itself is excluded.
Definition coordinates.hh:420
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
The multi-index {i} of point i.
Definition coordinates.hh:445
LinearPeriodicCoordinates1D(const LinearPeriodicCoordinates1D< NT2 > &other)
Convert from another precision.
Definition coordinates.hh:439
friend bool operator==(const LinearPeriodicCoordinates1D< NT > &lhs, const LinearPeriodicCoordinates1D< NT2 > &rhs)
Same precision, parameters and number of points.
Definition coordinates.hh:485
NT KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
The inverse map: the (fractional) grid index of the coordinate y, folded into [0, N).
Definition coordinates.hh:462
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Number of points N.
Definition coordinates.hh:475
static constexpr size_t dim
One axis.
Definition coordinates.hh:425
std::string to_string() const
"LinearPeriodicCoordinates1D(N, start, stop)"; identifies the grid.
Definition coordinates.hh:492
LinearPeriodicCoordinates1D(size_t grid_extent, double start, double stop)
grid_extent points (≥ 1, throws otherwise) on the period [start, stop).
Definition coordinates.hh:430
NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const
The coordinate at grid index x (real values allowed).
Definition coordinates.hh:451
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
As forward(x[0]).
Definition coordinates.hh:454
const NT start
Ends of the period.
Definition coordinates.hh:481
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION sizes() const
{N}.
Definition coordinates.hh:478
static constexpr bool periodic
Marks the axis as periodic.
Definition coordinates.hh:427
Points on [start, stop], including both ends, with spacing growing exponentially in the index.
Definition coordinates.hh:517
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
The multi-index {i} of point i.
Definition coordinates.hh:562
LogarithmicCoordinates1D(size_t grid_extent, double start, double stop, double bias)
Definition coordinates.hh:526
friend bool operator==(const LogarithmicCoordinates1D< NT > &lhs, const LogarithmicCoordinates1D< NT2 > &rhs)
Same precision, parameters and number of points (and the same parent, for a prefix).
Definition coordinates.hh:601
LogarithmicCoordinates1D prefix(size_t n) const
The first n points of this grid, as a grid of the same type.
Definition coordinates.hh:552
NT KOKKOS_FORCEINLINE_FUNCTION backward_derivative(const NT &y) const
at the coordinate y.
Definition coordinates.hh:588
NT KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
The inverse map: the (fractional) grid index of the coordinate y.
Definition coordinates.hh:581
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Number of points N.
Definition coordinates.hh:591
static constexpr size_t dim
One axis.
Definition coordinates.hh:522
std::string to_string() const
"LogarithmicCoordinates1D(start, stop, bias, N)"; identifies the grid.
Definition coordinates.hh:609
LogarithmicCoordinates1D(const LogarithmicCoordinates1D< NT2 > &other)
Convert from another precision.
Definition coordinates.hh:537
size_t KOKKOS_FORCEINLINE_FUNCTION parent_size() const
Number of points of the grid this one is a prefix() of; size() unless it is a prefix.
Definition coordinates.hh:559
NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const
The coordinate at grid index x (real values allowed).
Definition coordinates.hh:568
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
As forward(x[0]).
Definition coordinates.hh:575
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION sizes() const
{N}.
Definition coordinates.hh:594
The points with linear indices [offset, offset + size) of another coordinate system Base.
Definition coordinates.hh:244
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, dim > forward(I &&...i) const
Base::forward of the Base indices i.
Definition coordinates.hh:275
SubCoordinates(const Base &base, size_t offset, size_t size)
The window [offset, offset + size) of base; throws if empty or out of range.
Definition coordinates.hh:250
device::array< size_t, dim > KOKKOS_INLINE_FUNCTION from_linear_index(size_t s) const
Base's multi-index of the window's s-th point.
Definition coordinates.hh:267
device::array< size_t, dim > KOKKOS_FORCEINLINE_FUNCTION sizes() const
Per-axis extents; only defined for dim == 1 (a linear window is not a box otherwise).
Definition coordinates.hh:257
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Number of points in the window.
Definition coordinates.hh:264
KOKKOS_INLINE_FUNCTION device::array< ctype, dim > forward(device::array< IT, dim > i) const
Base::forward of a Base multi-index (as returned by from_linear_index()).
Definition coordinates.hh:282
std::string to_string() const
"SubCoordinates(<base>, offset, size)"; identifies the window.
Definition coordinates.hh:290
A coordinate system: a map from grid indices to physical coordinates.
Definition coordinates.hh:29
Execution and memory spaces, and Kokkos helpers.
Definition complex_math.hh:20
constexpr bool is_periodic_axis_v
Whether axis i of a (possibly multi-dimensional) coordinate system is periodic. Falls back to false f...
Definition coordinates.hh:66
auto make_grid(const Coordinates &coordinates)
All grid points, in linear index order, as arrays of dim coordinates.
Definition coordinates.hh:825
std::vector< typename Coordinates::ctype > dump_grid(const Coordinates &coordinates)
All grid points, in linear index order, flattened: point i occupies entries [i dim,...
Definition coordinates.hh:840
constexpr bool is_periodic_coordinate_v
Whether a 1D coordinate class describes a periodic axis, i.e. one where the last grid point is follow...
Definition coordinates.hh:50
typename rebind_ctype< Coordinates, NT >::type rebind_ctype_t
Definition coordinates.hh:875
constexpr void constexpr_for(F &&f)
Compile-time loop: calls f(i) for i = Start, Start + Inc, ... while i < End.
Definition utils.hh:37
The same coordinate system with ctype NT, e.g. the float twin of a double grid: rebind_ctype_t<Coordi...
Definition coordinates.hh:857
Generated by