dpnp icon indicating copy to clipboard operation
dpnp copied to clipboard

Mathematical functions

Open shssf opened this issue 5 years ago • 7 comments

Need to implement following function in mathematical module

Trigonometric functions

  • [x] sin(x, /[, out, where, casting, order, ...]) Trigonometric sine, element-wise.
  • [x] cos(x, /[, out, where, casting, order, ...]) Cosine element-wise.
  • [x] tan(x, /[, out, where, casting, order, ...]) Compute tangent element-wise.
  • [x] arcsin(x, /[, out, where, casting, order, ...]) Inverse sine, element-wise.
  • [x] arccos(x, /[, out, where, casting, order, ...]) Trigonometric inverse cosine, element-wise.
  • [x] arctan(x, /[, out, where, casting, order, ...]) Trigonometric inverse tangent, element-wise.
  • [x] hypot(x1, x2, /[, out, where, casting, ...]) Given the “legs” of a right triangle, return its hypotenuse.
  • [x] arctan2(x1, x2, /[, out, where, casting, ...]) Element-wise arc tangent of x1/x2 choosing the quadrant correctly.
  • [x] degrees(x, /[, out, where, casting, order, ...]) Convert angles from radians to degrees.
  • [x] radians(x, /[, out, where, casting, order, ...]) Convert angles from degrees to radians.
  • [x] unwrap(p[, discont, axis]) Unwrap by changing deltas between values to 2*pi complement.
  • [x] deg2rad(x, /[, out, where, casting, order, ...]) Convert angles from degrees to radians.
  • [x] rad2deg(x, /[, out, where, casting, order, ...]) Convert angles from radians to degrees.

Hyperbolic functions

  • [x] sinh(x, /[, out, where, casting, order, ...]) Hyperbolic sine, element-wise.
  • [x] cosh(x, /[, out, where, casting, order, ...]) Hyperbolic cosine, element-wise.
  • [x] tanh(x, /[, out, where, casting, order, ...]) Compute hyperbolic tangent element-wise.
  • [x] arcsinh(x, /[, out, where, casting, order, ...]) Inverse hyperbolic sine element-wise.
  • [x] arccosh(x, /[, out, where, casting, order, ...]) Inverse hyperbolic cosine, element-wise.
  • [x] arctanh(x, /[, out, where, casting, order, ...]) Inverse hyperbolic tangent element-wise.

Rounding

  • [x] around(a[, decimals, out]) Evenly round to the given number of decimals.
  • [x] round_(a[, decimals, out]) Round an array to the given number of decimals.
  • [x] rint(x, /[, out, where, casting, order, ...]) Round elements of the array to the nearest integer.
  • [ ] fix(x[, out]) Round to nearest integer towards zero.
  • [x] floor(x, /[, out, where, casting, order, ...]) Return the floor of the input, element-wise.
  • [x] ceil(x, /[, out, where, casting, order, ...]) Return the ceiling of the input, element-wise.
  • [x] trunc(x, /[, out, where, casting, order, ...]) Return the truncated value of the input, element-wise.

Sums, products, differences

  • [x] prod(a[, axis, dtype, out, keepdims]) Return the product of array elements over a given axis.
  • [x] sum(a[, axis, dtype, out, keepdims]) Sum of array elements over a given axis.
  • [x] nanprod(a[, axis, dtype, out, keepdims]) Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.
  • [x] nansum(a[, axis, dtype, out, keepdims]) Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.
  • [x] cumprod(a[, axis, dtype, out]) Return the cumulative product of elements along a given axis.
  • [x] cumsum(a[, axis, dtype, out]) Return the cumulative sum of the elements along a given axis.
  • [x] nancumprod(a[, axis, dtype, out]) Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one.
  • [x] nancumsum(a[, axis, dtype, out]) Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.
  • [x] diff(a[, n, axis]) Calculate the n-th discrete difference along given axis.
  • [ ] ediff1d(ary[, to_end, to_begin]) The differences between consecutive elements of an array.
  • [x] gradient(f, *varargs, **kwargs) Return the gradient of an N-dimensional array.
  • [x] cross(a, b[, axisa, axisb, axisc, axis]) Return the cross product of two (arrays of) vectors.
  • [x] trapz(y[, x, dx, axis]) Integrate along the given axis using the composite trapezoidal rule.

Exponents and logarithms

  • [x] exp(x, /[, out, where, casting, order, ...]) Calculate the exponential of all elements in the input array.
  • [x] expm1(x, /[, out, where, casting, order, ...]) Calculate exp(x) - 1 for all elements in the array.
  • [x] exp2(x, /[, out, where, casting, order, ...]) Calculate 2**p for all p in the input array.
  • [x] log(x, /[, out, where, casting, order, ...]) Natural logarithm, element-wise.
  • [x] log10(x, /[, out, where, casting, order, ...]) Return the base 10 logarithm of the input array, element-wise.
  • [x] log2(x, /[, out, where, casting, order, ...]) Base-2 logarithm of x.
  • [x] log1p(x, /[, out, where, casting, order, ...]) Return the natural logarithm of one plus the input array, element-wise.
  • [x] logaddexp(x1, x2, /[, out, where, casting, ...]) Logarithm of the sum of exponentiations of the inputs.
  • [x] logaddexp2(x1, x2, /[, out, where, casting, ...]) Logarithm of the sum of exponentiations of the inputs in base-2.

Other special functions

  • [x] i0(x) Modified Bessel function of the first kind, order 0.
  • [x] sinc(x) Return the sinc function.

Floating point routines

  • [x] signbit(x, /[, out, where, casting, order, ...]) Returns element-wise True where signbit is set (less than zero).
  • [x] copysign(x1, x2, /[, out, where, casting, ...]) Change the sign of x1 to that of x2, element-wise.
  • [x] frexp(x[, out1, out2], / [[, out, where, ...]) Decompose the elements of x into mantissa and twos exponent.
  • [x] ldexp(x1, x2, /[, out, where, casting, ...]) Returns x1 * 2**x2, element-wise.
  • [x] nextafter(x1, x2, /[, out, where, casting, ...]) Return the next floating-point value after x1 towards x2, element-wise.
  • [x] spacing(x, /[, out, where, casting, order, ...]) Return the distance between x and the nearest adjacent number.

Arithmetic operations

  • [x] add(x1, x2, /[, out, where, casting, order, ...]) Add arguments element-wise.
  • [x] reciprocal(x, /[, out, where, casting, ...]) Return the reciprocal of the argument, element-wise.
  • [x] positive(x, /[, out, where, casting, order, ...]) | Numerical positive, element-wise.
  • [x] negative(x, /[, out, where, casting, order, ...]) Numerical negative, element-wise.
  • [x] multiply(x1, x2, /[, out, where, casting, ...]) Multiply arguments element-wise.
  • [x] divide(x1, x2, /[, out, where, casting, ...]) Divide arguments element-wise.
  • [x] power(x1, x2, /[, out, where, casting, ...]) First array elements raised to powers from second array, element-wise.
  • [x] subtract(x1, x2, /[, out, where, casting, ...]) Subtract arguments, element-wise.
  • [x] true_divide(x1, x2, /[, out, where, ...]) Returns a true division of the inputs, element-wise.
  • [x] floor_divide(x1, x2, /[, out, where, ...]) Return the largest integer smaller or equal to the division of the inputs.
  • [x] float_power(x1, x2, /[, out, where, ...]) First array elements raised to powers from second array, element-wise.
  • [x] fmod(x1, x2, /[, out, where, casting, ...]) Return the element-wise remainder of division.
  • [x] mod(x1, x2, /[, out, where, casting, order, ...]) Return element-wise remainder of division.
  • [x] modf(x[, out1, out2], / [[, out, where, ...]) Return the fractional and integral parts of an array, element-wise.
  • [x] remainder(x1, x2, /[, out, where, casting, ...]) Return element-wise remainder of division.
  • [x] divmod(x1, x2[, out1, out2], / [[, out, ...]) Return element-wise quotient and remainder simultaneously.

Handling complex numbers

  • [x] angle(z[, deg]) Return the angle of the complex argument.
  • [x] real(val) Return the real part of the complex argument.
  • [x] imag(val) Return the imaginary part of the complex argument.
  • [x] conj(x, /[, out, where, casting, order, ...]) Return the complex conjugate, element-wise.
  • [x] conjugate(x, /[, out, where, casting, ...]) | Return the complex conjugate, element-wise.

Extrema Finding

  • [x] maximum(x1, x2, /[, out, where, casting, ...]) Element-wise maximum of array elements.
  • [x] max(a[, axis, out, keepdims, initial, where]) Return the maximum of an array or maximum along an axis.
  • [x] amax(a[, axis, out, keepdims, initial, where]) Return the maximum of an array or maximum along an axis.
  • [x] fmax(x1, x2, /[, out, where, casting, ...]) Element-wise maximum of array elements.
  • [x] nanmax(a[, axis, out, keepdims, initial, where]) Return the maximum of an array or maximum along an axis, ignoring any NaNs.
  • [x] minimum(x1, x2, /[, out, where, casting, ...]) Element-wise minimum of array elements.
  • [x] min(a[, axis, out, keepdims, initial, where]) Return the minimum of an array or minimum along an axis.
  • [x] amin(a[, axis, out, keepdims, initial, where]) Return the minimum of an array or minimum along an axis.
  • [x] fmin(x1, x2, /[, out, where, casting, ...]) Element-wise minimum of array elements.
  • [x] nanmin(a[, axis, out, keepdims, initial, where]) Return minimum of an array or minimum along an axis, ignoring any NaNs.

Miscellaneous

  • [ ] convolve(a, v[, mode]) Returns the discrete, linear convolution of two one-dimensional sequences.
  • [x] clip(a, a_min, a_max[, out]) Clip (limit) the values in an array.
  • [x] sqrt(x, /[, out, where, casting, order, ...]) Return the positive square-root of an array, element-wise.
  • [x] cbrt(x, /[, out, where, casting, order, ...]) Return the cube-root of an array, element-wise.
  • [x] square(x, /[, out, where, casting, order, ...]) Return the element-wise square of the input.
  • [x] absolute(x, /[, out, where, casting, order, ...]) Calculate the absolute value element-wise.
  • [x] fabs(x, /[, out, where, casting, order, ...]) Compute the absolute values element-wise.
  • [x] sign(x, /[, out, where, casting, order, ...]) Returns an element-wise indication of the sign of a number.
  • [x] heaviside(x1, x2, /[, out, where, casting, ...]) Compute the Heaviside step function.
  • [x] nan_to_num(x[, copy]) Replace nan with zero and inf with finite numbers.
  • [x] real_if_close(a[, tol]) If complex input returns a real array if complex parts are close to zero.
  • [ ] interp(x, xp, fp[, left, right, period]) One-dimensional linear interpolation.

shssf avatar Sep 29 '20 20:09 shssf

dpnp.logaddexp is added by #1561

antonwolfy avatar May 31 '24 10:05 antonwolfy

dpnp.rint is added by #1537

antonwolfy avatar May 31 '24 10:05 antonwolfy

dpnp.signbit is added by #1535

antonwolfy avatar May 31 '24 12:05 antonwolfy

dpnp.angle is added by #1650

antonwolfy avatar May 31 '24 12:05 antonwolfy

dpnp.real and dpnp.imag are added by #1557

antonwolfy avatar May 31 '24 12:05 antonwolfy

dpnp.conj and dpnp.conjugate are added by #1519

antonwolfy avatar May 31 '24 12:05 antonwolfy

dpnp.clip is added by #1645

antonwolfy avatar May 31 '24 12:05 antonwolfy