// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto.  Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#include <OgnPartialSumDatabase.h>
#include <numeric>

class OgnPartialSum
{
public:
    static bool compute(OgnPartialSumDatabase& db)
    {
        auto inputs = db.inputs.array();
        auto outputs = db.outputs.partialSum();
        outputs.resize(inputs.size() + 1);
        outputs[0] = 0;
        std::partial_sum(inputs.begin(), inputs.end(), outputs.begin() + 1);
        return true;
    }
};

REGISTER_OGN_NODE()
