/*
**************************************************************
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 19 *
* Author: Arash Partow (1999-2025) *
* URL: https://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
* Free use of the Mathematical Expression Toolkit Library is *
* permitted under the guidelines and in accordance with the *
* most current version of the MIT License. *
* https://www.opensource.org/licenses/MIT *
* SPDX-License-Identifier: MIT *
* *
**************************************************************
*/
#include
#include
#include
#include
#include "exprtk.hpp"
template
class randu : public exprtk::igeneric_function
{
public:
typedef typename exprtk::igeneric_function igfun_t;
typedef typename igfun_t::parameter_list_t parameter_list_t;
typedef typename igfun_t::generic_type generic_type;
typedef typename generic_type::vector_view vector_t;
using exprtk::igeneric_function::operator();
randu()
: exprtk::igeneric_function("V|VTT")
/*
Overloads:
0. V - vector
1. VTT - vector, r0, r1
*/
{ ::srand(static_cast(time(NULL))); }
inline T operator()(const std::size_t& ps_index, parameter_list_t parameters)
{
vector_t v(parameters[0]);
std::size_t r0 = 0;
std::size_t r1 = v.size() - 1;
using namespace exprtk::rtl::vecops::helper;
if (
(1 == ps_index) &&
!load_vector_range::process(parameters, r0, r1, 1, 2, 0)
)
return T(0);
for (std::size_t i = r0; i