0

I have a raw array from a low-level library double[] a of known size.

This array is in fact filled with subarrays of same size, i.e. a == [p0[n], p1[n], ... pM[n]]. I need to shuffle the subarrays, i.e. to make a permutation of p0[n], ..., pM[n]. For this I can use std::random_shuffle, but I have to cast the raw array to an array, where each element has sizeof(p) == n * sizeof(double). The n is defined by a variable and not compile-time known.

How would I do that or is it possible at all?

Alexey S. Larionov
  • 6,555
  • 1
  • 18
  • 37
  • 1
    You need to convert every C-subarray to std::array, like [here](https://stackoverflow.com/q/26219721/3871028) – Ripi2 Apr 07 '20 at 18:36
  • @Ripi2 thanks for the reply, but I decided to write a simple Fisher–Yates shuffle with `std::swap_ranges` on the raw array, which is easier than implementing my own random access iterator – Alexey S. Larionov Apr 07 '20 at 20:01

0 Answers0