Package org.flag4j.operations.dense.real
Class RealDenseOperations
java.lang.Object
org.flag4j.operations.dense.real.RealDenseOperations
This class provides low level methods for computing operations on real dense tensors.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
add
(double[] src, double b) Adds a scalar to every element of a tensor.static double[]
Computes the element-wise addition of two tensors.static void
addEq
(double[] src, double b) Adds a scalar from each entry of this tensor and stores the result in the tensor.static void
Computes element-wise addition between tensors and stores the result in the first tensor.static double
prod
(double[] src) Multiplies all entries in a tensor.static int
prod
(int[] src) Multiplies all entries in a tensor.static double[]
recip
(double[] src) Computes the reciprocals, element-wise, of a tensor.static double[]
scalDiv
(double[] src, double divisor) Computes the scalar division of a tensor.static double[]
sub
(double[] src, double b) Subtracts a scalar from every element of a tensor.static double[]
Computes the element-wise subtraction of two tensors.static void
subEq
(double[] src, double b) Subtracts a scalar from each entry of this tensor and stores the result in the tensor.static void
Computes element-wise subtraction between tensors and stores the result in the first tensor.
-
Constructor Details
-
RealDenseOperations
private RealDenseOperations()
-
-
Method Details
-
add
Computes the element-wise addition of two tensors.- Parameters:
src1
- Entries of first Tensor of the addition.shape1
- Shape of first tensor.src2
- Entries of second Tensor of the addition.shape2
- Shape of second tensor.- Returns:
- The element wise addition of two tensors.
- Throws:
IllegalArgumentException
- If entry arrays are not the same size.
-
sub
Computes the element-wise subtraction of two tensors.- Parameters:
src1
- Entries of first tensor.shape1
- Shape of first tensor.src2
- Entries of second tensor.shape2
- Shape of second tensor.- Returns:
- The element wise subtraction of two tensors.
- Throws:
IllegalArgumentException
- If entry arrays are not the same size.
-
sub
public static double[] sub(double[] src, double b) Subtracts a scalar from every element of a tensor.- Parameters:
src
- Entries of tensor to add scalar to.b
- Scalar to subtract from tensor.- Returns:
- The tensor scalar subtraction.
-
subEq
Computes element-wise subtraction between tensors and stores the result in the first tensor.- Parameters:
src1
- First tensor in subtraction. Also, where the result will be stored.shape1
- Shape of the first tensor.src2
- Second tensor in the subtraction.shape2
- Shape of the second tensor.- Throws:
IllegalArgumentException
- If tensors are not the same shape.
-
subEq
public static void subEq(double[] src, double b) Subtracts a scalar from each entry of this tensor and stores the result in the tensor.- Parameters:
src
- Tensor in subtraction. Also, where the result will be stored.b
- Scalar to subtract.
-
addEq
Computes element-wise addition between tensors and stores the result in the first tensor.- Parameters:
src1
- First tensor in addition. Also, where the result will be stored.shape1
- Shape of the first tensor.src2
- Second tensor in the addition.shape2
- Shape of the second tensor.- Throws:
IllegalArgumentException
- If tensors are not the same shape.
-
addEq
public static void addEq(double[] src, double b) Adds a scalar from each entry of this tensor and stores the result in the tensor.- Parameters:
src
- Tensor in addition. Also, where the result will be stored.b
- Scalar to add.
-
prod
public static double prod(double[] src) Multiplies all entries in a tensor.- Parameters:
src
- The entries of the tensor.- Returns:
- The product of all entries in the tensor.
-
prod
public static int prod(int[] src) Multiplies all entries in a tensor.- Parameters:
src
- The entries of the tensor.- Returns:
- The product of all entries in the tensor.
-
scalDiv
public static double[] scalDiv(double[] src, double divisor) Computes the scalar division of a tensor.- Parameters:
src
- Entries of the tensor.divisor
- Scalar to divide by.- Returns:
- The scalar division of the tensor.
-
recip
public static double[] recip(double[] src) Computes the reciprocals, element-wise, of a tensor.- Parameters:
src
- Elements of the tensor.- Returns:
- The element-wise reciprocals of the tensor.
-
add
public static double[] add(double[] src, double b) Adds a scalar to every element of a tensor.- Parameters:
src
- src of tensor to add scalar to.b
- Scalar to add to tensor.- Returns:
- The tensor scalar addition.
-