Universal Functions (ufunc)

DPNP provides universal functions (a.k.a. ufuncs) to support various element-wise operations.

Available ufuncs

Math operations

dpnp.add

Calculates the sum for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.

dpnp.subtract

Calculates the difference between each element x1_i of the input array x1 and the respective element x2_i of the input array x2.

dpnp.multiply

Calculates the product for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.

dpnp.matmul

Matrix product of two arrays.

dpnp.divide

Calculates the ratio for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.

dpnp.logaddexp

Calculates the natural logarithm of the sum of exponents for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.

dpnp.logaddexp2

Calculates the logarithm of the sum of exponents in base-2 for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.

dpnp.true_divide

Calculates the ratio for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.

dpnp.floor_divide

Calculates the ratio for each element x1_i of the input array x1 with the respective element x2_i of the input array x2 to the greatest integer-value number that is not greater than the division result.

dpnp.negative

Computes the numerical negative for each element x_i of input array x.

dpnp.positive

Computes the numerical positive for each element x_i of input array x.

dpnp.power

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.

dpnp.pow

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.

dpnp.float_power

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.

dpnp.remainder

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.

dpnp.mod

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.

dpnp.fmod

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.

dpnp.absolute

Calculates the absolute value for each element x_i of input array x.

dpnp.fabs

Compute the absolute values element-wise.

dpnp.rint

Rounds each element x_i of the input array x to the nearest integer-valued number.

dpnp.sign

Computes an indication of the sign of each element x_i of input array x using the signum function.

dpnp.heaviside

Compute the Heaviside step function.

dpnp.conj

Computes conjugate of each element x_i for input array x.

dpnp.conjugate

Computes conjugate of each element x_i for input array x.

dpnp.exp

Computes the exponent for each element x_i of input array x.

dpnp.exp2

Computes the base-2 exponent for each element x_i for input array x.

dpnp.log

Computes the natural logarithm for each element x_i of input array x.

dpnp.log2

Computes the base-2 logarithm for each element x_i of input array x.

dpnp.log10

Computes the base-10 logarithm for each element x_i of input array x.

dpnp.expm1

Computes the exponent minus 1 for each element x_i of input array x.

dpnp.log1p

Computes the natural logarithm of (1 + x) for each element x_i of input array x.

dpnp.proj

Computes projection of each element x_i for input array x.

dpnp.sqrt

Computes the positive square-root for each element x_i of input array x.

dpnp.square

Squares each element x_i of input array x.

dpnp.cbrt

Computes positive cube-root for each element x_i for input array x.

dpnp.reciprocal

Computes the reciprocal square-root for each element x_i for input array x.

dpnp.rsqrt

Computes the reciprocal square-root for each element x_i for input array x.

dpnp.gcd

Returns the greatest common divisor of |x1| and |x2|.

dpnp.lcm

Returns the lowest common multiple of |x1| and |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.\)

dpnp.sin

Computes sine for each element x_i of input array x.

dpnp.cos

Computes cosine for each element x_i for input array x.

dpnp.tan

Computes tangent for each element x_i for input array x.

dpnp.arcsin

Computes inverse sine for each element x_i for input array x.

dpnp.asin

Computes inverse sine for each element x_i for input array x.

dpnp.arccos

Computes inverse cosine for each element x_i for input array x.

dpnp.acos

Computes inverse cosine for each element x_i for input array x.

dpnp.arctan

Computes inverse tangent for each element x_i for input array x.

dpnp.atan

Computes inverse tangent for each element x_i for input array x.

dpnp.arctan2

Calculates the inverse tangent of the quotient 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.

dpnp.atan2

Calculates the inverse tangent of the quotient 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.

dpnp.hypot

Calculates the hypotenuse for a right triangle with "legs" x1_i and x2_i of input arrays x1 and x2.

dpnp.sinh

Computes hyperbolic sine for each element x_i for input array x.

dpnp.cosh

Computes hyperbolic cosine for each element x_i for input array x.

dpnp.tanh

Computes hyperbolic tangent for each element x_i for input array x.

dpnp.arcsinh

Computes inverse hyperbolic sine for each element x_i for input array x.

dpnp.asinh

Computes inverse hyperbolic sine for each element x_i for input array x.

dpnp.arccosh

Computes inverse hyperbolic cosine for each element x_i for input array x.

dpnp.acosh

Computes inverse hyperbolic cosine for each element x_i for input array x.

dpnp.arctanh

Computes hyperbolic inverse tangent for each element x_i for input array x.

dpnp.atanh

Computes hyperbolic inverse tangent for each element x_i for input array x.

dpnp.degrees

Convert angles from radians to degrees.

dpnp.radians

Convert angles from degrees to radians.

dpnp.deg2rad

Convert angles from degrees to radians.

dpnp.rad2deg

Convert angles from radians to degrees.

Bit-twiddling functions

dpnp.bitwise_and

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.

dpnp.bitwise_not

Inverts (flips) each bit for each element x_i of the input array x.

dpnp.bitwise_or

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.

dpnp.bitwise_xor

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.

dpnp.invert

Inverts (flips) each bit for each element x_i of the input array x.

dpnp.bitwise_invert

Inverts (flips) each bit for each element x_i of the input array x.

dpnp.left_shift

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.

dpnp.bitwise_left_shift

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.

dpnp.right_shift

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.

dpnp.bitwise_right_shift

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.

Comparison functions

dpnp.greater

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.

dpnp.greater_equal

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.

dpnp.less

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.

dpnp.less_equal

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.

dpnp.not_equal

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.

dpnp.equal

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.

dpnp.logical_and

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.

dpnp.logical_or

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.

dpnp.logical_xor

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.

dpnp.logical_not

Computes the logical NOT for each element x_i of input array x.

dpnp.maximum

Compares two input arrays x1 and x2 and returns a new array containing the element-wise maxima.

dpnp.minimum

Compares two input arrays x1 and x2 and returns a new array containing the element-wise minima.

dpnp.fmax

Compares two input arrays x1 and x2 and returns a new array containing the element-wise maxima.

dpnp.fmin

Compares two input arrays x1 and x2 and returns a new array containing the element-wise minima.

Floating functions

dpnp.isfinite

Test if each element of input array is a finite number.

dpnp.isinf

Test if each element of input array is an infinity.

dpnp.isnan

Test if each element of an input array is a NaN.

dpnp.fabs

Compute the absolute values element-wise.

dpnp.signbit

Computes an indication of whether the sign bit of each element x_i of input array x is set.

dpnp.copysign

Composes a floating-point value with the magnitude of x1_i and the sign of x2_i for each element of input arrays x1 and x2.

dpnp.nextafter

Return the next floating-point value after x1 towards x2, element-wise.

dpnp.spacing

Return the distance between x and the nearest adjacent number.

dpnp.modf

Return the fractional and integral parts of an array, element-wise.

dpnp.ldexp

Returns x1 * 2**x2, element-wise.

dpnp.fmod

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.

dpnp.floor

Returns the floor for each element x_i for input array x.

dpnp.ceil

Returns the ceiling for each element x_i for input array x.

dpnp.trunc

Returns the truncated value for each element x_i for input array x.