Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorized RNG repeats values with nested arrays #130

Open
sweeneychris opened this issue Feb 1, 2023 · 0 comments
Open

Vectorized RNG repeats values with nested arrays #130

sweeneychris opened this issue Feb 1, 2023 · 0 comments

Comments

@sweeneychris
Copy link

I am trying to initialize a non-square matrix (i.e. a nested array) using Enoki's RNG. When I run the following code, I notice that the values are repeated across the array.

  using FloatP = enoki::Packet<enoki::Array<float, 3>, 2>;
  using RNG_2x3 = enoki::PCG32<FloatP>;

  RNG_2x3 my_rng;
  FloatP value = my_rng.next_float32();
  std::cout << "RNG VALUE:\n" << value << std::endl;

This gives the output:

RNG VALUE:
[[0.108379, 0.158414],
 [0.108379, 0.158414],
 [0.108379, 0.158414]]

So it appears that the RNG is only working on the outer dimension and is copying values to the other dimensions. Is there a way to use a single RNG to initialize random values for each element of a nested loop? Of course it is possible to do this with an explicit for loop, but I was curious if there is a way in the API to do this in one call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant