sarcomp.mul#
- sarcomp.mul(array0: ndarray | Array, array1: ndarray | Array, new=False) Array #
Element-wise multiplication of two arrays.
This function performs element-wise multiplication of two input arrays, which can be numpy ndarrays or instances of the custom Array class. If both inputs are numpy ndarrays, the output will be a numpy ndarray. If at least one input is an instance of the custom Array class, the output will be an instance of the custom Array class. If new is set to True, a new array is returned, leaving the original arrays unchanged. Otherwise, the result is stored in array0.
- Parameters:
array0 (Union[np.ndarray, Array]) – The first input array.
array1 (Union[np.ndarray, Array]) – The second input array.
new (bool, optional) – If True, returns a new array without modifying the original input arrays. Default is False.
- Returns:
An array containing the element-wise product of array0 and array1.
- Return type:
Array
- Raises:
ValueError – If the shapes of the input arrays are not compatible for element-wise multiplication.
Examples
>>> import numpy as np >>> import sarcomp as sc
>>> np_array0 = np.array([2, 3, 4]).astype('f4') >>> np_array1 = np.array([5, 6, 7]).astype('f4') >>> result = sc.mul(np_array0, np_array1)
Notes
The shapes of the input arrays must be compatible for element-wise multiplication.