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 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)Returns the indices of 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>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 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 NumpyArray<Double>pow(NumpyArray array, double power)Performs an element-wise power operation on a given NumpyArray.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)Sums the values of a NumpyArray along a specified axis.
-
-
-
Method Detail
-
argmax
public static <Type> NumpyArray<Long> argmax(NumpyArray<Type> array, int axis)
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.- 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)
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.- 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<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<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.
-
-