Line data Source code
1 : // SPDX-License-Identifier: BSD-3-Clause 2 : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp) 3 : /// @file 4 : /// @author Simon Heybrock 5 : #pragma once 6 : 7 : #include "scipp/common/overloaded.h" 8 : #include "scipp/core/element/arg_list.h" 9 : #include "scipp/core/transform_common.h" 10 : 11 : namespace scipp::core::element { 12 : 13 : // Cannot support variances since transform copies value and variance into 14 : // ValueAndVariance before calling the functor. Only the *first* arg in an 15 : // in-place transform is copied back to the input. 16 : constexpr auto exclusive_scan = overloaded{ 17 : arg_list<double, std::tuple<double, float>, int64_t, int32_t>, 18 : transform_flags::expect_no_variance_arg<0>, 19 10926943 : transform_flags::expect_no_variance_arg<1>, [](auto &sum, auto &x) { 20 10926943 : sum += x; 21 10926943 : x = sum - x; 22 10926943 : }}; 23 : 24 : constexpr auto inclusive_scan = overloaded{ 25 : arg_list<double, std::tuple<double, float>, int64_t, int32_t>, 26 : transform_flags::expect_no_variance_arg<0>, 27 15281985 : transform_flags::expect_no_variance_arg<1>, [](auto &sum, auto &x) { 28 15281985 : sum += x; 29 15281985 : x = sum; 30 15281985 : }}; 31 : 32 : } // namespace scipp::core::element