Supported NumPy Functions#
NumPy QuadDType supports a comprehensive set of NumPy universal functions (ufuncs) and array functions.
Element-wise Arithmetic Operations#
Unary Arithmetic#
Function |
Operator |
Description |
|---|---|---|
|
|
Numerical negative |
|
|
Numerical positive |
|
|
Absolute value |
Binary Arithmetic#
Function |
Operator |
Description |
|---|---|---|
|
|
Addition |
|
|
Subtraction |
|
|
Multiplication |
|
|
Division |
|
|
True division |
|
|
Floor division |
|
|
Modulo |
|
|
Power |
Element-wise Sign Functions#
Function |
Description |
|---|---|
|
Sign indicator |
|
Test for negative sign bit (works with NaN) |
|
Copy sign of second to first |
Element-wise Trigonometric Functions#
Function |
Description |
|---|---|
|
Sine |
|
Cosine |
|
Tangent |
|
Inverse sine |
|
Inverse cosine |
|
Inverse tangent |
|
Two-argument inverse tangent |
Element-wise Hyperbolic Functions#
Function |
Description |
|---|---|
|
Hyperbolic sine |
|
Hyperbolic cosine |
|
Hyperbolic tangent |
|
Inverse hyperbolic sine |
|
Inverse hyperbolic cosine |
|
Inverse hyperbolic tangent |
Element-wise Exponential Functions#
Function |
Description |
|---|---|
|
Exponential (\(e^x\)) |
|
Base-2 exponential (\(2^x\)) |
|
|
Element-wise Logarithmic Functions#
Function |
Description |
|---|---|
|
Natural logarithm |
|
Base-2 logarithm |
|
Base-10 logarithm |
|
|
Element-wise Power and Root Functions#
Function |
Description |
|---|---|
|
Square (\(x^2\)) |
|
Square root |
|
Cube root |
|
Hypotenuse (\(\sqrt{x^2 + y^2}\)) |
Element-wise Rounding Functions#
Function |
Description |
|---|---|
|
Floor (round down) |
|
Ceiling (round up) |
|
Truncate toward zero |
|
Round to nearest integer (ties to even) |
Element-wise Classification Functions#
Function |
Description |
|---|---|
|
Test for finite values |
|
Test for infinity |
|
Test for NaN |
Element-wise Comparison Functions#
Function |
Operator |
Description |
|---|---|---|
|
|
Equal |
|
|
Not equal |
|
|
Less than |
|
|
Less than or equal |
|
|
Greater than |
|
|
Greater than or equal |
Element-wise Minimum/Maximum#
Function |
Description |
|---|---|
|
Minimum |
|
Maximum |
|
Minimum (ignores NaN) |
|
Maximum (ignores NaN) |
Reduction Functions#
Function |
Description |
|---|---|
|
Sum of elements |
|
Product of elements |
|
Arithmetic mean |
|
Minimum value |
|
Maximum value |
Array Creation and Manipulation#
Creation#
Function |
Description |
|---|---|
|
Array of zeros |
|
Array of ones |
|
Uninitialized array |
|
Array filled with given value |
|
Range of values |
|
Linearly spaced values |
Manipulation#
Function |
Description |
|---|---|
|
Reshape array |
|
Transpose array |
|
Join arrays |
|
Stack arrays |
|
Split array |
Linear Algebra (via QuadBLAS)#
When QuadBLAS is available (not on Windows):
Function |
Description |
|---|---|
|
Matrix multiplication |
Type Conversion#
Function |
Description |
|---|---|
|
Convert array dtype |
|
Create array from data |
Usage Examples#
Trigonometric#
import numpy as np
from numpy_quaddtype import QuadPrecDType, pi
x = np.array([0, pi/6, pi/4, pi/3, pi/2, pi], dtype=QuadPrecDType())
print("sin(x):", np.sin(x))
print("cos(x):", np.cos(x))
Exponential and Logarithmic#
import numpy as np
from numpy_quaddtype import QuadPrecDType
x = np.array([1, 2, 3], dtype=QuadPrecDType())
print("exp(x):", np.exp(x))
print("log(exp(x)):", np.log(np.exp(x))) # Should return x
Reductions#
import numpy as np
from numpy_quaddtype import QuadPrecDType
arr = np.arange(1, 11, dtype=QuadPrecDType())
print("Sum:", np.sum(arr)) # 55
print("Product:", np.prod(arr)) # 3628800 (10!)
print("Mean:", np.mean(arr)) # 5.5