java.lang.Object
- All Implemented Interfaces:
Serializable
,DenseTensorMixin<CVector,
,CooCVector> DenseVectorMixin<CVector,
,CooCVector, CMatrix, Field<Complex128>[], Complex128> TensorBinaryOpsMixin<CVector,
,CVector> TensorMixin<CVector,
,Field<Complex128>[], Complex128> VectorMatrixOpsMixin<CVector,
,CMatrix, CMatrix> VectorMixinOld<CVector,
CMatrix, CMatrix, Field<Complex128>[], Complex128>
A complex dense vector whose entries are Complex128
's.
A vector is essentially equivalent to a rank 1 tensor but has some extended functionality and may have improved performance for some operations.
CVector's have mutable entries but a fixed size.
- See Also:
-
Field Summary
Fields inherited from class org.flag4j.arrays.backend.DenseFieldVectorBase
size
Fields inherited from class org.flag4j.arrays.backend.AbstractTensor
entries, rank, shape
-
Constructor Summary
ConstructorDescriptionCVector
(double... entries) Creates a complex vector with the specifiedentries
.CVector
(int size) Creates a complex zero vector with the specifiedsize
.CVector
(int... entries) Creates a complex vector with the specifiedentries
.CVector
(int size, double fillValue) Creates a complex vector with the specifiedsize
and filled withfillValue
.CVector
(int size, Complex128 fillValue) Creates a complex vector with the specifiedsize
and filled withfillValue
.Creates a complex vector with the specifiedsize
and filled withfillValue
.Creates a complex vector with the specifiedentries
.CVector
(Field<Complex128>... entries) Creates a complex vector with the specifiedentries
.Creates a copy of the provided vector. -
Method Summary
Modifier and TypeMethodDescriptionadd
(Complex128 b) Adds a complex-valued scalar to each entry of this vector.Adds a complex dense vector to this vector.add
(CooCVector b) Adds a complex sparse vector to this vector.Adds a real sparse vector to this vector.void
addEq
(double b) Adds a scalar value to each entry of this tensor and stores the result in this tensor.void
Computes the element-wise sum between two tensors and stores the result in this tensor.Computes the element-wise quotient of this vector and a complex dense vector.Computes the element-wise product of this vector and a complex dense vector.Computes the element-wise product of this vector and a complex sparse vector.Computes the element-wise product of this vector and a real sparse vector.static CVector
getEmpty
(int size) Constructs an empty complex vector with the specifiedsize
.double
Computes the inner product between this vector and itself.makeLikeMatrix
(Shape shape, Field<Complex128>[] entries) Constructs a matrix of similar type to this vector with the specifiedshape
andentries
.makeLikeTensor
(int size, Complex128 fillValue) Creates a vector with the specified size filled with thefillValue
.makeLikeTensor
(Field<Complex128>... entries) Creates a vector with the specifiedentries
.makeLikeTensor
(Shape shape, Field<Complex128>[] entries) Constructs a tensor of the same type as this tensor with the given the shape and entries.makeSparseVector
(int size, List<Field<Complex128>> entries, List<Integer> indices) Constructs a sparse vector of similar type to this dense vector.round()
Rounds this tensor to the nearest whole number.round
(int precision) Rounds a matrix to the nearest whole number.Rounds values which are close to zero in absolute value to zero.roundToZero
(double threshold) Rounds values which are close to zero in absolute value to zero.set
(double val, int index) Sets a value of this vector toval
.Subtracts a complex dense vector from this vector.sub
(CooCVector b) Subtracts a complex sparse vector from this vector.Subtracts a real sparse vector from this vector.void
subEq
(double b) Subtracts a scalar from each entry of this tensor.void
Computes the element-wise difference between two tensors and stores the result in this tensor.toReal()
Converts this complex vector to a real vector.toString()
Generates a human-readable string representation of this vector.Methods inherited from class org.flag4j.arrays.backend.DenseFieldVectorBase
abs, addEq, allClose, cross, div, divEq, dot, elemMultEq, equals, H, H, inner, isParallel, isPerp, join, length, norm, norm, normalize, outer, repeat, set, stack, stack, subEq, T, T, tensorDot, tensorDot, toCoo, toMatrix
Methods inherited from class org.flag4j.arrays.backend.FieldTensorBase
add, add, addEq, conj, copy, div, div, divEq, elemMult, flatten, flatten, get, getZeroElement, H, isOnes, isZeros, mult, mult, multEq, prod, recip, reshape, setZeroElement, sqrt, sub, sub, sub, subEq, sum, T, tensorTr
Methods inherited from class org.flag4j.arrays.backend.TensorOverSemiRing
tensorDot, tensorDot, tensorTr
Methods inherited from class org.flag4j.arrays.backend.AbstractTensor
getEntries, getRank, getShape, reshape, sameShape, totalEntries
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.arrays.backend.DenseTensorMixin
allClose
Methods inherited from interface org.flag4j.arrays.backend.TensorMixin
copy, get, getEntries, getRank, getShape, T
Methods inherited from interface org.flag4j.arrays.backend.VectorMatrixOpsMixin
toMatrix
Methods inherited from interface org.flag4j.arrays.backend.VectorMixinOld
size
-
Constructor Details
-
CVector
Creates a complex vector with the specifiedentries
.- Parameters:
entries
- Entries of this vector.
-
CVector
Creates a complex vector with the specifiedentries
.- Parameters:
entries
- Entries of this vector.
-
CVector
public CVector(double... entries) Creates a complex vector with the specifiedentries
.- Parameters:
entries
- Entries of this vector.
-
CVector
public CVector(int... entries) Creates a complex vector with the specifiedentries
.- Parameters:
entries
- Entries of this vector.
-
CVector
Creates a complex vector with the specifiedsize
and filled withfillValue
.- Parameters:
size
- The size of the vector.fillValue
- The value to fill the vector with.
-
CVector
Creates a complex vector with the specifiedsize
and filled withfillValue
.- Parameters:
size
- The size of the vector.fillValue
- The value to fill the vector with.
-
CVector
public CVector(int size, double fillValue) Creates a complex vector with the specifiedsize
and filled withfillValue
.- Parameters:
size
- The size of the vector.fillValue
- The value to fill the vector with.
-
CVector
public CVector(int size) Creates a complex zero vector with the specifiedsize
.- Parameters:
size
- The size of the vector.
-
CVector
Creates a copy of the provided vector.- Parameters:
vector
- Vector to create a copy of.
-
-
Method Details
-
getEmpty
Constructs an empty complex vector with the specifiedsize
. The entries of the resulting vector will benull
.- Parameters:
size
- The size of the vector.- Returns:
- An empty complex vector with the specified
size
.
-
makeLikeTensor
Creates a vector with the specified size filled with thefillValue
.- Specified by:
makeLikeTensor
in classDenseFieldVectorBase<CVector,
CMatrix, CooCVector, Complex128> - Parameters:
size
-fillValue
- Value to fill this vector with.
-
makeLikeTensor
Creates a vector with the specifiedentries
.- Specified by:
makeLikeTensor
in classDenseFieldVectorBase<CVector,
CMatrix, CooCVector, Complex128> - Parameters:
entries
- Entries of this vector.
-
makeLikeMatrix
Constructs a matrix of similar type to this vector with the specifiedshape
andentries
.- Specified by:
makeLikeMatrix
in classDenseFieldVectorBase<CVector,
CMatrix, CooCVector, Complex128> - Parameters:
shape
- Shape of the matrix to construct.entries
- Entries of the matrix to construct.- Returns:
- A matrix of similar type to this vector with the specified
shape
andentries
.
-
makeSparseVector
public CooCVector makeSparseVector(int size, List<Field<Complex128>> entries, List<Integer> indices) Constructs a sparse vector of similar type to this dense vector.- Specified by:
makeSparseVector
in classDenseFieldVectorBase<CVector,
CMatrix, CooCVector, Complex128> - Parameters:
size
- The size of the sparse vector.entries
- The non-zero entries of the sparse vector.indices
- The non-zero indices of the sparse vector.- Returns:
- A sparse vector of similar type to this dense vector with the specified size, entries, and indices.
-
makeLikeTensor
Constructs a tensor of the same type as this tensor with the given the shape and entries.- Specified by:
makeLikeTensor
in interfaceTensorMixin<CVector,
Field<Complex128>[], Complex128> - Specified by:
makeLikeTensor
in classAbstractTensor<CVector,
Field<Complex128>[], Complex128> - Parameters:
shape
- Shape of the tensor to construct.entries
- Entries of the tensor to construct.- Returns:
- A tensor of the same type as this tensor with the given the shape and entries.
-
innerSelf
public double innerSelf()Computes the inner product between this vector and itself.- Returns:
- The inner product between this vector and itself.
-
toReal
Converts this complex vector to a real vector. This is done by ignoring the imaginary component of all entries.- Returns:
- A real vector containing the real components of this complex vectors entries.
-
add
-
add
-
add
Adds a complex sparse vector to this vector.- Parameters:
b
- The complex sparse vector in the sum.- Returns:
- The sum of this vector and
b
.
-
add
Adds a complex-valued scalar to each entry of this vector.- Overrides:
add
in classFieldTensorBase<CVector,
CVector, Complex128> - Parameters:
b
- The scalar value in the sum.- Returns:
- The sum of this vector's entries with the scalar value
b
.
-
sub
-
sub
-
sub
Subtracts a complex sparse vector from this vector.- Parameters:
b
- The complex sparse vector in the difference.- Returns:
- The difference of this vector and
b
.
-
subEq
public void subEq(double b) Subtracts a scalar from each entry of this tensor. The result is stored in this tensor.- Parameters:
b
- The scalar to subtract from each entry of this tensor.
-
elemMult
-
elemMult
Computes the element-wise product of this vector and a real sparse vector.- Parameters:
b
- The real sparse vector in the element-wise product.- Returns:
- The element-wise product of this vector and
b
.
-
elemMult
Computes the element-wise product of this vector and a complex sparse vector.- Parameters:
b
- The complex sparse vector in the element-wise product.- Returns:
- The element-wise product of this vector and
b
.
-
div
-
round
Rounds this tensor to the nearest whole number. If the tensor is complex, both the real and imaginary component will be rounded independently.- Returns:
- A copy of this tensor with each entry rounded to the nearest whole number.
-
round
Rounds a matrix to the nearest whole number. If the matrix is complex, both the real and imaginary component will be rounded independently.- Parameters:
precision
- The number of decimal places to round to. This value must be non-negative.- Returns:
- A copy of this matrix with rounded values.
- Throws:
IllegalArgumentException
- Ifprecision
is negative.
-
roundToZero
Rounds values which are close to zero in absolute value to zero. If the tensor is complex, both the real and imaginary components will be rounded independently. By default, the values must be withinFlag4jConstants.EPS_F64
of zero. To specify a threshold value seeroundToZero(double)
.- Returns:
- A copy of this tensor with rounded values.
-
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 matrix 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
- If threshold is negative.
-
subEq
Computes the element-wise difference between two tensors and stores the result in this tensor.- Parameters:
b
- Second tensor in the element-wise difference.- Throws:
TensorShapeException
- If this tensor andb
do not have the same shape.
-
addEq
Computes the element-wise sum between two tensors and stores the result in this tensor.- Parameters:
b
- Second tensor in the element-wise sum.- Throws:
TensorShapeException
- If this tensor andb
do not have the same shape.
-
set
Sets a value of this vector toval
.- Parameters:
val
- Value to set.index
- Index of this vector to set toval
.- Throws:
ArrayIndexOutOfBoundsException
- Ifindex
is not within this vector.
-
addEq
public void addEq(double b) Adds a scalar value to each entry of this tensor and stores the result in this tensor.- Parameters:
b
- Scalar value in sum.
-
toString
-