Random functions#
- lazylinop.wip.random.rand(shape, dtype='float', seed=None, mode='scalar', bsize=1)[source]#
Returns a new
LazyLinOpof random entries (uniform distribution into[0, 1)).Free memory cost
Whatever is the shape of the
rand, it has no memory cost if'scalar'mode is used.- Args:
- shape: (
tuple[int, int]) Shape of the random
LazyLinOp.- dtype: (
str) numpy dtype of the random
LazyLinOp.- mode: (
str) 'scalar': uses only random scalars, one by one to compute the multiplication. Memory cost: one scalar.'vector': uses only a random vectors, one by one to compute the multiplication. Memory cost: one vector of sizeshape[1].'block': computes the multiplication by generating blocks of random values (one by one). The size of each block is max(bsize, shape[1]).'array': uses a full array of random entries of dimensionsshapeto compute the multiplication. Memory cost: array of dimensionsshape.
- seed: (
int) Seed for initialization of the numpy PRNG (Mersenne Twister).
- shape: (
- Example:
>>> from lazylinop import rand >>> lr = rand((4, 5), seed=42) >>> lr.toarray() array([[0.54199389, 0.61966721, 0.05736978, 0.81190365, 0.86009402], [0.62760232, 0.68193335, 0.67527253, 0.48076406, 0.73472516], [0.15634112, 0.72853736, 0.21693909, 0.7016948 , 0.96408854], [0.27678254, 0.70566135, 0.88665806, 0.61825175, 0.97278719]])
- Returns:
The random
LazyLinOp.
version 1.24.19 documentation