Package org.djunits.vecmat.d2
Class Vector2.Row<Q extends Quantity<Q,U>,U extends UnitInterface<U,Q>>
java.lang.Object
org.djunits.vecmat.def.VectorMatrix<Q,U,M,SI,H>
org.djunits.vecmat.def.Matrix<Q,U,V,SI,H>
org.djunits.vecmat.def.Vector<Q,U,V,SI,H>
org.djunits.vecmat.d2.Vector2<Q,U,Vector2.Row<Q,U>,Vector2.Row<SIQuantity,SIUnit>,Vector2.Row<?,?>>
org.djunits.vecmat.d2.Vector2.Row<Q,U>
- Type Parameters:
Q- the quantity typeU- the unit type
- All Implemented Interfaces:
Serializable,Iterable<Q>,Additive<Vector2.Row<Q,,U>> Scalable<Vector2.Row<Q,,U>> Value<U,,Vector2.Row<Q, U>> Hadamard<Vector2.Row<?,,?>, Vector2.Row<SIQuantity, SIUnit>> Normed<Q,,U> VectorTransposable<Vector2.Col<Q,U>>
- Enclosing class:
- Vector2<Q extends Quantity<Q,
U>, U extends UnitInterface<U, Q>, V extends Vector2<Q, U, V, SI, H>, SI extends Vector2<SIQuantity, SIUnit, SI, ?, ?>, H extends Vector2<?, ?, ?, ?, ?>>
public static class Vector2.Row<Q extends Quantity<Q,U>,U extends UnitInterface<U,Q>>
extends Vector2<Q,U,Vector2.Row<Q,U>,Vector2.Row<SIQuantity,SIUnit>,Vector2.Row<?,?>>
implements VectorTransposable<Vector2.Col<Q,U>>
Vector2.Row implements a row vector with two real-valued entries. The vector is immutable, except for the display unit,
which can be changed.
Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.
- Author:
- Alexander Verbraeck
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.djunits.vecmat.d2.Vector2
Vector2.Col<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<TQ extends Quantity<TQ,TU>, TU extends UnitInterface<TU, TQ>>
Vector2.Row<TQ,TU> as(TU targetUnit) Return the vector 'as' a vector with a known quantity, using a unit to express the result in.intcols()Return the number of columns.divideElements(Vector2.Row<?, ?> other) Divide the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).double[]getColumnSi(int col) Return an array with SI-values for the given column (0-based) from the vector or matrix.getColumnVector(int col) Return a quantity column (0-based) from the vector or matrix.double[]getRowSi(int row) Return an array with SI-values for the given row (0-based) from the vector or matrix.getRowVector(int row) Return a quantity row (0-based) from the vector or matrix.instantiateSi(double[] siNew, SIUnit siUnit) Return a new vector or matrix in SI-units with the given SI or BASE values.protected Vector2.Row<Q,U> instantiateSi(double xSi, double ySi) Return a column or row vector with x and y values in SI or BASE units.Invert the vector, matrix or table on an element-by-element basis.booleanReturn whether this vector is a column vector.mgetColumnVector(int mCol) Return a quantity column (1-based) from the vector or matrix.mgetRowVector(int mRow) Return a quantity row (1-based) from the vector or matrix.Multiply this row vector with a matrix, resulting in a column vector.multiply(Vector2.Col<?, ?> otherVec) Multiply this row vector with a column vector, resulting in a scalar quantity.multiplyElements(Quantity<?, ?> quantity) Multiply the elements of this vector, matrix or table by the given quantity.multiplyElements(Vector2.Row<?, ?> other) Multiply the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).static <Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>>
Vector2.Row<Q,U> of(double xInUnit, double yInUnit, U displayUnit) Create a Vector2 row vector without needing generics.introws()Return the number of rows.doublesi(int row, int col) Return the si-value at position (row, col), where both row and col are 0-based values.Transpose the vector (swap rows and columns).Methods inherited from class org.djunits.vecmat.d2.Vector2
abs, add, add, equals, getScalarArray, hashCode, instantiateSi, isRelative, iterator, max, mean, median, min, mode, negate, normL1, normL2, normLinf, normLp, scaleBy, si, si, size, subtract, subtract, sum, toString, toString, x, xSi, y, ySiMethods inherited from class org.djunits.vecmat.def.Matrix
checkMultiply, checkMultiply, multiplyMethods inherited from class org.djunits.vecmat.def.VectorMatrix
asMatrixNxM, asQuantityTable, checkCol, checkRow, divideElements, get, getColumnScalars, getDisplayUnit, getRowScalars, getScalarGrid, mcheckCol, mcheckRow, mget, mgetColumnScalars, mgetColumnSi, mgetRowScalars, mgetRowSi, msi, multiplyElements, setDisplayUnitMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djunits.vecmat.operations.Hadamard
divideElementsMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.djunits.value.Value
isAbsolute, setDisplayUnit
-
Constructor Details
-
Row
Create a new 2 row vector with a unit.- Parameters:
xInUnit- the x-value expressed in the given unityInUnit- the y-value expressed in the given unitdisplayUnit- the display unit to use
-
-
Method Details
-
of
public static <Q extends Quantity<Q,U>, Vector2.Row<Q,U extends UnitInterface<U, Q>> U> of(double xInUnit, double yInUnit, U displayUnit) Create a Vector2 row vector without needing generics.- Type Parameters:
Q- the quantity typeU- the unit type- Parameters:
xInUnit- the x-value expressed in the display unityInUnit- the y-value expressed in the display unitdisplayUnit- the display unit to use- Returns:
- a new Vector2 with a unit
-
isColumnVector
public boolean isColumnVector()Description copied from class:Vector2Return whether this vector is a column vector.- Specified by:
isColumnVectorin classVector2<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Returns:
- whether this vector is a column vector
-
rows
public int rows()Description copied from class:VectorMatrixReturn the number of rows.- Specified by:
rowsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Returns:
- the number of rows
-
cols
public int cols()Description copied from class:VectorMatrixReturn the number of columns.- Specified by:
colsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Returns:
- the number of columns
-
instantiateSi
Description copied from class:Vector2Return a column or row vector with x and y values in SI or BASE units.- Specified by:
instantiateSiin classVector2<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
xSi- the x value in SI or BASE unitsySi- the y value in SI or BASE units- Returns:
- a new column or row vector with adapted x and y values
-
instantiateSi
Description copied from class:VectorMatrixReturn a new vector or matrix in SI-units with the given SI or BASE values.- Specified by:
instantiateSiin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
siNew- the values for the new vector or matrix in row-major formatsiUnit- the new unit for the new vector or matrix- Returns:
- a new matrix with the provided SI or BASE values
-
si
Description copied from class:VectorMatrixReturn the si-value at position (row, col), where both row and col are 0-based values.- Specified by:
siin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
row- the row (0-based)col- the column (0-based)- Returns:
- the si-value at position (row, col)
- Throws:
IndexOutOfBoundsException- when row or col < 0 or larger than number of rows/columns - 1.
-
getRowVector
Description copied from class:VectorMatrixReturn a quantity row (0-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
getRowVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
row- the row number to retrieve (0-based)- Returns:
- a row vector with the data at the given row
-
mgetRowVector
Description copied from class:VectorMatrixReturn a quantity row (1-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
mgetRowVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
mRow- the row number to retrieve (1-based)- Returns:
- a row vector with the data at the given row
-
getColumnVector
Description copied from class:VectorMatrixReturn a quantity column (0-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
getColumnVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
col- the column number to retrieve (0-based)- Returns:
- a column vector with the data at the given column
-
mgetColumnVector
Description copied from class:VectorMatrixReturn a quantity column (1-based) from the vector or matrix. Note that the specific vector to return can be tightened by the implementing class.- Specified by:
mgetColumnVectorin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
mCol- the column number to retrieve (1-based)- Returns:
- a column vector with the data at the given column
-
getRowSi
public double[] getRowSi(int row) Description copied from class:VectorMatrixReturn an array with SI-values for the given row (0-based) from the vector or matrix.- Specified by:
getRowSiin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
row- the row number to retrieve (0-based)- Returns:
- an array with SI-values with the data at the given row
-
getColumnSi
public double[] getColumnSi(int col) Description copied from class:VectorMatrixReturn an array with SI-values for the given column (0-based) from the vector or matrix.- Specified by:
getColumnSiin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
col- the column number to retrieve (0-based)- Returns:
- an array with SI-values with the data at the given column
-
transpose
Description copied from interface:VectorTransposableTranspose the vector (swap rows and columns). -
invertElements
Description copied from interface:HadamardInvert the vector, matrix or table on an element-by-element basis.- Specified by:
invertElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
invertElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Returns:
- a vector, matrix or table with an element-by-element inversion (1/value) of the elements
-
multiplyElements
Description copied from interface:HadamardMultiply the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).- Specified by:
multiplyElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
multiplyElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
other- the other collection of the same type- Returns:
- a vector, matrix or table with an element-by-element multiplication of its elements
-
divideElements
Description copied from interface:HadamardDivide the elements of this vector, matrix or table on an element-by-element basis with those of another collection of the same type (but possibly representing another quantity).- Specified by:
divideElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
divideElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
other- the other collection of the same type- Returns:
- a vector, matrix or table with an element-by-element division of this collection's elements and other's elements
-
multiply
Multiply this row vector with a column vector, resulting in a scalar quantity.- Parameters:
otherVec- the column vector to multiply with- Returns:
- the resulting matrix from the multiplication
-
multiply
Multiply this row vector with a matrix, resulting in a column vector.- Parameters:
otherMat- the matrix to multiply with- Returns:
- the resulting column vector from the multiplication
-
multiplyElements
Description copied from interface:HadamardMultiply the elements of this vector, matrix or table by the given quantity.- Specified by:
multiplyElementsin interfaceHadamard<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
multiplyElementsin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, Vector2.Row<Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>>, Vector2.Row<SIQuantity, SIUnit>, Vector2.Row<?, ?>> - Parameters:
quantity- the scalar quantity to multiply by- Returns:
- a vector, matrix or table where the elements have been multiplied by the given quantity
-
as
public <TQ extends Quantity<TQ,TU>, Vector2.Row<TQ,TU extends UnitInterface<TU, TQ>> TU> as(TU targetUnit) throws IllegalArgumentException Return the vector 'as' a vector with a known quantity, using a unit to express the result in. Throw a Runtime exception when the SI units of this vector and the target vector do not match.- Type Parameters:
TQ- target quantity typeTU- target unit type- Parameters:
targetUnit- the unit to convert the vector to- Returns:
- a quantity typed in the target vector class
- Throws:
IllegalArgumentException- when the units do not match
-