JuliaRandom / JuliaRandom/RandomNumbers.jl

Generic gen_seed method

Aperta
#36 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Julia
Stelle
100
Fork
23
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I see that `gen_seed` is a common function for all RNGs in `RandomNumbers`. It would be useful to able to call `gen_seed(rng)` and have it return the appropriately sized tuple for that rng. This could make code more generic.
I can't see whether this is currently possible. My workaround has been:

```
Base.length(::Type{NTuple{N,T}}) where {N,T} = N
seed_length(rng) = length(seed_type(rng))
gen_seed(rng::RandomNumbers.AbstractRNG) = gen_seed(output_type(rng), seed_length(rng))
```

Not sure if `Base.length` is the right function to extend here, or if there already exists a function for this.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.