Class CVector
- All Implemented Interfaces:
Serializable
,ComplexTensorMixin<CVector,
,Vector> DenseMixin<CNumber>
,DenseVectorMixin
,TensorComparisonsMixin
,TensorManipulationsMixin<CVector>
,TensorOperationsMixin<CVector,
,CVector, CVector, CVector, Vector, CNumber> TensorPropertiesMixin
,VectorComparisonsMixin
,VectorManipulationsMixin<CMatrix>
,VectorMixin<CVector,
,CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> VectorOperationsMixin<CVector,
,CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> VectorPropertiesMixin
- See Also:
-
Field Summary
Fields inherited from class org.flag4j.core.TensorBase
DEFAULT_ROUND_TO_ZERO_THRESHOLD, entries, shape
-
Constructor Summary
ConstructorDescriptionCVector
(double... entries) Creates a vector with specified entries.CVector
(int size) Creates a column vector of specified size filled with zeros.CVector
(int... entries) Creates a vector with specified entries.CVector
(int size, double fillValue) Creates a vector of specified size filled with a specified value.Creates a vector of specified size filled with a specified value.Constructs a complex vector whose entries and shape are specified by another complex vector.Constructs a complex vector whose entries and shape are specified by another real vector.Creates a vector with specified entries. -
Method Summary
Modifier and TypeMethodDescriptionComputes the element-wise addition between this vector and the specified vector.add
(CooCVector B) Computes the element-wise addition between this vector and the specified vector.Computes the element-wise addition between this vector and the specified vector.void
Computes the element-wise addition between this vector and the specified vector and stores the result in this vector.void
addEq
(CooCVector B) Computes the element-wise addition between this vector and the specified vector and stores the result in this vector.void
Computes the element-wise addition between this vector and the specified vector.Computes the vector cross product between two vectors.Computes the vector cross product between two vectors.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 (Hadamard multiplication) between this vector and a specified vector.boolean
Checks if an object is equal to this vector object.extend
(int n, int axis) Extends a vector a specified number of times to a matrix.flatten()
Since vectors are rank 1 tensors, this method simply copies the vector.flatten
(int axis) Flattens a tensor along the specified axis.static CVector
getEmpty
(int size) Constructs an empty complex dense vector whose entries arenull
.protected CVector
getSelf()
Simply returns a reference of this tensor.H()
Computes the conjugate transpose of this vector.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.double
Computes the inner product between two vectors.boolean
isParallel
(Vector b) Checks if a vector is parallel to this vector.boolean
Checks if a vector is perpendicular to this vector.Creates a new vector which is the result of joining the 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 Vector
makeRealTensor
(Shape shape, double[] entries) Factory to create a real tensor with the specified shape and size.protected CVector
makeTensor
(Shape shape, CNumber[] entries) Factory to create a tensor with the specified shape and size.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.repeat
(int n, int axis) Repeats a vectorn
times along a certain axis to create a matrix.Since vectors are rank 1 tensors, this method simply copies the vector.int
size()
gets the size of this vector.Stacks two vectors along columns as if they are column vectors.Stacks two vectors along specified axis.Stacks two vectors along columns as if they are column vectors.Stacks two vectors along specified axis.stack
(CooCVector b) Stacks two vectors along columns as if they are column vectors.stack
(CooCVector b, int axis) Stacks two vectors along specified axis.Stacks two vectors along columns as if they are column vectors.Stacks two vectors along specified axis.Computes the element-wise addition between this vector and the specified vector.sub
(CooCVector B) Computes the element-wise addition between this vector and the specified vector.Computes the element-wise addition between this vector and the specified vector.void
Computes the element-wise subtraction between this vector and the specified vector and stores the result in this vector.void
subEq
(CooCVector B) Computes the element-wise subtraction between this vector and the specified vector and stores the result in this vector.void
Computes the element-wise addition between this vector and the specified vector.T()
Computes the transpose of a tensor.toCoo()
Converts this dense vector to an equivalentCooCVector
.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.toString()
Generates a human-readable string representation of this vector.toTensor()
Creates a rank 1 tensor which is equivalent to this vector.Methods inherited from class org.flag4j.core.dense_base.ComplexDenseTensorBase
abs, add, add, add, addEq, addEq, addEq, allClose, argMax, argMin, conj, copy, div, div, elemDiv, elemMult, get, hashCode, isComplex, isOnes, isReal, isZeros, max, maxAbs, min, minAbs, mult, mult, recip, reshape, round, round, roundToZero, roundToZero, set, set, sqrt, sub, sub, sub, subEq, subEq, subEq, sum, toReal, toRealSafe
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, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.core.ComplexTensorMixin
hermTranspose
Methods inherited from interface org.flag4j.core.TensorOperationsMixin
transpose
Methods inherited from interface org.flag4j.core.VectorOperationsMixin
add, elemDiv, elemMult, sub
Methods inherited from interface org.flag4j.core.VectorPropertiesMixin
maxAbs
-
Field Details
-
size
public final int sizeThe size of this vector. That is, the total number of entries in this vector.
-
-
Constructor Details
-
CVector
public CVector(int size) Creates a column vector of specified size filled with zeros.- Parameters:
size
- Size of the vector.
-
CVector
public CVector(int size, double fillValue) Creates a vector of specified size filled with a specified value.- Parameters:
size
- Size of the vector.fillValue
- Value to fill vector with.
-
CVector
Creates a vector of specified size filled with a specified value.- Parameters:
size
- Size of the vector.fillValue
- Value to fill vector with.
-
CVector
public CVector(double... entries) Creates a vector with specified entries.- Parameters:
entries
- Entries for this column vector.
-
CVector
public CVector(int... entries) Creates a vector with specified entries.- Parameters:
entries
- Entries for this column vector.
-
CVector
Creates a vector with specified entries.- Parameters:
entries
- Entries for this column vector.
-
CVector
Constructs a complex vector whose entries and shape are specified by another real vector.- Parameters:
a
- Real vector to copy.
-
CVector
Constructs a complex vector whose entries and shape are specified by another complex vector.- Parameters:
a
- Complex vector to copy.
-
-
Method Details
-
getEmpty
Constructs an empty complex dense vector whose entries arenull
. Note, this is in contrast toCVector(int)
which constructs the zero vector of a specified length.- Parameters:
size
- Size of the empty vector to construct.- Returns:
- An empty dense complex vector containing null values.
- Throws:
NegativeArraySizeException
- If size is negative.
-
equals
Checks if an object is equal to this vector object.- Specified by:
equals
in interfaceTensorComparisonsMixin
- Overrides:
equals
in classObject
- Parameters:
object
- Object to check equality with this vector.- Returns:
- True if the two vectors have the same shape, are numerically equivalent, and are of type
CVector
. False otherwise.
-
add
Computes the element-wise addition between this vector and the specified vector.- Specified by:
add
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
addEq
Computes the element-wise addition between this vector and the specified vector and stores the result in this vector.- Specified by:
addEq
in interfaceDenseVectorMixin
- Parameters:
B
- Vector to add to this vector.- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
subEq
Computes the element-wise subtraction between this vector and the specified vector and stores the result in this vector.- Specified by:
subEq
in interfaceDenseVectorMixin
- Parameters:
B
- Vector to subtract this vector.- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
sub
Computes the element-wise addition between this vector and the specified vector.- Specified by:
sub
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
sub
Computes the element-wise addition between this vector and the specified vector.- Specified by:
sub
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
sub
Computes the element-wise addition between this vector and the specified vector.- Specified by:
sub
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
addEq
Computes the element-wise addition between this vector and the specified vector.- Specified by:
addEq
in interfaceDenseVectorMixin
- Parameters:
B
- Vector to add to this vector.- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
addEq
Computes the element-wise addition between this vector and the specified vector and stores the result in this vector.- Parameters:
B
- Vector to add to this vector.- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
subEq
Computes the element-wise addition between this vector and the specified vector.- Specified by:
subEq
in interfaceDenseVectorMixin
- Parameters:
B
- Vector to add to this vector.- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
subEq
Computes the element-wise subtraction between this vector and the specified vector and stores the result in this vector.- Parameters:
B
- Vector to add to this vector.- Throws:
IllegalArgumentException
- If this vector and the specified vector have different lengths.
-
elemMult
Computes the element-wise multiplication (Hadamard multiplication) between this vector and a specified vector.- Specified by:
elemMult
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
elemDiv
Computes the element-wise division (Hadamard multiplication) between this vector and a specified vector.- Specified by:
elemDiv
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
T
Computes the transpose of a tensor. Same asTensorOperationsMixin.transpose()
. This has no effect on a vector. -
makeRealTensor
Factory to create a real tensor with the specified shape and size.- Specified by:
makeRealTensor
in classComplexDenseTensorBase<CVector,
Vector> - Parameters:
shape
- Shape of the tensor to make.entries
- Entries of the tensor to make.- Returns:
- A new tensor with the specified shape and entries.
-
extend
Extends a vector a specified number of times to a matrix.- Specified by:
extend
in interfaceVectorManipulationsMixin<CMatrix>
- Parameters:
n
- The number of times to extend this vector.axis
- Axis along which to extend vector. If axis=0 this vector is treated as a row vector and extended along rows. If axis=1 this vector is treated as a column vector and extended along the columns.- Returns:
- A matrix which is the result of extending a vector
n
times.
-
join
Joints specified vector with this vector.- Specified by:
join
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - Parameters:
b
- Vector to join with this vector.- Returns:
- A vector resulting from joining the specified vector with this vector.
-
join
Creates a new vector which is the result of joining the specified vector with this vector.- Specified by:
join
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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 are column vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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 vector b.
-
stack
Stacks two vectors along columns as if they are column vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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 vector b.
-
stack
Stacks two vectors along columns as if they are column vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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 vector b.
-
stack
Stacks two vectors along columns as if they are column vectors.- Specified by:
stack
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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 vector b.
-
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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
inner
Computes the inner product between two vectors.- Specified by:
inner
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
innerSelf
public double innerSelf()Computes the inner product between two vectors.- Returns:
- The inner product between this vector and the vector b.
-
inner
Computes the inner product between two vectors.- Specified by:
inner
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
cross
Computes the vector cross product between two vectors.- Parameters:
b
- Second vector in the cross product.- Returns:
- The result of the vector cross product between this vector and b.
- Throws:
IllegalArgumentException
- If either this vector or b do not have 3 entries.
-
cross
Computes the vector cross product between two vectors.- Parameters:
b
- Second vector in the cross product.- Returns:
- The result of the vector cross product between this vector and b.
- Throws:
IllegalArgumentException
- If either this vector or b do not have 3 entries.
-
outer
Computes the outer product of two vectors.- Specified by:
outer
in interfaceVectorOperationsMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
toTensor
Creates a rank 1 tensor which is equivalent to this vector.- Returns:
- A rank 1 tensor equivalent to this vector.
-
toCoo
Converts this dense vector to an equivalentCooCVector
. Note, this is likely only worthwhile for very sparse vectors.- Specified by:
toCoo
in classDenseTensorBase<CVector,
CVector, Vector, CNumber[], CNumber> - Returns:
- A
CooCVector
that is equivalent to this dense vector.
-
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.
-
H
Computes the conjugate transpose of this vector. Since a vector is a rank 1 tensor, this simply computes the complex conjugate of this vector.- Specified by:
H
in interfaceComplexTensorMixin<CVector,
Vector> - Returns:
- The complex conjugate of this vector.
-
reshape
Since vectors are rank 1 tensors, this method simply copies the vector.- Specified by:
reshape
in interfaceTensorManipulationsMixin<CVector>
- Overrides:
reshape
in classComplexDenseTensorBase<CVector,
Vector> - 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
Since vectors are rank 1 tensors, this method simply copies the vector.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CVector>
- Returns:
- The flattened tensor.
-
flatten
Flattens a tensor along the specified axis.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CVector>
- 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 size of this vector.- Specified by:
size
in interfaceVectorMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - Returns:
- The total number of entries in this vector.
-
repeat
Repeats a vectorn
times along a certain axis to create a matrix.- Specified by:
repeat
in interfaceVectorMixin<CVector,
CVector, CooCVector, CVector, CNumber, CMatrix, CMatrix, CMatrix> - 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.
-
makeTensor
Factory to create a tensor with the specified shape and size.- Specified by:
makeTensor
in classDenseTensorBase<CVector,
CVector, Vector, CNumber[], CNumber> - Parameters:
shape
- Shape of the tensor to make.entries
- Entries of the tensor to make.- Returns:
- A new tensor with the specified shape and entries.
-
getSelf
-
toString
-