cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
utility.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef cMHN_UTILITY_UTILITY_H
4#define cMHN_UTILITY_UTILITY_H
5
6#include <prc.hpp>
7#include <random>
8
9namespace cMHN
10{
17 template<class S>
18 static inline auto getRandomSubscripts()
19 {
20 // rng setup
21 std::random_device rd;
22 std::mt19937 rng(rd());
23
24 S result;
25 for(pRC::Index i = 0; i < S::Dimension; ++i)
26 {
27 std::uniform_int_distribution dist(pRC::Index(0), S::size(i) - 1);
28 result[i] = dist(rng);
29 }
30 return result;
31 }
32}
33
34#endif // cMHN_UTILITY_UTILITY_H
TN::Subscripts S
Definition externs_nonTT.hpp:9
int i
Definition gmock-matchers-comparisons_test.cc:603
Definition calculate_pTheta.hpp:20
static auto getRandomSubscripts()
Generates a uniformly distributed random Subscripts element for a Tensor or a TT.
Definition utility.hpp:18
Size Index
Definition basics.hpp:32