sarcomp.sqrt#

sarcomp.sqrt(array: ndarray | Array, new=False, method='ac') Array#

Compute the element-wise square root of the input array using the specified method.

Parameters:
  • array (Union[np.ndarray, Array]) – The input array, which can be a NumPy ndarray or an instance of the custom Array class.

  • new (bool, optional) – If True, returns a new array without modifying the original input arrays. Default is False.

  • method (str, optional) –

    The method used for calculating the square root. Options are: The method used for calculating the absolute value. Applicable only for complex and split-complex types:

    • ’ac’: Accurate (default). Calculates the absolute value with full precision.

    • ’ap’: Approximate. Uses SIMD rsqrt for fast but less accurate results.

    • ’nr’: Newton-Raphson. Refines rsqrt for improved accuracy.

Returns:

A new Array instance containing the element-wise square root of the input array.

Return type:

Array

Raises:
  • ValueError – If the specified method is not supported.

  • KeyError – If the specified conversion function is not found in the functions dictionary.

Examples

>>> import numpy as np
>>> import sarcomp as sc
>>> np_array = np.array([1.0, 4.0, 9.0], dtype=np.float32)
>>> result = sc.sqrt(np_array, method='nr')