mtalg.add

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

Add 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

Add b to a; 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.add(a, b, direction='left')

Add a to b; b is modified in-place.

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

Add a to b using 4 threads.

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