mtalg.sub
- sub(a: ndarray | Number, b: ndarray | Number, num_threads: int | None = None, direction: str = 'left')[source]
Subtract 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
Subtract b from 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.sub(a, b, direction='left')
Subtract a from b; b is modified in-place.
>>> mtalg.sub(a, b, direction='right')
Subtract a from b using 4 threads.
>>> mtalg.sub(a, b, num_threads=4, direction='right')