Class Complex128Ops
java.lang.Object
org.flag4j.linalg.ops.common.complex.Complex128Ops
This class provides low level methods for computing operations on complex tensors. These methods can be applied to
either sparse or dense complex tensors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isComplex
(Complex128[] entries) Checks whether a tensor contains at least one non-real value.static boolean
isReal
(Complex128[] entries) Checks whether a tensor contains only real values.static Complex128[]
round
(Complex128[] src, int precision) Rounds the values of a tensor with specified precision.static Complex128[]
roundToZero
(Complex128[] src, double threshold) Rounds values which are close to zero in absolute value to zero.static Complex128[]
scalDiv
(double[] entries, Complex128 divisor) Computes the scalar division of a tensor.static Complex128[]
sqrt
(double[] src) Computes the element-wise square root of a tensor as complex values.static double[]
toReal
(Complex128[] src) Converts a complex tensor to a real tensor by copying the real component and discarding the imaginary component.
-
Method Details
-
sqrt
Computes the element-wise square root of a tensor as complex values. This allows for the square root of negative numbers.- Parameters:
src
- Elements of the tensor.- Returns:
- The element-wise square root of the tensor.
-
round
Rounds the values of a tensor with specified precision.- Parameters:
src
- Entries of the tensor to round.precision
- Precision to round to (i.e. the number of decimal places).- Returns:
- The result of rounding all data of the source tensor with the specified precision.
- Throws:
IllegalArgumentException
- Ifprecision
is negative.
-
roundToZero
Rounds values which are close to zero in absolute value to zero.- Parameters:
threshold
- Threshold for rounding values to zero. That is, if a value in this tensor is less than the threshold in absolute value then it will be rounded to zero. This value must be non-negative.- Returns:
- A copy of this matrix with rounded values.
- Throws:
IllegalArgumentException
- Ifthreshold
is negative.
-
toReal
Converts a complex tensor to a real tensor by copying the real component and discarding the imaginary component.- Parameters:
src
- Entries of complex tensor.- Returns:
- Equivalent real data for complex tensor.
-
scalDiv
Computes the scalar division of a tensor.- Parameters:
entries
- Entries of the tensor.divisor
- Scalar value to divide each element ot the tensor by.- Returns:
- The scalar division of the tensor.
-
isReal
Checks whether a tensor contains only real values.- Parameters:
entries
- Entries of dense tensor or non-zero data of sparse tensor.- Returns:
- True if the tensor only contains real values. Returns false otherwise.
-
isComplex
Checks whether a tensor contains at least one non-real value.- Parameters:
entries
- Entries of dense tensor or non-zero data of sparse tensor.- Returns:
- True if the tensor contains at least one non-real value. Returns false otherwise.
-