Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
linspace.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
21#include "shambackends/vec.hpp"
23
24namespace shamalgs::primitives {
25
36 template<typename Tval>
37 sham::DeviceBuffer<Tval> linspace(Tval Rmin, Tval Rmax, u32 N) {
38 sham::DeviceBuffer<Tval> bins(N, shamsys::instance::get_compute_scheduler_ptr());
39 Tval step = (Rmax - Rmin) / (N - 1);
40 for (int i = 0; i < N; ++i) {
41 bins.set_val_at_idx(i, Rmin + i * step);
42 }
43 return bins;
44 }
45
46} // namespace shamalgs::primitives
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
namespace for primitive algorithm (e.g. sort, scan, reductions, ...)
sham::DeviceBuffer< Tval > linspace(Tval Rmin, Tval Rmax, u32 N)
Create an array of N values between two values.
Definition linspace.hpp:37