CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-cupy-cuda101

CuPy: NumPy & SciPy for GPU (CUDA 10.1 version)

Pending
Overview
Eval results
Files

math-functions.mddocs/

Mathematical Functions

Comprehensive mathematical operations performed on GPU with NumPy-compatible interfaces. These functions provide GPU-accelerated computation for trigonometric, hyperbolic, exponential, logarithmic, arithmetic, and special mathematical functions.

Capabilities

Trigonometric Functions

Standard trigonometric functions with GPU acceleration, supporting both scalar and array inputs.

def sin(x, out=None, **kwargs):
    """
    Sine function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Sine of input on GPU
    """

def cos(x, out=None, **kwargs):
    """
    Cosine function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Cosine of input on GPU
    """

def tan(x, out=None, **kwargs):
    """
    Tangent function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Tangent of input on GPU
    """

def arcsin(x, out=None, **kwargs):
    """
    Inverse sine function.
    
    Parameters:
    - x: array-like, input array in [-1, 1]
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Arcsine of input on GPU
    """

def arccos(x, out=None, **kwargs):
    """
    Inverse cosine function.
    
    Parameters:
    - x: array-like, input array in [-1, 1]
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Arccosine of input on GPU
    """

def arctan(x, out=None, **kwargs):
    """
    Inverse tangent function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Arctangent of input on GPU
    """

def arctan2(y, x, out=None, **kwargs):
    """
    Element-wise arc tangent of y/x.
    
    Parameters:
    - y: array-like, y coordinates
    - x: array-like, x coordinates
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Arctangent of y/x on GPU
    """

def hypot(x1, x2, out=None, **kwargs):
    """
    Element-wise hypotenuse given legs of right triangle.
    
    Parameters:
    - x1: array-like, first leg
    - x2: array-like, second leg
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Hypotenuse sqrt(x1**2 + x2**2) on GPU
    """

def degrees(x, out=None, **kwargs):
    """
    Convert angles from radians to degrees.
    
    Parameters:
    - x: array-like, input in radians
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Angles in degrees on GPU
    """

def radians(x, out=None, **kwargs):
    """
    Convert angles from degrees to radians.
    
    Parameters:
    - x: array-like, input in degrees
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Angles in radians on GPU
    """

Hyperbolic Functions

Hyperbolic trigonometric functions for advanced mathematical computations.

def sinh(x, out=None, **kwargs):
    """
    Hyperbolic sine function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Hyperbolic sine of input on GPU
    """

def cosh(x, out=None, **kwargs):
    """
    Hyperbolic cosine function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Hyperbolic cosine of input on GPU
    """

def tanh(x, out=None, **kwargs):
    """
    Hyperbolic tangent function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Hyperbolic tangent of input on GPU
    """

def arcsinh(x, out=None, **kwargs):
    """
    Inverse hyperbolic sine function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Inverse hyperbolic sine of input on GPU
    """

def arccosh(x, out=None, **kwargs):
    """
    Inverse hyperbolic cosine function.
    
    Parameters:
    - x: array-like, input array >= 1
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Inverse hyperbolic cosine of input on GPU
    """

def arctanh(x, out=None, **kwargs):
    """
    Inverse hyperbolic tangent function.
    
    Parameters:
    - x: array-like, input array in (-1, 1)
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Inverse hyperbolic tangent of input on GPU
    """

Exponential and Logarithmic Functions

Exponential and logarithmic functions with various bases and special cases.

def exp(x, out=None, **kwargs):
    """
    Exponential function e^x.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Exponential of input on GPU
    """

def exp2(x, out=None, **kwargs):
    """
    Base-2 exponential function 2^x.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Base-2 exponential of input on GPU
    """

def expm1(x, out=None, **kwargs):
    """
    Exponential minus one: exp(x) - 1.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: exp(x) - 1 on GPU
    """

def log(x, out=None, **kwargs):
    """
    Natural logarithm.
    
    Parameters:
    - x: array-like, input array > 0
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Natural logarithm of input on GPU
    """

def log2(x, out=None, **kwargs):
    """
    Base-2 logarithm.
    
    Parameters:
    - x: array-like, input array > 0
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Base-2 logarithm of input on GPU
    """

def log10(x, out=None, **kwargs):
    """
    Base-10 logarithm.
    
    Parameters:
    - x: array-like, input array > 0
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Base-10 logarithm of input on GPU
    """

def log1p(x, out=None, **kwargs):
    """
    Logarithm of one plus input: log(1 + x).
    
    Parameters:
    - x: array-like, input array > -1
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: log(1 + x) on GPU
    """

def logaddexp(x1, x2, out=None, **kwargs):
    """
    Logarithm of sum of exponentials: log(exp(x1) + exp(x2)).
    
    Parameters:
    - x1: array-like, first input array
    - x2: array-like, second input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: log(exp(x1) + exp(x2)) on GPU
    """

def logaddexp2(x1, x2, out=None, **kwargs):
    """
    Base-2 logarithm of sum of powers: log2(2^x1 + 2^x2).
    
    Parameters:
    - x1: array-like, first input array
    - x2: array-like, second input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: log2(2^x1 + 2^x2) on GPU
    """

Arithmetic Functions

Basic arithmetic operations with broadcasting support and GPU acceleration.

def add(x1, x2, out=None, **kwargs):
    """
    Addition of arrays element-wise.
    
    Parameters:
    - x1: array-like, first input array
    - x2: array-like, second input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise sum on GPU
    """

def subtract(x1, x2, out=None, **kwargs):
    """
    Subtraction of arrays element-wise.
    
    Parameters:
    - x1: array-like, first input array
    - x2: array-like, second input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise difference on GPU
    """

def multiply(x1, x2, out=None, **kwargs):
    """
    Multiplication of arrays element-wise.
    
    Parameters:
    - x1: array-like, first input array
    - x2: array-like, second input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise product on GPU
    """

def divide(x1, x2, out=None, **kwargs):
    """
    Division of arrays element-wise.
    
    Parameters:
    - x1: array-like, dividend array
    - x2: array-like, divisor array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise quotient on GPU
    """

def true_divide(x1, x2, out=None, **kwargs):
    """
    True division of arrays element-wise.
    
    Parameters:
    - x1: array-like, dividend array
    - x2: array-like, divisor array  
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise true division on GPU
    """

def floor_divide(x1, x2, out=None, **kwargs):
    """
    Floor division of arrays element-wise.
    
    Parameters:
    - x1: array-like, dividend array
    - x2: array-like, divisor array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise floor division on GPU
    """

def power(x1, x2, out=None, **kwargs):
    """
    Element-wise power function.
    
    Parameters:
    - x1: array-like, base array
    - x2: array-like, exponent array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise x1^x2 on GPU
    """

def remainder(x1, x2, out=None, **kwargs):
    """
    Remainder of division element-wise.
    
    Parameters:
    - x1: array-like, dividend array
    - x2: array-like, divisor array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise remainder on GPU
    """

def negative(x, out=None, **kwargs):
    """
    Numerical negative element-wise.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Negative of input on GPU
    """

def absolute(x, out=None, **kwargs):
    """
    Absolute value element-wise.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Absolute value of input on GPU
    """

Rounding Functions

Functions for rounding numbers to integers or specified decimal places.

def around(a, decimals=0, out=None):
    """
    Round to given number of decimals.
    
    Parameters:
    - a: array-like, input array
    - decimals: int, number of decimal places
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Rounded array on GPU
    """

def round_(a, decimals=0, out=None):
    """
    Round to given number of decimals.
    
    Parameters:
    - a: array-like, input array
    - decimals: int, number of decimal places
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Rounded array on GPU
    """

def rint(x, out=None, **kwargs):
    """
    Round to nearest integer.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Rounded to nearest integer on GPU
    """

def floor(x, out=None, **kwargs):
    """
    Floor function (round down).
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Floor of input on GPU
    """

def ceil(x, out=None, **kwargs):
    """
    Ceiling function (round up).
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Ceiling of input on GPU
    """

def trunc(x, out=None, **kwargs):
    """
    Truncate towards zero.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Truncated values on GPU
    """

Miscellaneous Mathematical Functions

Additional mathematical functions including roots, extrema, and special operations.

def sqrt(x, out=None, **kwargs):
    """
    Square root function.
    
    Parameters:
    - x: array-like, input array >= 0
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Square root of input on GPU
    """

def cbrt(x, out=None, **kwargs):
    """
    Cube root function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Cube root of input on GPU
    """

def square(x, out=None, **kwargs):
    """
    Square function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Square of input on GPU
    """

def sign(x, out=None, **kwargs):
    """
    Sign function.
    
    Parameters:
    - x: array-like, input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Sign of input (-1, 0, 1) on GPU
    """

def maximum(x1, x2, out=None, **kwargs):
    """
    Element-wise maximum.
    
    Parameters:
    - x1: array-like, first input array
    - x2: array-like, second input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise maximum on GPU
    """

def minimum(x1, x2, out=None, **kwargs):
    """
    Element-wise minimum.
    
    Parameters:
    - x1: array-like, first input array
    - x2: array-like, second input array
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Element-wise minimum on GPU
    """

def clip(a, a_min, a_max, out=None, **kwargs):
    """
    Clip values to range.
    
    Parameters:
    - a: array-like, input array
    - a_min: scalar or array, minimum value
    - a_max: scalar or array, maximum value
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Clipped array on GPU
    """

Sum and Product Functions

Aggregation functions for computing sums, products, and cumulative operations.

def sum(a, axis=None, dtype=None, out=None, keepdims=False, initial=None, where=True):
    """
    Sum of array elements over given axes.
    
    Parameters:
    - a: array-like, input array
    - axis: int or tuple, axes to sum over, optional
    - dtype: data type, result data type, optional
    - out: array, output array, optional
    - keepdims: bool, keep dimensions
    - initial: scalar, initial value, optional
    - where: array, condition, optional
    
    Returns:
    cupy.ndarray: Sum along specified axes on GPU
    """

def prod(a, axis=None, dtype=None, out=None, keepdims=False, initial=None, where=True):
    """
    Product of array elements over given axes.
    
    Parameters:
    - a: array-like, input array
    - axis: int or tuple, axes to multiply over, optional
    - dtype: data type, result data type, optional
    - out: array, output array, optional
    - keepdims: bool, keep dimensions
    - initial: scalar, initial value, optional
    - where: array, condition, optional
    
    Returns:
    cupy.ndarray: Product along specified axes on GPU
    """

def cumsum(a, axis=None, dtype=None, out=None):
    """
    Cumulative sum along axis.
    
    Parameters:
    - a: array-like, input array
    - axis: int, axis for cumulative sum, optional
    - dtype: data type, result data type, optional
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Cumulative sum on GPU
    """

def cumprod(a, axis=None, dtype=None, out=None):
    """
    Cumulative product along axis.
    
    Parameters:
    - a: array-like, input array
    - axis: int, axis for cumulative product, optional
    - dtype: data type, result data type, optional
    - out: array, output array, optional
    
    Returns:
    cupy.ndarray: Cumulative product on GPU
    """

Usage Examples

Basic Mathematical Operations

import cupy as cp
import numpy as np

# Create test arrays
x = cp.linspace(0, 2*cp.pi, 1000)
y = cp.array([[1, 2, 3], [4, 5, 6]], dtype=cp.float32)

# Trigonometric functions
sin_x = cp.sin(x)
cos_x = cp.cos(x)
tan_half = cp.tan(x/2)

# Exponential and logarithmic
exp_y = cp.exp(y)
log_y = cp.log(y)
sqrt_y = cp.sqrt(y)

# Element-wise arithmetic
z = cp.add(y, 10)  # Broadcasting
product = cp.multiply(y, y)  # Element-wise square

Advanced Mathematical Operations

# Complex mathematical expressions
amplitude = cp.sqrt(cp.add(cp.square(sin_x), cp.square(cos_x)))
phase = cp.arctan2(sin_x, cos_x)

# Aggregation operations
total = cp.sum(y)
row_sums = cp.sum(y, axis=1)
cumulative = cp.cumsum(y.flatten())

# Rounding and clipping
rounded = cp.around(y * 1.7, decimals=1)
clipped = cp.clip(y, 2, 5)

Install with Tessl CLI

npx tessl i tessl/pypi-cupy-cuda101

docs

array-creation.md

array-manipulation.md

binary-operations.md

cuda.md

fft.md

index.md

indexing-searching.md

linalg.md

logic-functions.md

math-functions.md

memory-performance.md

random.md

sorting-counting.md

statistics.md

tile.json