Class Numpy
- java.lang.Object
-
- ai.sklearn4j.core.libraries.numpy.Numpy
-
public final class Numpy extends Object
Implementation of the Numpy library APIs.
-
-
Constructor Summary
Constructors Constructor Description Numpy()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NumpyArrayabs(NumpyArray<Double> array)Calculate the absolute value element-wise.static NumpyArrayadd(NumpyArray array, byte value)Adds a byte value to numpy arrays.static NumpyArray<Double>add(NumpyArray array, double value)Adds a double value to numpy arrays.static NumpyArray<Float>add(NumpyArray array, float value)Adds a float value to numpy arrays.static NumpyArrayadd(NumpyArray array, int value)Adds a int value to numpy arrays.static NumpyArrayadd(NumpyArray array, long value)Adds a long value to numpy arrays.static NumpyArrayadd(NumpyArray array, short value)Adds a short value to numpy arrays.static NumpyArrayadd(NumpyArray a1, NumpyArray a2)Adds two numpy arrays.static <Type> NumpyArray<Long>argmax(NumpyArray<Type> array, int axis, boolean keepDimensions)Returns the indices of the maximum values along an axis.static NumpyArray<Double>arrayMax(NumpyArray<Double> array, int axis, boolean keepDimensions)Returns the maximum values along an axis.static NumpyArray<Byte>atLeast2D(byte value)Wraps an atomic byte value into a 2 dimensional array.static NumpyArray<Double>atLeast2D(double value)Wraps an atomic double value into a 2 dimensional array.static NumpyArray<Float>atLeast2D(float value)Wraps an atomic float value into a 2 dimensional array.static NumpyArray<Integer>atLeast2D(int value)Wraps an atomic int value into a 2 dimensional array.static NumpyArray<Long>atLeast2D(long value)Wraps an atomic long value into a 2 dimensional array.static NumpyArray<Short>atLeast2D(short value)Wraps an atomic short value into a 2 dimensional array.static <Type> NumpyArray<Type>atLeast2D(NumpyArray<Type> array)Wraps a numpy array into a 2 dimensional array if the number dimensions is less than 2.static NumpyArray<Double>clip(NumpyArray<Double> array, double min, double max)Clip (limit) the values in an array.static NumpyArray<Double>divide(NumpyArray<Double> array, double factor)Divides a numpy array by a double value.static NumpyArray<Float>divide(NumpyArray<Float> array, float factor)Divides a numpy array by a float value.static NumpyArraydivide(NumpyArray a1, NumpyArray a2)Divides two numpy arrays.static NumpyArray<Double>exp(NumpyArray array)Calculate the exponential of all elements in the input array.static NumpyArray<Double>log(NumpyArray array)Natural logarithm, element-wise.static NumpyArray<Double>multiply(NumpyArray<Double> array, double factor)Multiplies a numpy array by a double value.static NumpyArray<Float>multiply(NumpyArray<Float> array, float factor)Multiplies a numpy array by a float value.static NumpyArraymultiply(NumpyArray a1, NumpyArray a2)Multiplies two numpy arrays.static NumpyArray<Double>pow(NumpyArray array, double power)Performs an element-wise power operation on a given NumpyArray.static NumpyArray<Double>sqrt(NumpyArray array)Return the non-negative square-root of an array, element-wise.static NumpyArraysqueeze(NumpyArray array)Remove axes of length one from the array.static NumpyArraysubtract(NumpyArray array, byte value)Subtract a byte value from numpy arrays.static NumpyArray<Double>subtract(NumpyArray array, double value)Subtract a double value from numpy arrays.static NumpyArray<Float>subtract(NumpyArray array, float value)Subtract a float value from numpy arrays.static NumpyArraysubtract(NumpyArray array, int value)Subtract a int value from numpy arrays.static NumpyArraysubtract(NumpyArray array, long value)Subtract a long value from numpy arrays.static NumpyArraysubtract(NumpyArray array, short value)Subtract a short value from numpy arrays.static NumpyArraysubtract(NumpyArray a1, NumpyArray a2)Subtract two numpy arrays.static NumpyArraysum(NumpyArray array, int axis, boolean keepDimensions)Sums the values of a NumpyArray along a specified axis.
-
-
-
Method Detail
-
argmax
public static <Type> NumpyArray<Long> argmax(NumpyArray<Type> array, int axis, boolean keepDimensions)
Returns the indices of the maximum values along an axis. See: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html- Parameters:
array- The input multidimensional array.axis- The axis which the argmax should reduce to.keepDimensions- A flag to specify whether to keep the reduced dimension in the output.- Returns:
- Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed.
-
pow
public static NumpyArray<Double> pow(NumpyArray array, double power)
Performs an element-wise power operation on a given NumpyArray. See: https://numpy.org/doc/stable/reference/generated/numpy.power.html- Parameters:
array- Input array.power- The value of the power.- Returns:
- An array with same dimension with the requested power calculation.
-
sum
public static NumpyArray sum(NumpyArray array, int axis, boolean keepDimensions)
Sums the values of a NumpyArray along a specified axis. See: https://numpy.org/doc/stable/reference/generated/numpy.sum.html- Parameters:
array- Input array.axis- Axis along which a sum is performed.keepDimensions- A flag to specify whether to keep the reduced dimension in the output.- Returns:
- An array with the same shape as a, with the specified axis removed.
-
exp
public static NumpyArray<Double> exp(NumpyArray array)
Calculate the exponential of all elements in the input array. https://numpy.org/doc/stable/reference/generated/numpy.exp.html- Parameters:
array- Input values.- Returns:
- Output array, element-wise exponential of x.
-
log
public static NumpyArray<Double> log(NumpyArray array)
Natural logarithm, element-wise.The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e.
- Parameters:
array- Input values.- Returns:
- Output array, element-wise log of x.
-
subtract
public static NumpyArray subtract(NumpyArray a1, NumpyArray a2)
Subtract two numpy arrays.- Parameters:
a1- Left-hand side of the expression.a2- Right-hand side of the expression.- Returns:
- The subtraction result.
-
add
public static NumpyArray add(NumpyArray a1, NumpyArray a2)
Adds two numpy arrays.- Parameters:
a1- Left-hand side of the expression.a2- Right-hand side of the expression.- Returns:
- The addition result.
-
add
public static NumpyArray<Double> add(NumpyArray array, double value)
Adds a double value to numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The addition result.
-
subtract
public static NumpyArray<Double> subtract(NumpyArray array, double value)
Subtract a double value from numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The subtraction result.
-
add
public static NumpyArray<Float> add(NumpyArray array, float value)
Adds a float value to numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The addition result.
-
subtract
public static NumpyArray<Float> subtract(NumpyArray array, float value)
Subtract a float value from numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The subtraction result.
-
add
public static NumpyArray add(NumpyArray array, byte value)
Adds a byte value to numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The addition result.
-
subtract
public static NumpyArray subtract(NumpyArray array, byte value)
Subtract a byte value from numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The subtraction result.
-
add
public static NumpyArray add(NumpyArray array, short value)
Adds a short value to numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The addition result.
-
subtract
public static NumpyArray subtract(NumpyArray array, short value)
Subtract a short value from numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The subtraction result.
-
add
public static NumpyArray add(NumpyArray array, int value)
Adds a int value to numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The addition result.
-
subtract
public static NumpyArray subtract(NumpyArray array, int value)
Subtract a int value from numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The subtraction result.
-
add
public static NumpyArray add(NumpyArray array, long value)
Adds a long value to numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The addition result.
-
subtract
public static NumpyArray subtract(NumpyArray array, long value)
Subtract a long value from numpy arrays.- Parameters:
array- Left-hand side of the expression.value- Right-hand side of the expression.- Returns:
- The subtraction result.
-
multiply
public static NumpyArray multiply(NumpyArray a1, NumpyArray a2)
Multiplies two numpy arrays.- Parameters:
a1- Left-hand side of the expression.a2- Right-hand side of the expression.- Returns:
- The multiplication result.
-
multiply
public static NumpyArray<Double> multiply(NumpyArray<Double> array, double factor)
Multiplies a numpy array by a double value. The operation is element-wise.- Parameters:
array- The input array to be multiplied.factor- The value to be multiplied with.- Returns:
- A numpy array of the calculation result.
-
multiply
public static NumpyArray<Float> multiply(NumpyArray<Float> array, float factor)
Multiplies a numpy array by a float value. The operation is element-wise.- Parameters:
array- The input array to be multiplied.factor- The value to be multiplied with.- Returns:
- A numpy array of the calculation result.
-
divide
public static NumpyArray divide(NumpyArray a1, NumpyArray a2)
Divides two numpy arrays.- Parameters:
a1- Left-hand side of the expression.a2- Right-hand side of the expression.- Returns:
- The multiplication result.
-
divide
public static NumpyArray<Double> divide(NumpyArray<Double> array, double factor)
Divides a numpy array by a double value. The operation is element-wise.- Parameters:
array- The input array to be divided.factor- The value to be divided by.- Returns:
- A numpy array of the calculation result.
-
divide
public static NumpyArray<Float> divide(NumpyArray<Float> array, float factor)
Divides a numpy array by a float value. The operation is element-wise.- Parameters:
array- The input array to be divided.factor- The value to be divided by.- Returns:
- A numpy array of the calculation result.
-
atLeast2D
public static NumpyArray<Double> atLeast2D(double value)
Wraps an atomic double value into a 2 dimensional array.- Parameters:
value- The value to be wrapped into an array.- Returns:
- A two dimensional array that wraps the given value.
-
atLeast2D
public static NumpyArray<Float> atLeast2D(float value)
Wraps an atomic float value into a 2 dimensional array.- Parameters:
value- The value to be wrapped into an array.- Returns:
- A two dimensional array that wraps the given value.
-
atLeast2D
public static NumpyArray<Long> atLeast2D(long value)
Wraps an atomic long value into a 2 dimensional array.- Parameters:
value- The value to be wrapped into an array.- Returns:
- A two dimensional array that wraps the given value.
-
atLeast2D
public static NumpyArray<Integer> atLeast2D(int value)
Wraps an atomic int value into a 2 dimensional array.- Parameters:
value- The value to be wrapped into an array.- Returns:
- A two dimensional array that wraps the given value.
-
atLeast2D
public static NumpyArray<Short> atLeast2D(short value)
Wraps an atomic short value into a 2 dimensional array.- Parameters:
value- The value to be wrapped into an array.- Returns:
- A two dimensional array that wraps the given value.
-
atLeast2D
public static NumpyArray<Byte> atLeast2D(byte value)
Wraps an atomic byte value into a 2 dimensional array.- Parameters:
value- The value to be wrapped into an array.- Returns:
- A two dimensional array that wraps the given value.
-
atLeast2D
public static <Type> NumpyArray<Type> atLeast2D(NumpyArray<Type> array)
Wraps a numpy array into a 2 dimensional array if the number dimensions is less than 2.- Parameters:
array- The array to be wrapped into a 2 dimensional array.- Returns:
- A two dimensional array that wraps the given value.
-
arrayMax
public static NumpyArray<Double> arrayMax(NumpyArray<Double> array, int axis, boolean keepDimensions)
Returns the maximum values along an axis. See: https://numpy.org/doc/stable/reference/generated/numpy.amax.html- Parameters:
array- The input multidimensional array.axis- The axis which the amax should reduce to.keepDimensions- A flag to specify whether to keep the reduced dimension in the output.- Returns:
- Array of maximum into the array. It has the same shape as a.shape with the dimension along axis removed.
-
squeeze
public static NumpyArray squeeze(NumpyArray array)
Remove axes of length one from the array.- Parameters:
array- The array to squeeze.- Returns:
- An array without any dimension of length 1.
-
clip
public static NumpyArray<Double> clip(NumpyArray<Double> array, double min, double max)
Clip (limit) the values in an array.Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1.
Equivalent to but faster than np.minimum(a_max, np.maximum(a, a_min)).
- Parameters:
array- Array containing elements to clip.min- The minimum value to clip.max- The maximum value to clip.- Returns:
- An array with the elements of array, but where values less than min are replaced with min, and those greater than max with max.
-
abs
public static NumpyArray abs(NumpyArray<Double> array)
Calculate the absolute value element-wise.- Parameters:
array- Input array.- Returns:
- An ndarray containing the absolute value of each element in x.
-
sqrt
public static NumpyArray<Double> sqrt(NumpyArray array)
Return the non-negative square-root of an array, element-wise.- Parameters:
array- The values whose square-roots are required.- Returns:
- An array of the same shape as x, containing the positive square-root of each element in x.
-
-