26 auto c1 =
Take(v1, idx[0]);
27 auto c2 =
Take(v2, idx[1]);
32 std::cout <<
"Combinations of " << v1 <<
" and " << v2 <<
":" << std::endl;
33 for(
size_t i=0; i<v3.size(); i++) {
34 std::cout <<
c1[i] <<
" * " <<
c2[i] <<
" = " << v3[i] << std::endl;
36 std::cout << std::endl;
46 auto c3 =
Take(v4, idx2[0]);
47 auto c4 =
Take(v4, idx2[1]);
48 auto c5 =
Take(v4, idx2[2]);
50 auto v5 =
c3 * c4 * c5;
52 std::cout <<
"Unique triples of " << v4 <<
":" << std::endl;
53 for(
size_t i=0; i<v4.size(); i++) {
54 std::cout <<
c3[i] <<
" * " << c4[i] <<
" * " << c5[i] <<
" = " << v5[i] << std::endl;
56 std::cout << std::endl;
A "std::vector"-like collection of values implementing handy operation to analyse them.
RVec< RVec< typename RVec< T1 >::size_type > > Combinations(const RVec< T1 > &v1, const RVec< T2 > &v2)
Return the indices that represent all combinations of the elements of two RVecs.
RVec< T > Take(const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i)
Return elements of a vector at given indices.