Mojo-Numerics-and-Algorithms-group / NuMojo

NuMojo is a library for numerical computing in Mojo 🔥 similar to numpy in Python.
Apache License 2.0
112 stars 15 forks source link

Add NDArray initialization with random values in an specified interval #88

Closed mmenendezg closed 3 months ago

mmenendezg commented 3 months ago

Add the option to initialize a NDArray with random values between min and max values with the following syntax:

import numojo as nm
fn main() raises:
    var A = nm.NDArray[DType.float16](List[Int](2, 2), min=0.0, max=10.0)
    print(A)

[Output]:

[[  7.515625    8.25    ]
 [  7.53125 3.19140625  ]]
2-D array  Shape: [2, 2]  DType: float16