Universal Functions (ufunc)
DPNP provides universal functions (a.k.a. ufuncs) to support various element-wise operations.
Available ufuncs
Math operations
Calculates the sum for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the difference for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the product for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Matrix product of two arrays. |
|
Calculates the ratio for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the natural logarithm of the sum of exponentiations \(\log(e^{x1} + e^{x2})\) for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the base-2 logarithm of the sum of exponentiations \(\log_2(2^{x1} + 2^{x2})\) for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the ratio for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Rounds the result of dividing each element \(x1_i\) of the input array x1 by the respective element \(x2_i\) of the input array x2 to the greatest (i.e., closest to |
|
Computes the numerical negative of each element \(x_i\) (i.e., \(y_i = -x_i\)) of the input array x. |
|
Computes the numerical positive of each element \(x_i\) (i.e., \(y_i = +x_i\)) of the input array x. |
|
Calculates \(x1_i\) raised to \(x2_i\) for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates \(x1_i\) raised to \(x2_i\) for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates \(x1_i\) raised to \(x2_i\) for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the remainder of division for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the remainder of division for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the remainder of division for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the absolute value for each element \(x_i\) of input array x. |
|
Compute the absolute values element-wise. |
|
Rounds each element \(x_i\) of the input array x to the nearest integer-valued number. |
|
Returns an indication of the sign of a number for each element \(x_i\) of the input array x. |
|
Compute the Heaviside step function. |
|
Returns the complex conjugate for each element \(x_i\) of the input array x. |
|
Returns the complex conjugate for each element \(x_i\) of the input array x. |
|
Computes the exponential for each element \(x_i\) of input array x. |
|
Computes the base-2 exponential for each element \(x_i\) for input array x. |
|
Computes the natural logarithm for each element \(x_i\) of input array x. |
|
Computes the base-2 logarithm for each element \(x_i\) of input array x. |
|
Computes the base-10 logarithm for each element \(x_i\) of input array x. |
|
Computes the exponential minus |
|
Computes the natural logarithm of (1 + x) for each element \(x_i\) of input array x. |
|
Computes the complex projection of each element \(x_i\) for input array x. |
|
Computes the principal square-root for each element \(x_i\) of input array x. |
|
Squares each element \(x_i\) of input array x. |
|
Computes the cube-root for each element \(x_i\) for input array x. |
|
Computes the reciprocal for each element \(x_i\) for input array x. |
|
Computes the reciprocal square-root for each element \(x_i\) for input array x. |
|
Returns the greatest common divisor of \(\abs{x1}\) and \(\abs{x2}\). |
|
Returns the lowest common multiple of \(\abs{x1}\) and \(\abs{x2}\). |
Tip
The optional output arguments can be used to help you save memory
for large calculations. If your arrays are large, complicated
expressions can take longer than absolutely necessary due to the
creation and (later) destruction of temporary calculation
spaces. For example, the expression G = A * B + C
is equivalent to
T1 = A * B; G = T1 + C; del T1
. It will be more quickly executed
as G = A * B; add(G, C, G)
which is the same as
G = A * B; G += C
.
Trigonometric functions
All trigonometric functions use radians when an angle is called for. The ratio of degrees to radians is \(180^{\circ}/\pi.\)
Computes the sine for each element \(x_i\) of input array x. |
|
Computes the cosine for each element \(x_i\) for input array x. |
|
Computes the tangent for each element \(x_i\) for input array x. |
|
Computes inverse sine for each element \(x_i\) for input array x. |
|
Computes inverse sine for each element \(x_i\) for input array x. |
|
Computes inverse cosine for each element \(x_i\) for input array x. |
|
Computes inverse cosine for each element \(x_i\) for input array x. |
|
Computes inverse tangent for each element \(x_i\) for input array x. |
|
Computes inverse tangent for each element \(x_i\) for input array x. |
|
Calculates the inverse tangent of the quotient \(\frac{x1_i}{x2_i}\) for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates the inverse tangent of the quotient \(\frac{x1_i}{x2_i}\) for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the square root of the sum of squares for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the hyperbolic sine for each element \(x_i\) for input array x. |
|
Computes the hyperbolic cosine for each element \(x_i\) for input array x. |
|
Computes the hyperbolic tangent for each element \(x_i\) for input array x. |
|
Computes inverse hyperbolic sine for each element \(x_i\) for input array x. |
|
Computes inverse hyperbolic sine for each element \(x_i\) for input array x. |
|
Computes inverse hyperbolic cosine for each element \(x_i\) for input array x. |
|
Computes inverse hyperbolic cosine for each element \(x_i\) for input array x. |
|
Computes hyperbolic inverse tangent for each element \(x_i\) for input array x. |
|
Computes hyperbolic inverse tangent for each element \(x_i\) for input array x. |
|
Convert angles from radian to degrees for each element \(x_i\) for input array x. |
|
Convert angles from degrees to radians for each element \(x_i\) for input array x. |
|
Convert angles from degrees to radians for each element \(x_i\) for input array x. |
|
Convert angles from radians to degrees for each element \(x_i\) for input array x. |
Bit-twiddling functions
Computes the bitwise AND of the underlying binary representation of each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Inverts (flips) each bit for each element \(x_i\) of the input array x. |
|
Computes the bitwise OR of the underlying binary representation of each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the bitwise XOR of the underlying binary representation of each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Inverts (flips) each bit for each element \(x_i\) of the input array x. |
|
Inverts (flips) each bit for each element \(x_i\) of the input array x. |
|
Shifts the bits of each element \(x1_i\) of the input array x1 to the left by appending \(x2_i\) (i.e., the respective element in the input array x2) zeros to the right of \(x1_i\). |
|
Shifts the bits of each element \(x1_i\) of the input array x1 to the left by appending \(x2_i\) (i.e., the respective element in the input array x2) zeros to the right of \(x1_i\). |
|
Shifts the bits of each element \(x1_i\) of the input array x1 to the right according to the respective element \(x2_i\) of the input array x2. |
|
Shifts the bits of each element \(x1_i\) of the input array x1 to the right according to the respective element \(x2_i\) of the input array x2. |
|
Computes the number of 1-bits in the absolute value of x. |
Comparison functions
Computes the greater-than test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the greater-than or equal-to test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the less-than test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the less-than or equal-to test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates inequality test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Calculates equality test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the logical AND for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the logical OR for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the logical XOR for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Computes the logical NOT for each element \(x_i\) of input array x. |
|
Computes the maximum value for each element \(x1_i\) of the input array x1 relative to the respective element \(x2_i\) of the input array x2. |
|
Computes the minimum value for each element \(x1_i\) of the input array x1 relative to the respective element \(x2_i\) of the input array x2. |
|
Compares two input arrays x1 and x2 and returns a new array containing the element-wise maxima. |
|
Compares two input arrays x1 and x2 and returns a new array containing the element-wise minima. |
Floating functions
Test each element \(x_i\) of the input array x to determine if finite. |
|
Tests each element \(x_i\) of the input array x to determine if equal to positive or negative infinity. |
|
Tests each element \(x_i\) of the input array x to determine whether the element is |
|
Compute the absolute values element-wise. |
|
Determines whether the sign bit is set for each element \(x_i\) of the input array x. |
|
Composes a floating-point value with the magnitude of \(x1_i\) and the sign of \(x2_i\) for each element of the input array x1. |
|
Return the next floating-point value after x1 towards x2, element-wise. |
|
Return the distance between x and the nearest adjacent number. |
|
Return the fractional and integral parts of an array, element-wise. |
|
Returns \(x1 * 2^{x2}\), element-wise. |
|
Calculates the remainder of division for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2. |
|
Returns the floor for each element \(x_i\) for input array x. |
|
Returns the ceiling for each element \(x_i\) for input array x. |
|
Returns the truncated value for each element \(x_i\) for input array x. |