Class ComplexOperations
java.lang.Object
org.flag4j.operations.common.complex.ComplexOperations
This class provides low level methods for computing operations on real tensors. These methods can be applied to
either sparse or dense real tensors.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
Computes the element-wise absolute value of a tensor.static CNumber[]
Computes the element-wise complex conjugate of a tensor.static CNumber[]
Rounds the values of a tensor to the nearest integer.static CNumber[]
Rounds the values of a tensor with specified precision.static CNumber[]
roundToZero
(CNumber[] src, double threshold) Rounds values which are close to zero in absolute value to zero.static CNumber[]
Computes the scalar division of a tensor.static CNumber[]
Computes the scalar multiplication of a tensor.static CNumber[]
Computes the scalar multiplication of a tensor with a scalar value.static CNumber[]
Computes the scalar multiplication of a tensor with a scalar value.static CNumber[]
Computes the scalar multiplication of a tensor.static CNumber[]
Computes the scalar multiplication of a tensor.static CNumber[]
sqrt
(double[] src) Computes the element-wise square root of a tensor.static CNumber[]
Computes the element-wise square root of a tensor.static double[]
Converts a complex tensor to a real tensor by copying the real component and discarding the imaginary component.
-
Constructor Details
-
ComplexOperations
private ComplexOperations()
-
-
Method Details
-
sqrt
-
sqrt
Computes the element-wise square root of a tensor.- Parameters:
src
- Elements of the tensor.- Returns:
- The element-wise square root of the tensor.
-
abs
Computes the element-wise absolute value of a tensor.- Parameters:
src
- Elements of the tensor.- Returns:
- The element-wise absolute value of the tensor.
-
round
Rounds the values of a tensor to the nearest integer. Also seeround(CNumber[], int)
.- Parameters:
src
- Entries of the tensor to round.- Returns:
- The result of rounding all entries of the source tensor to the nearest integer.
- Throws:
IllegalArgumentException
- Ifprecision
is negative.
-
round
Rounds the values of a tensor with specified precision. Note, if precision is zero,round(CNumber[])
is preferred.- 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 entries 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.
-
scalMult
-
scalMult
-
scalMult
-
scalMult
Computes the scalar multiplication of a tensor.- Parameters:
src
- Entries of the tensor.dest
- Array to store result in. May be null.factor
- Scalar value to multiply.- Returns:
- A reference to the
dest
array if it was not null. Otherwise, a new array will be formed. - Throws:
ArrayIndexOutOfBoundsException
- Ifdest
is not at least the size ofsrc
.
-
scalMult
public static CNumber[] scalMult(CNumber[] src, CNumber[] dest, CNumber factor, int start, int stop) Computes the scalar multiplication of a tensor.- Parameters:
src
- Entries of the tensor.dest
- Array to store result in. May be null.factor
- Scalar value to multiply.start
- Starting index of scalar multiplication.stop
- Stopping index of scalar multiplication.- Returns:
- A reference to the
dest
array if it was not null. Otherwise, a new array will be formed. - Throws:
ArrayIndexOutOfBoundsException
- Ifdest
is not the size ofsrc
.
-
scalDiv
-
conj
-
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 entries for complex tensor.
-