ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
make_lin_space.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2019-2022 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ESPResSo is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <algorithm>
23
#include <cstddef>
24
#include <ranges>
25
26
namespace
Utils
{
27
/**
28
* @brief Equally spaced values in interval
29
*
30
* Returns a range of equally spaced values in
31
* the range @p start to @p stop, like @c numpy.linspace().
32
*
33
* @tparam T floating point type
34
* @param start Start value of the interval
35
* @param stop End value of the interval
36
* @param number Number of partition points
37
* @param endpoint If true, the last point is @p stop.
38
* @return Range of equally-spaced values
39
*/
40
template
<
class
T>
41
auto
make_lin_space
(T start, T stop, std::size_t
number
,
bool
endpoint
=
true
) {
42
auto
const
dx
= (stop - start) / T(
number
-
endpoint
);
43
44
return
std::ranges::views::transform(
45
std::views::iota(std::size_t{0
u
},
number
),
46
[
dx
, start](std::size_t i) {
return
start + T(i) *
dx
; });
47
}
48
}
// namespace Utils
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
Utils
Definition
Variant.hpp:43
Utils::make_lin_space
auto make_lin_space(T start, T stop, std::size_t number, bool endpoint=true)
Equally spaced values in interval.
Definition
make_lin_space.hpp:41
src
utils
include
utils
math
make_lin_space.hpp
Generated on Mon Dec 8 2025 02:32:30 for ESPResSo by
1.9.8