inducer / inducer/pyopencl

Fill struct with random values

Open
#334 1 comment 0 reactions 0 assignees View on GitHub
enhancement seeking-patch
Dominant language
Python
Stars
1.2k
Forks
247
Avg merge
7h 2m
Merged PRs (30d)
6

Description

Is it possible to fill a custom struct (or an array of custom structs) with random values after I have registered its type?
For a "primitive" type, I can to it like this:
```
from pyopencl.clrandom import rand as clrand
import pyopencl.cltypes as cltypes

a = clrand(queue, (1024,), dtype=cltypes.float, a=-10.0, b=10.0)
```
It even works for vector types:
```
a = clrand(queue, (1024,), dtype=cltypes.float4, a=-10.0, b=10.0)
```
Is there a way to do it for structs? E.g. if I have a struct with an int16 and a float32, I would expect a similar syntax to create such random structs, where each struct in the array has been initialized recursively, using the respective RNG of the "primitive" types that constitute the struct type.

I am extremely sorry in advance in case I missed something from the documentation and/or the examples and tests.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.