A math library for python
Project description
NumSpark (Version 1.2)
NumSpark is a Python library that provides mathematical operations and functions for numerical calculations. It includes operations on lists, vectors, matrices, sets, and various mathematical functions.
Installation and Dependencies
pip install numspark
numpy
sympy
Constants
NumSpark provides the following constants:
PI
: The mathematical constant π (pi).E
: The mathematical constant e (base of the natural logarithm).INFINITY
,INF
,inf
: Represents positive infinity.NAN
,NaN
,nan
: Represents not a number.TRUE
,true
: Represents the boolean value True.FALSE
,false
: Represents the boolean value False.NONE
,NULL
,none
,null
: Represents None or null.
List Operations
The List
class provides various element-wise operations on lists:
element_wise_operation
: Perform an element-wise operation on multiple lists.product
: Compute the element-wise product of multiple lists.scalarProduct
: Multiply each element of a list by a scalar value.add
: Compute the element-wise addition of multiple lists.scalarAdd
: Add a scalar value to each element of a list.sub
: Compute the element-wise subtraction of multiple lists.scalarSub
: Subtract a scalar value from each element of a list.div
: Compute the element-wise division of multiple lists.scalarDiv
: Divide each element of a list by a scalar value.floorDiv
: Compute the element-wise floor division of multiple lists.scalarFloorDiv
: Perform floor division of each element of a list by a scalar value.modulo
: Compute the element-wise modulo operation of multiple lists.scalarModulo
: Perform modulo operation on each element of a list with a scalar value.pow
: Compute the element-wise power of a list with a scalar value.flatten
: Flatten a nested list to a single list.
Vector Operations
The Vector
class provides operations on 3-dimensional vectors:
add
: Add multiple 3-dimensional vectors.sub
: Subtract multiple 3-dimensional vectors.crossProduct
: Compute the cross product of multiple 3-dimensional vectors.dotProduct
: Compute the dot product of multiple 3-dimensional vectors.magnitude
: Compute the magnitude of a 3-dimensional vector.projection
: Compute the projection of one 3-dimensional vector onto another.angleOfProjection
: Compute the angle of projection between two 3-dimensional vectors.
Matrix Operations
The Matrix
class provides operations on matrices:
isMatrix
: Check if a given nested list is a matrix.isSquare
: Check if a given matrix is square.add
: Add multiple matrices element-wise.scalarAdd
: Add a scalar value to each element of a matrix.sub
: Subtract multiple matrices element-wise.scalarSub
: Subtract a scalar value from each element of a matrix.product
: Multiply multiple matrices.scalarProduct
: Multiply each element of a matrix by a scalar value.T
: Transpose a matrix.subMatrix
: Extract a submatrix by removing a specific row and column from the original matrix.det
: Calculate the determinant of a square matrix.cofactor
: Calculate the cofactors of a square matrix.adjoint
: Calculate the adjoint (adjugate) of a square matrix.inv
: Calculate the inverse of a square matrix.traces
: Calculate the sum of the diagonal elements of a square matrix.diagonalSum
: Calculate the sum of the diagonal and anti-diagonal elements of a square matrix.removeCol
: Remove a specific column from a matrix.removeRow
: Remove a specific row from a matrix.reciprocal
: Calculate the reciprocal of each element in a matrix.
Set Operations
The Set
class provides operations on sets:
toSet
: Convert a list to a set, removing duplicates.intersect
: Compute the intersection of multiple sets.union
: Compute the union of multiple sets.belongsTo
: Check if an element belongs to a set.subSet
: Check if one set is a subset of another.
Mathematical Functions
NumSpark includes various mathematical functions:
max
: Find the maximum value in an array.min
: Find the minimum value in an array.sin
: Compute the sine of an angle (in radians or degrees).cos
: Compute the cosine of an angle (in radians or degrees).tan
: Compute the tangent of an angle (in radians or degrees).cot
: Compute the cotangent of an angle (in radians or degrees).cosec
: Compute the cosecant of an angle (in radians or degrees).sec
: Compute the secant of an angle (in radians or degrees).asin
: Compute the arcsine of an angle (in radians).acos
: Compute the arccosine of an angle (in radians).atan
: Compute the arctangent of an angle (in radians).acot
: Compute the arccotangent of an angle (in radians).acosec
: Compute the arccosecant of an angle (in radians).asec
: Compute the arcsecant of an angle (in radians).sqrt
: Compute the square root of a number.cbrt
: Compute the cube root of a number.power
: Compute the power of a number with a given exponent.exp
: Compute the exponential function of a number.factorial
: Compute the factorial of a number.fibSequence
: Generate a Fibonacci sequence up to a given number.floor
: Round a number down to the nearest integer.ceil
: Round a number up to the nearest integer.quadratic_roots
: Calculate the roots of a quadratic equation.log
: Compute the logarithm of a number (base 10).ln
: Compute the natural logarithm of a number (base e).logn
: Compute the logarithm of a number with a specified base.permutation
: Calculate the number of permutations ofn
objects takenr
at a time.combination
: Calculate the number of combinations ofn
objects takenr
at a time.product
: Compute the product of elements in an array.summation
: Compute the sum of elements in an array.mean
: Calculate the arithmetic mean (average) of an array.median
: Calculate the median of an array.mode
: Calculate the mode of an array.variance
: Calculate the variance of an array (sample or population).standard_deviation
: Calculate the standard deviation of an array (sample or population).skewness
: Calculate the skewness of an array.kurtosis
: Calculate the kurtosis of an array.geometric_mean
: Calculate the geometric mean of an arrayharmonic_mean(array: list)
: Calculates the harmonic mean of a list of numbers.correlation_coefficient(x: list, y: list)
: Computes the correlation coefficient between two lists of numbers.slope_intercept(array1: list, array2: list)
: Calculates the slope and intercept of the linear regression line for two arrays of data points.moving_average(array: list, steps: int)
: Computes the moving average of a list of numbers using a given window size.exponential_moving_average(array: list, alpha: int|float)
: Calculates the exponential moving average of a list of numbers using a smoothing factoralpha
.mean_sqrd_error(actual: list, predicted: list)
: Computes the mean squared error between two lists of actual and predicted values.root_mean_sqrd_error(actual: list, predicted: list)
: Calculates the root mean squared error between two lists of actual and predicted values.errors(actual: list, predicted: list)
: Calculates the errors (differences) between two lists of actual and predicted values.mean_error(actual: list, predicted: list)
: Computes the mean error (average of errors) between two lists of actual and predicted values.power(base: int|float, exponent: int|float)
: Raises the base to the power of the exponent.power_sum(array: list, exponent: int|float)
: Computes the sum of the elements in the array raised to the power of the given exponent.power_array(array: list, exponent: int|float)
: Generates a new list with elements from the input list raised to the power of the given exponent.primes(limit: int)
: Generates a list of prime numbers up to a given limit.isprime(number: int)
: Checks if a given number is prime.cost_function(actual: list, predicted: list)
: Computes the cost function (mean squared error) between two lists of actual and predicted values for a regression problem.scaling(array: list, feature_range: tuple = (0, 1))
: Scales the values in the array to a specified feature range (default 0 to 1).gaussian(array: list)
: Generates a list of values representing the Gaussian distribution based on the input data.sigmoid(x: int)
: Computes the sigmoid function for a given input.zscore(array: list, number: int) -> int|float
: Calculates the z-score of a given number in relation to a list of data.euclidean_distance(array1: list, array2: list)
: Calculates the Euclidean distance between two lists of coordinates (2D).manhattan_distance(array1: list, array2: list)
: Computes the Manhattan distance between two lists of coordinates (2D).camberra_distance(array1: list, array2: list)
: Calculates the Canberra distance between two lists of coordinates (2D).integrate(expression: str, wrt: str = "x")
: Performs symbolic integration of a given expression with respect to the specified variable.derivate(expression: str, wrt: str = "x")
: Performs symbolic differentiation of a given expression with respect to the specified variable.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file numspark-1.2.tar.gz
.
File metadata
- Download URL: numspark-1.2.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22f248b24c230cd2a906ceb10b40ab7d60b2ba7d0da1e5a5967c8425ad97a642 |
|
MD5 | 718564091fcd932a01c6755fb1281ec6 |
|
BLAKE2b-256 | 73e7cdf316ada0aa5f314118d041438234c0780c915e3971241a43fc8fe348ee |
File details
Details for the file numspark-1.2-py3-none-any.whl
.
File metadata
- Download URL: numspark-1.2-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 717ff5b1be0602c1181c926d528b0d1ff4588daea9b2cccc446067add6192e6f |
|
MD5 | f36ae5bd87b8a21f058036922503221a |
|
BLAKE2b-256 | b8072c2edae5730cc285248ee85948fc7a8a7037693b1e9aa525af3d43d07163 |