stdgpu/numeric.h Source File

stdgpu/numeric.h Source File#

stdgpu: stdgpu/numeric.h Source File
stdgpu Latest
Efficient STL-like Data Structures on the GPU
numeric.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Patrick Stotko
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef STDGPU_NUMERIC_H
17#define STDGPU_NUMERIC_H
18
28#include <stdgpu/execution.h>
29
30namespace stdgpu
31{
32
44template <typename ExecutionPolicy,
45 typename Iterator,
46 typename T,
47 STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v<remove_cvref_t<ExecutionPolicy>>)>
48void
49iota(ExecutionPolicy&& policy, Iterator begin, Iterator end, T value);
50
65template <typename IndexType,
66 typename ExecutionPolicy,
67 typename T,
68 typename BinaryFunction,
69 typename UnaryFunction,
70 STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v<remove_cvref_t<ExecutionPolicy>>)>
71T
72transform_reduce_index(ExecutionPolicy&& policy, IndexType size, T init, BinaryFunction reduce, UnaryFunction f);
73
74} // namespace stdgpu
75
76#include <stdgpu/impl/numeric_detail.h>
77
78#endif // STDGPU_NUMERIC_H
index64_t size(T *array)
Finds the size (number of elements) of the given dynamically allocated array.
T transform_reduce_index(ExecutionPolicy &&policy, IndexType size, T init, BinaryFunction reduce, UnaryFunction f)
Calls the given unary function with an index from the range [0, size) and performs a reduction afterw...
void iota(ExecutionPolicy &&policy, Iterator begin, Iterator end, T value)
Writes ascending values {values + i} to the i-th position of the given range.