Class CooCVector
- All Implemented Interfaces:
Serializable
,ComplexTensorMixin<CooCVector,
,CooVector> SparseTensorMixin
,TensorComparisonsMixin
,TensorManipulationsMixin<CooCVector>
,TensorOperationsMixin<CooCVector,
,CVector, CooCVector, CVector, CooVector, CNumber> TensorPropertiesMixin
,VectorComparisonsMixin
,VectorManipulationsMixin<CooCMatrix>
,VectorMixin<CooCVector,
,CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> VectorOperationsMixin<CooCVector,
,CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> VectorPropertiesMixin
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal int[]
Indices of non-zero entries in this sparse vector.final int
The size of this vector.Fields inherited from class org.flag4j.core.sparse_base.SparseTensorBase
nnz
Fields inherited from class org.flag4j.core.TensorBase
DEFAULT_ROUND_TO_ZERO_THRESHOLD, entries, shape
-
Constructor Summary
ConstructorDescriptionCooCVector
(int size) Creates a sparse column vector of specified size filled with zeros.CooCVector
(int size, double[] nonZeroEntries, int[] indices) Creates a sparse column vector of specified size filled with zeros.CooCVector
(int size, int[] nonZeroEntries, int[] indices) Creates a sparse column vector of specified size filled with zeros.CooCVector
(int size, List<CNumber> entries, List<Integer> indices) Creates a sparse vector of specified size, non-zero entries, and non-zero indices.CooCVector
(int size, CNumber[] nonZeroEntries, int[] indices) Creates a sparse column vector of specified size filled with zeros.Constructs a complex sparse vector whose size, orientation, non-zero entries, and indices are specified by another complex sparse vector. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Computes the element-wise absolute value/magnitude of a tensor.add
(double a) Adds specified value to all entries of this tensor.Computes the element-wise addition between this vector and the specified vector.Computes the element-wise addition between this vector and the specified vector.add
(CooCVector B) Computes the element-wise addition between two tensors of the same rank.Computes the element-wise addition between this vector and the specified vector.Adds specified value to all entries of this tensor.boolean
allClose
(CooCVector tensor, double relTol, double absTol) Checks if all entries of this tensor are close to the entries of the argumenttensor
.int[]
argMax()
Finds the indices of the maximum value in this tensor.int[]
argMin()
Finds the indices of the minimum value in this tensor.conj()
Computes the complex conjugate of a tensor.copy()
Creates a dense copy of this tensor.div
(double divisor) Computes the scalar division of a tensor.Computes the scalar division of a tensor.Computes the element-wise division between two tensors.Computes the element-wise division (Hadamard multiplication) between this vector and a specified vector.Computes the element-wise multiplication (Hadamard multiplication) between this vector and a specified vector.Computes the element-wise multiplication (Hadamard multiplication) between this vector and a specified vector.Computes the element-wise multiplication between two tensors.Computes the element-wise multiplication (Hadamard multiplication) between this vector and a specified vector.boolean
Checks if an object is equal to this sparse COO vector.extend
(int n, int axis) Extends a vector a specified number of times to a matrix.flatten()
Flattens tensor to single dimension.flatten
(int axis) Flattens a tensor along the specified axis.static CooCVector
Creates a sparse tensor from a dense tensor.get
(int... indices) Gets the element in this tensor at the specified indices.protected CooCVector
getSelf()
Simply returns a reference of this tensor.H()
Computes the conjugate transpose of this tensor.Computes the inner product between two vectors.Computes the inner product between two vectors.inner
(CooCVector b) Computes the inner product between two vectors.Computes the inner product between two vectors.boolean
Checks if this vector contains at least one non-real entry.boolean
isParallel
(Vector b) Checks if a vector is parallel to this vector.boolean
Checks if a vector is perpendicular to this vector.boolean
isReal()
Checks if this vector contains only real entries.Joints specified vector with this vector.Joints specified vector with this vector.join
(CooCVector b) Joints specified vector with this vector.Joints specified vector with this vector.int
length()
Gets the length of a vector.protected CooVector
makeRealTensor
(Shape shape, double[] entries, int[][] indices) A factory for creating a real sparse tensor.protected CooCVector
makeTensor
(Shape shape, CNumber[] entries, int[][] indices) A factory for creating a complex sparse tensor.mult
(double factor) Computes scalar multiplication of a tensor.Computes scalar multiplication of a tensor.Computes a unit vector in the same direction as this vector.Computes the outer product of two vectors.Computes the outer product of two vectors.outer
(CooCVector b) Computes the outer product of two vectors.Computes the outer product of two vectors.recip()
Computes the reciprocals, element-wise, of this sparse vector.repeat
(int n, int axis) Repeats a vectorn
times along a certain axis to create a matrix.reshape
(int... shape) Copies and reshapes tensor if possible.Copies and reshapes tensor if possible.set
(double value, int... indices) Sets an index of this tensor to a specified value.Sets an index of this tensor to a specified value.int
size()
Gets the full size of this vector (including non-zero entries).sqrt()
Computes the element-wise square root of a tensor.Stacks two vectors along columns as if they were row vectors.Stacks two vectors along specified axis.Stacks two vectors along columns as if they were row vectors.Stacks two vectors along specified axis.stack
(CooCVector b) Stacks two vectors along columns as if they were row vectors.stack
(CooCVector b, int axis) Stacks two vectors along specified axis.Stacks two vectors along columns as if they were row vectors.Stacks two vectors along specified axis.sub
(double a) Adds specified value to all entries of this tensor.Computes the element-wise subtraction between this vector and the specified vector.Computes the element-wise subtraction between this vector and the specified vector.sub
(CooCVector B) Computes the element-wise subtraction between two tensors of the same rank.Computes the element-wise subtraction between this vector and the specified vector.Subtracts a specified value from all entries of this tensor.T()
Computes the transpose of a tensor.toDense()
Converts this sparse tensor to an equivalent dense tensor.toMatrix()
Converts a vector to an equivalent matrix.toMatrix
(boolean columVector) Converts a vector to an equivalent matrix representing either a row or column vector.toReal()
Converts a complex tensor to a real matrix.Converts a complex tensor to a real matrix safely.toString()
Formats this tensor as a human-readable string.toTensor()
Converts this vector to an equivalent tensor.Computes the transpose of a tensor.Methods inherited from class org.flag4j.core.sparse_base.ComplexSparseTensorBase
isOnes, isZeros, max, maxAbs, min, minAbs, nonZeroEntries, round, round, roundToZero, roundToZero, sortIndices, sum
Methods inherited from class org.flag4j.core.sparse_base.SparseTensorBase
density, sparsity
Methods inherited from class org.flag4j.core.TensorBase
allClose, getEntries, getRank, getShape, sameLength, sameShape, tensorEquals, totalEntries
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.core.ComplexTensorMixin
hermTranspose
Methods inherited from interface org.flag4j.core.VectorPropertiesMixin
maxAbs
-
Field Details
-
size
public final int sizeThe size of this vector. That is, the number of entries in this vector. -
indices
public final int[] indicesIndices of non-zero entries in this sparse vector.
-
-
Constructor Details
-
CooCVector
public CooCVector(int size) Creates a sparse column vector of specified size filled with zeros.- Parameters:
size
- The size of the sparse vector. i.e. the total number of entries in the sparse vector.
-
CooCVector
public CooCVector(int size, int[] nonZeroEntries, int[] indices) Creates a sparse column vector of specified size filled with zeros.- Parameters:
size
- The size of the sparse vector. i.e. the total number of entries in the sparse vector.nonZeroEntries
- The nonZero entries of this sparse vector.indices
- Indices of the nonZero entries.- Throws:
IllegalArgumentException
- If the lengths of nonZeroEntries and indices arrays are not equal or if the length of the nonZeroEntries array is greater than the size.
-
CooCVector
public CooCVector(int size, double[] nonZeroEntries, int[] indices) Creates a sparse column vector of specified size filled with zeros.- Parameters:
size
- The size of the sparse vector. i.e. the total number of entries in the sparse vector.nonZeroEntries
- The nonZero entries of this sparse vector.indices
- Indices of the nonZero entries.- Throws:
IllegalArgumentException
- If the lengths of nonZeroEntries and indices arrays are not equal or if the length of the nonZeroEntries array is greater than the size.
-
CooCVector
Creates a sparse column vector of specified size filled with zeros.- Parameters:
size
- The size of the sparse vector. i.e. the total number of entries in the sparse vector.nonZeroEntries
- The nonZero entries of this sparse vector.indices
- Indices of the nonZero entries.- Throws:
IllegalArgumentException
- If the lengths of nonZeroEntries and indices arrays are not equal or if the length of the nonZeroEntries array is greater than the size.
-
CooCVector
Constructs a complex sparse vector whose size, orientation, non-zero entries, and indices are specified by another complex sparse vector.- Parameters:
a
- Vector to copy.
-
CooCVector
Creates a sparse vector of specified size, non-zero entries, and non-zero indices.- Parameters:
size
- Full size, including zeros, of the sparse vector.entries
- Non-zero entries of the sparse vector.indices
- Non-zero indices of the sparse vector.
-
-
Method Details
-
equals
Checks if an object is equal to this sparse COO vector.- Specified by:
equals
in interfaceTensorComparisonsMixin
- Overrides:
equals
in classObject
- Parameters:
object
- Object to compare this sparse COO vector to.- Returns:
- True if the object is a
CooVector
, has the same shape as this vector, and is element-wise equal to this vector.
-
fromDense
Creates a sparse tensor from a dense tensor.- Parameters:
src
- Dense tensor to convert to a sparse tensor.- Returns:
- A sparse tensor which is equivalent to the
src
dense tensor.
-
getSelf
Simply returns a reference of this tensor.- Specified by:
getSelf
in classTensorBase<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber[], CNumber> - Returns:
- A reference to this tensor.
-
allClose
Description copied from class:TensorBase
Checks if all entries of this tensor are close to the entries of the argumenttensor
.- Specified by:
allClose
in classTensorBase<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber[], CNumber> - Parameters:
tensor
- Tensor to compare this tensor to.relTol
- Relative tolerance.absTol
- Absolute tolerance.- Returns:
- True if the argument
tensor
is the same shape as this tensor and all entries are 'close', i.e. elementsa
andb
at the same positions in the two tensors respectively satisfy|a-b| <= (atol + rtol*|b|)
. Otherwise, returns false. - See Also:
-
H
Computes the conjugate transpose of this tensor. In the context of a tensor, this swaps the first and last axes and takes the complex conjugate of the elements along these axes. Same asComplexTensorMixin.hermTranspose()
.- Specified by:
H
in interfaceComplexTensorMixin<CooCVector,
CooVector> - Returns:
- The complex transpose of this tensor.
-
set
Sets an index of this tensor to a specified value.- Specified by:
set
in interfaceComplexTensorMixin<CooCVector,
CooVector> - Parameters:
value
- Value to set.indices
- The indices of this matrix for which to set the value.- Returns:
- A reference to this tensor.
- Throws:
IllegalArgumentException
- If the number of indices is not equal to the rank of this tensor.IndexOutOfBoundsException
- If any of the indices are not within this tensor.
-
isReal
public boolean isReal()Checks if this vector contains only real entries.- Specified by:
isReal
in interfaceComplexTensorMixin<CooCVector,
CooVector> - Overrides:
isReal
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- True if this vector only contains real entries. Returns false if there is at least one entry with non-zero imaginary component.
-
isComplex
public boolean isComplex()Checks if this vector contains at least one non-real entry.- Specified by:
isComplex
in interfaceComplexTensorMixin<CooCVector,
CooVector> - Overrides:
isComplex
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- True if this vector contains at least one non-real entry. Returns false if all entries are real.
-
conj
Description copied from interface:ComplexTensorMixin
Computes the complex conjugate of a tensor.- Specified by:
conj
in interfaceComplexTensorMixin<CooCVector,
CooVector> - Overrides:
conj
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- The complex conjugate of this tensor.
-
toReal
Description copied from class:ComplexSparseTensorBase
Converts a complex tensor to a real matrix. The imaginary component of any complex value will be ignored.- Specified by:
toReal
in interfaceComplexTensorMixin<CooCVector,
CooVector> - Overrides:
toReal
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- A tensor of the same size containing only the real components of this tensor.
- See Also:
-
toRealSafe
Converts a complex tensor to a real matrix safely. That is, first checks if the tensor only contains real values and then converts to a real tensor. However, if non-real value exist, then an error is thrown.- Specified by:
toRealSafe
in interfaceComplexTensorMixin<CooCVector,
CooVector> - Overrides:
toRealSafe
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- A tensor of the same size containing only the real components of this tensor.
- Throws:
RuntimeException
- If this tensor contains at least one non-real value.- See Also:
-
toTensor
Converts this vector to an equivalent tensor.- Returns:
- A tensor which is equivalent to this vector.
-
set
Sets an index of this tensor to a specified value.- Specified by:
set
in interfaceTensorManipulationsMixin<CooCVector>
- Parameters:
value
- Value to set.indices
- The indices of this tensor for which to set the value.- Returns:
- A reference to this tensor.
-
reshape
Copies and reshapes tensor if possible. The total number of entries in this tensor must match the total number of entries in the reshaped tensor.- Specified by:
reshape
in interfaceTensorManipulationsMixin<CooCVector>
- Parameters:
shape
- Shape of the new tensor.- Returns:
- A tensor which is equivalent to this tensor but with the specified shape.
- Throws:
IllegalArgumentException
- If this tensor cannot be reshaped to the specified dimensions.
-
reshape
Copies and reshapes tensor if possible. The total number of entries in this tensor must match the total number of entries in the reshaped tensor.- Specified by:
reshape
in interfaceTensorManipulationsMixin<CooCVector>
- Overrides:
reshape
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Parameters:
shape
- Shape of the new tensor.- Returns:
- A tensor which is equivalent to this tensor but with the specified shape.
- Throws:
IllegalArgumentException
- If this tensor cannot be reshaped to the specified dimensions.
-
flatten
Flattens tensor to single dimension. To flatten tensor along a single axis.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CooCVector>
- Returns:
- The flattened tensor.
-
join
Joints specified vector with this vector.- Specified by:
join
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to join with this vector.- Returns:
- A vector resulting from joining the specified vector with this vector.
-
join
Joints specified vector with this vector.- Specified by:
join
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to join with this vector.- Returns:
- A vector resulting from joining the specified vector with this vector.
-
join
Joints specified vector with this vector.- Specified by:
join
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to join with this vector.- Returns:
- A vector resulting from joining the specified vector with this vector.
-
join
Joints specified vector with this vector.- Specified by:
join
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to join with this vector.- Returns:
- A vector resulting from joining the specified vector with this vector.
-
stack
Stacks two vectors along columns as if they were row vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack to the bottom of this vector.- Returns:
- The result of stacking this vector and vector
b
. - Throws:
IllegalArgumentException
-
- If the number of entries in this vector is different from the number of entries in the vectorb
.
-
stack
Stacks two vectors along columns as if they were row vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack to the bottom of this vector.- Returns:
- The result of stacking this vector and vector
b
. - Throws:
IllegalArgumentException
-
- If the number of entries in this vector is different from the number of entries in the vectorb
.
-
stack
Stacks two vectors along columns as if they were row vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack to the bottom of this vector.- Returns:
- The result of stacking this vector and vector
b
. - Throws:
IllegalArgumentException
-
- If the number of entries in this vector is different from the number of entries in the vectorb
.
-
stack
Stacks two vectors along columns as if they were row vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack to the bottom of this vector.- Returns:
- The result of stacking this vector and vector
b
. - Throws:
IllegalArgumentException
-
- If the number of entries in this vector is different from the number of entries in the vectorb
.
-
stack
Stacks two vectors along specified axis.
Stacking two vectors of length
n
along axis 0 stacks the vectors as if they were row vectors resulting in a2-by-n
matrix.Stacking two vectors of length
n
along axis 1 stacks the vectors as if they were column vectors resulting in an-by-2
matrix.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack with this vector.axis
- Axis along which to stack vectors. Ifaxis=0
, then vectors are stacked as if they are row vectors. Ifaxis=1
, then vectors are stacked as if they are column vectors.- Returns:
- The result of stacking this vector and the vector
b
. - Throws:
IllegalArgumentException
- If the number of entries in this vector is different from the number of entries in the vectorb
.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
Stacks two vectors along specified axis.
Stacking two vectors of length
n
along axis 0 stacks the vectors as if they were row vectors resulting in a2-by-n
matrix.Stacking two vectors of length
n
along axis 1 stacks the vectors as if they were column vectors resulting in an-by-2
matrix.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack with this vector.axis
- Axis along which to stack vectors. Ifaxis=0
, then vectors are stacked as if they are row vectors. Ifaxis=1
, then vectors are stacked as if they are column vectors.- Returns:
- The result of stacking this vector and the vector
b
. - Throws:
IllegalArgumentException
- If the number of entries in this vector is different from the number of entries in the vectorb
.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
Stacks two vectors along specified axis.
Stacking two vectors of length
n
along axis 0 stacks the vectors as if they were row vectors resulting in a2-by-n
matrix.Stacking two vectors of length
n
along axis 1 stacks the vectors as if they were column vectors resulting in an-by-2
matrix.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack with this vector.axis
- Axis along which to stack vectors. Ifaxis=0
, then vectors are stacked as if they are row vectors. Ifaxis=1
, then vectors are stacked as if they are column vectors.- Returns:
- The result of stacking this vector and the vector
b
. - Throws:
IllegalArgumentException
- If the number of entries in this vector is different from the number of entries in the vectorb
.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
Stacks two vectors along specified axis.
Stacking two vectors of length
n
along axis 0 stacks the vectors as if they were row vectors resulting in a2-by-n
matrix.Stacking two vectors of length
n
along axis 1 stacks the vectors as if they were column vectors resulting in an-by-2
matrix.- Specified by:
stack
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to stack with this vector.axis
- Axis along which to stack vectors. Ifaxis=0
, then vectors are stacked as if they are row vectors. Ifaxis=1
, then vectors are stacked as if they are column vectors.- Returns:
- The result of stacking this vector and the vector
b
. - Throws:
IllegalArgumentException
- If the number of entries in this vector is different from the number of entries in the vectorb
.IllegalArgumentException
- If axis is not either 0 or 1.
-
add
Computes the element-wise addition between this vector and the specified vector.- Specified by:
add
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to add to this vector.- Returns:
- The result of the element-wise vector addition.
- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
add
Computes the element-wise addition between this vector and the specified vector.- Specified by:
add
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to add to this vector.- Returns:
- The result of the element-wise vector addition.
- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
add
Computes the element-wise addition between this vector and the specified vector.- Specified by:
add
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to add to this vector.- Returns:
- The result of the element-wise vector addition.
- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
add
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Specified by:
add
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If this tensor and B have different shapes.
-
sub
Computes the element-wise subtraction between this vector and the specified vector.- Specified by:
sub
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to subtract from this vector.- Returns:
- The result of the element-wise vector subtraction.
- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
sub
Computes the element-wise subtraction between this vector and the specified vector.- Specified by:
sub
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to subtract from this vector.- Returns:
- The result of the element-wise vector subtraction.
- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
sub
Computes the element-wise subtraction between this vector and the specified vector.- Specified by:
sub
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to subtract from this vector.- Returns:
- The result of the element-wise vector subtraction.
- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
add
Adds specified value to all entries of this tensor.- Specified by:
add
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Parameters:
a
- Value to add to all entries of this tensor.- Returns:
- The result of adding the specified value to each entry of this tensor.
-
add
Adds specified value to all entries of this tensor.- Specified by:
add
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Parameters:
a
- Value to add to all entries of this tensor.- Returns:
- The result of adding the specified value to each entry of this tensor.
-
sub
Computes the element-wise subtraction between two tensors of the same rank.- Specified by:
sub
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Specified by:
sub
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Second tensor in element-wise subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If this tensor and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard multiplication) between this vector and a specified vector.- Specified by:
elemMult
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to element-wise multiply to this vector.- Returns:
- The vector resulting from the element-wise multiplication.
- Throws:
IllegalArgumentException
- If this vector andB
do not have the same size.
-
elemMult
Computes the element-wise multiplication (Hadamard multiplication) between this vector and a specified vector.- Specified by:
elemMult
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to element-wise multiply to this vector.- Returns:
- The vector resulting from the element-wise multiplication.
- Throws:
IllegalArgumentException
- If this vector andB
do not have the same size.
-
elemMult
Computes the element-wise multiplication (Hadamard multiplication) between this vector and a specified vector.- Specified by:
elemMult
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to element-wise multiply to this vector.- Returns:
- The vector resulting from the element-wise multiplication.
- Throws:
IllegalArgumentException
- If this vector andB
do not have the same size.
-
sub
Adds specified value to all entries of this tensor.- Specified by:
sub
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Parameters:
a
- Value to add to all entries of this tensor.- Returns:
- The result of adding the specified value to each entry of this tensor.
-
sub
Subtracts a specified value from all entries of this tensor.- Specified by:
sub
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Parameters:
a
- Value to subtract from all entries of this tensor.- Returns:
- The result of subtracting the specified value from each entry of this tensor.
-
makeTensor
A factory for creating a complex sparse tensor.- Specified by:
makeTensor
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Parameters:
shape
- Shape of the sparse tensor to make.entries
- Non-zero entries of the sparse tensor to make.indices
- Non-zero indices of the sparse tensor to make.- Returns:
- A tensor created from the specified parameters.
-
makeRealTensor
A factory for creating a real sparse tensor.- Specified by:
makeRealTensor
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Parameters:
shape
- Shape of the sparse tensor to make.entries
- Non-zero entries of the sparse tensor to make.indices
- Non-zero indices of the sparse tensor to make.- Returns:
- A tensor created from the specified parameters.
-
mult
Computes scalar multiplication of a tensor.- Specified by:
mult
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Overrides:
mult
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Parameters:
factor
- Scalar value to multiply with tensor.- Returns:
- The result of multiplying this tensor by the specified scalar.
-
mult
Computes scalar multiplication of a tensor.- Specified by:
mult
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Overrides:
mult
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Parameters:
factor
- Scalar value to multiply with tensor.- Returns:
- The result of multiplying this tensor by the specified scalar.
-
div
Computes the scalar division of a tensor.- Specified by:
div
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Overrides:
div
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Parameters:
divisor
- The scalar value to divide tensor by.- Returns:
- The result of dividing this tensor by the specified scalar.
- Throws:
ArithmeticException
- If divisor is zero.
-
div
Computes the scalar division of a tensor.- Specified by:
div
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Overrides:
div
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Parameters:
divisor
- The scalar value to divide tensor by.- Returns:
- The result of dividing this tensor by the specified scalar.
- Throws:
ArithmeticException
- If divisor is zero.
-
sqrt
Computes the element-wise square root of a tensor.- Specified by:
sqrt
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Overrides:
sqrt
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- The result of applying an element-wise square root to this tensor. Note, this method will compute the principle square root i.e. the square root with positive real part.
-
abs
Computes the element-wise absolute value/magnitude of a tensor. If the tensor contains complex values, the magnitude will be computed.- Specified by:
abs
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Overrides:
abs
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- The result of applying an element-wise absolute value/magnitude to this tensor.
-
transpose
Computes the transpose of a tensor. Same asT()
.- Specified by:
transpose
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Returns:
- The transpose of this tensor.
-
T
Computes the transpose of a tensor. Same astranspose()
.- Specified by:
T
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Returns:
- The transpose of this tensor.
-
recip
Computes the reciprocals, element-wise, of this sparse vector. However, all zero entries will remain zero.- Specified by:
recip
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Overrides:
recip
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- A sparse vector containing the reciprocal non-zero elements of this tensor.
- Throws:
ArithmeticException
- If this tensor contains any zeros.
-
get
Gets the element in this tensor at the specified indices.- Specified by:
get
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Parameters:
indices
- Indices of element.- Returns:
- The element at the specified indices.
- Throws:
IllegalArgumentException
- If the number of indices does not match the rank of this tensor.
-
copy
Creates a dense copy of this tensor.- Specified by:
copy
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Returns:
- A copy of this tensor.
-
elemMult
Computes the element-wise multiplication between two tensors.- Specified by:
elemMult
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Specified by:
elemMult
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Tensor to element-wise multiply to this tensor.- Returns:
- The result of the element-wise tensor multiplication.
- Throws:
IllegalArgumentException
- If this tensor andB
do not have the same shape.
-
elemDiv
Computes the element-wise division (Hadamard multiplication) between this vector and a specified vector.- Specified by:
elemDiv
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Vector to element-wise divide this vector by.- Returns:
- The vector resulting from the element-wise division.
- Throws:
IllegalArgumentException
- If this vector andB
do not have the same size.
-
elemDiv
Computes the element-wise division between two tensors.- Specified by:
elemDiv
in interfaceTensorOperationsMixin<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber> - Specified by:
elemDiv
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
B
- Tensor to element-wise divide with this tensor.- Returns:
- The result of the element-wise tensor multiplication.
- Throws:
IllegalArgumentException
- If this tensor andB
do not have the same shape.
-
inner
Computes the inner product between two vectors.- Specified by:
inner
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the inner product.- Returns:
- The inner product between this vector and the vector b.
- Throws:
IllegalArgumentException
- If this vector and vector b do not have the same number of entries.
-
inner
Computes the inner product between two vectors.- Specified by:
inner
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the inner product.- Returns:
- The inner product between this vector and the vector b.
- Throws:
IllegalArgumentException
- If this vector and vector b do not have the same number of entries.
-
normalize
Computes a unit vector in the same direction as this vector.- Specified by:
normalize
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Returns:
- A unit vector with the same direction as this vector. If this vector is zeros, then an equivalently sized zero vector will be returned.
-
inner
Computes the inner product between two vectors.- Specified by:
inner
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the inner product.- Returns:
- The inner product between this vector and the vector b.
- Throws:
IllegalArgumentException
- If this vector and vector b do not have the same number of entries.
-
inner
Computes the inner product between two vectors.- Specified by:
inner
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the inner product.- Returns:
- The inner product between this vector and the vector b.
- Throws:
IllegalArgumentException
- If this vector and vector b do not have the same number of entries.
-
outer
Computes the outer product of two vectors.- Specified by:
outer
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the outer product.- Returns:
- The result of the vector outer product between this vector and b.
- Throws:
IllegalArgumentException
- If the two vectors do not have the same number of entries.
-
outer
Computes the outer product of two vectors.- Specified by:
outer
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the outer product.- Returns:
- The result of the vector outer product between this vector and b.
- Throws:
IllegalArgumentException
- If the two vectors do not have the same number of entries.
-
outer
Computes the outer product of two vectors.- Specified by:
outer
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the outer product.- Returns:
- The result of the vector outer product between this vector and b.
- Throws:
IllegalArgumentException
- If the two vectors do not have the same number of entries.
-
outer
Computes the outer product of two vectors.- Specified by:
outer
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Second vector in the outer product.- Returns:
- The result of the vector outer product between this vector and b.
- Throws:
IllegalArgumentException
- If the two vectors do not have the same number of entries.
-
isParallel
Checks if a vector is parallel to this vector.- Specified by:
isParallel
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to compare to this vector.- Returns:
- True if the vector
b
is parallel to this vector and the same size. Otherwise, returns false.
-
isPerp
Checks if a vector is perpendicular to this vector.- Specified by:
isPerp
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
b
- Vector to compare to this vector.- Returns:
- True if the vector
b
is perpendicular to this vector and the same size. Otherwise, returns false.
-
toMatrix
Converts a vector to an equivalent matrix.- Specified by:
toMatrix
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Returns:
- A matrix equivalent to this vector. This method will respect the orientation of the vector. That is, if this vector is a row vector, then the resulting matrix will have a single row. If this vector is a column vector, then the resulting matrix will have a single column.
-
toMatrix
Converts a vector to an equivalent matrix representing either a row or column vector.- Specified by:
toMatrix
in interfaceVectorOperationsMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
columVector
- Flag for choosing whether to convert this vector to a matrix representing a row or column vector.If true, the vector will be converted to a matrix representing a column vector.
If false, The vector will be converted to a matrix representing a row vector.
- Returns:
- A matrix equivalent to this vector.
-
argMin
public int[] argMin()Finds the indices of the minimum value in this tensor.- Specified by:
argMin
in interfaceTensorPropertiesMixin
- Overrides:
argMin
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- The indices of the minimum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
argMax
public int[] argMax()Finds the indices of the maximum value in this tensor.- Specified by:
argMax
in interfaceTensorPropertiesMixin
- Overrides:
argMax
in classComplexSparseTensorBase<CooCVector,
CVector, CooVector> - Returns:
- The indices of the maximum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
flatten
Flattens a tensor along the specified axis. Since a vector only has 1 axis, this simply copies the vector.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CooCVector>
- Parameters:
axis
- Axis along which to flatten tensor.- Throws:
IllegalArgumentException
- If the axis is not positive or larger thanthis.
.TensorBase.getRank()
-1
-
size
public int size()Gets the full size of this vector (including non-zero entries).- Specified by:
size
in interfaceVectorMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Returns:
- The full size of this vector.
-
repeat
Repeats a vectorn
times along a certain axis to create a matrix.- Specified by:
repeat
in interfaceVectorMixin<CooCVector,
CVector, CooCVector, CooCVector, CNumber, CooCMatrix, CMatrix, CooCMatrix> - Parameters:
n
- Number of times to repeat vector.axis
- Axis along which to repeat vector. Ifaxis=0
then each row of the resulting matrix will be equivalent to this vector. Ifaxis=1
then each column of the resulting matrix will be equivalent to this vector.- Returns:
- A matrix whose rows/columns are this vector repeated.
-
toDense
Converts this sparse tensor to an equivalent dense tensor.- Specified by:
toDense
in classSparseTensorBase<CooCVector,
CVector, CooCVector, CVector, CooVector, CNumber[], CNumber> - Returns:
- A dense tensor which is equivalent to this sparse tensor.
-
extend
Extends a vector a specified number of times to a matrix.- Specified by:
extend
in interfaceVectorManipulationsMixin<CooCMatrix>
- Parameters:
n
- The number of times to extend this vector.axis
- Axis along which to extend vector.- Returns:
- A matrix which is the result of extending a vector
n
times.
-
length
public int length()Gets the length of a vector.- Specified by:
length
in interfaceVectorPropertiesMixin
- Returns:
- The length, i.e. the number of entries, in this vector.
-
toString
-