Package edu.wpi.first.math
Class Vector<R extends Num>
- Type Parameters:
R
- The number of rows in this matrix.
public class Vector<R extends Num> extends Matrix<R,N1>
A shape-safe wrapper over Efficient Java Matrix Library (EJML) matrices.
This class is intended to be used alongside the state space library.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Vector(Matrix<R,N1> other)
Constructs a new vector with the storage of the supplied matrix.Vector(Nat<R> rows)
Constructs an empty zero vector of the given dimensions.Vector(org.ejml.simple.SimpleMatrix storage)
Constructs a newVector
with the given storage. -
Method Summary
Modifier and Type Method Description static Vector<N3>
cross(Vector<N3> a, Vector<N3> b)
Returns the cross product of 3 dimensional vectors a and b.Vector<R>
div(double value)
Divides all elements of this matrix by the given value.Vector<R>
div(int value)
Divides all elements of this matrix by the given value.double
dot(Vector<R> other)
Returns the dot product of this vector with another.double
get(int row)
Returns an element of the vector at a specified row.Vector<R>
minus(Vector<R> value)
Subtracts the given vector to this vector.double
norm()
Returns the norm of this vector.Vector<R>
plus(Vector<R> value)
Adds the given vector to this vector.Vector<R>
projection(Vector<R> other)
Returns the projection of this vector along another.Vector<R>
times(double value)
Multiplies all the elements of this matrix by the given scalar.Vector<R>
unit()
Returns the unit vector parallel with this vector.Methods inherited from class edu.wpi.first.math.Matrix
assignBlock, block, block, changeBoundsUnchecked, copy, det, diag, elementPower, elementPower, elementSum, elementTimes, equals, exp, extractColumnVector, extractFrom, extractRowVector, eye, eye, fill, get, getData, getNumCols, getNumRows, getStorage, hashCode, inv, isEqual, isIdentical, lltDecompose, mat, max, maxAbs, mean, minInternal, minus, minus, normF, normIndP1, plus, plus, pow, rankUpdate, set, setColumn, setRow, solve, solveFullPivHouseholderQr, times, toString, trace, transpose
-
Constructor Details
-
Vector
Constructs an empty zero vector of the given dimensions.- Parameters:
rows
- The number of rows of the vector.
-
Vector
Constructs a newVector
with the given storage. Caller should make sure that the provided generic bounds match the shape of the providedVector
.NOTE:It is not recommended to use this constructor unless the
SimpleMatrix
API is absolutely necessary due to the desired function not being accessible through theVector
wrapper.- Parameters:
storage
- TheSimpleMatrix
to back this vector.
-
Vector
Constructs a new vector with the storage of the supplied matrix.- Parameters:
other
- TheVector
to copy the storage of.
-
-
Method Details
-
get
Returns an element of the vector at a specified row.- Parameters:
row
- The row that the element is located at.- Returns:
- An element of the vector.
-
times
Description copied from class:Matrix
Multiplies all the elements of this matrix by the given scalar. -
div
Description copied from class:Matrix
Divides all elements of this matrix by the given value. -
div
Description copied from class:Matrix
Divides all elements of this matrix by the given value. -
plus
Adds the given vector to this vector.- Parameters:
value
- The vector to add.- Returns:
- The resultant vector.
-
minus
Subtracts the given vector to this vector.- Parameters:
value
- The vector to add.- Returns:
- The resultant vector.
-
dot
Returns the dot product of this vector with another.- Parameters:
other
- The other vector.- Returns:
- The dot product.
-
norm
Returns the norm of this vector.- Returns:
- The norm.
-
unit
Returns the unit vector parallel with this vector.- Returns:
- The unit vector.
-
projection
Returns the projection of this vector along another.- Parameters:
other
- The vector to project along.- Returns:
- The projection.
-
cross
Returns the cross product of 3 dimensional vectors a and b.- Parameters:
a
- The vector to cross with b.b
- The vector to cross with a.- Returns:
- The cross product of a and b.
-