mtalg.div

div(a: ndarray | Number, b: ndarray | Number, num_threads: int | None = None, direction: str = 'left')[source]

Divide multithreaded.

Modifies a or b in-place depending on the direction.

Parameters:
  • a – Numpy array or scalar.

  • b – Numpy array or scalar.

  • num_threads – Number of threads to be used, overrides threads as set by set_num_threads().

  • direction – ‘left’ or ‘right’ to decide if a or b is modified.

Examples

Divide a by b; a is modified in-place.

>>> a = mtalg.random.standard_normal(size=(10_000, 5_000))
>>> b = mtalg.random.uniform(size=(10_000, 5_000), low=0, high=10)
>>> mtalg.div(a, b, direction='left')

Divide b by a; b is modified in-place.

>>> mtalg.div(a, b, direction='right')

Divide b by a using 4 threads.

>>> mtalg.div(a, b, num_threads=4, direction='right')