Package org.djunits.vecmat.dn
Class VectorN<Q extends Quantity<Q,U>,U extends UnitInterface<U,Q>,V extends VectorN<Q,U,V,SI,H>,SI extends VectorN<SIQuantity,SIUnit,SI,?,?>,H extends VectorN<?,?,?,?,?>>
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.dn.VectorN<Q,U,V,SI,H>
- Type Parameters:
Q- the quantity typeU- the unit typeV- the vector type (Row or Col)SI- the vector type with generics <SIQuantity, SIUnit<H- the generic vector type with generics <?, ?< for Hadamard operations
- All Implemented Interfaces:
Serializable,Iterable<Q>,Additive<V>,Scalable<V>,Value<U,,V> Hadamard<H,,SI> Normed<Q,U>
- Direct Known Subclasses:
VectorN.Col,VectorN.Row
public abstract class VectorN<Q extends Quantity<Q,U>,U extends UnitInterface<U,Q>,V extends VectorN<Q,U,V,SI,H>,SI extends VectorN<SIQuantity,SIUnit,SI,?,?>,H extends VectorN<?,?,?,?,?>>
extends Vector<Q,U,V,SI,H>
VectorN.java.
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 ClassesModifier and TypeClassDescriptionstatic classVectorN.Col<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> VectorN.Col implements a column vector with real-valued entries.static classVectorN.Row<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> VectorN.Row implements a row vector with real-valued entries. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataGridSi<?>The data of the matrix, in SI unit. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedVectorN(DataGridSi<?> dataSi, U displayUnit) Create a new VectorN with a unit, based on a DataGridSi storage object that contains SI data. -
Method Summary
Modifier and TypeMethodDescriptionintcols()Return the number of columns.booleanQ[]Return the vector as an array of scalars.inthashCode()iterator()Create and return an iterator over the scalars in this vector in proper sequence.normL1()Return the L1-norm of this element, expressed as a quantity.normL2()Return the L2-norm of this element, expressed as a quantity.normLinf()Return the L∞-norm of this element, expressed as a quantity.normLp(int p) Return the Lp-norm of this element, expressed as a quantity.introws()Return the number of rows.double[]si()Return a row-major array of SI-values for this matrix or vector.doublesi(int row, int col) Return the si-value at position (row, col), where both row and col are 0-based values.toString()Return a concise description of this value.Return a concise description of this value with the values expressed in the specified unit.Methods inherited from class org.djunits.vecmat.def.Matrix
checkMultiply, checkMultiply, multiplyMethods inherited from class org.djunits.vecmat.def.VectorMatrix
abs, add, add, asMatrixNxM, asQuantityTable, checkCol, checkRow, divideElements, divideElements, get, getColumnScalars, getColumnSi, getColumnVector, getDisplayUnit, getRowScalars, getRowSi, getRowVector, getScalarGrid, instantiateSi, instantiateSi, invertElements, isRelative, max, mcheckCol, mcheckRow, mean, median, mget, mgetColumnScalars, mgetColumnSi, mgetColumnVector, mgetRowScalars, mgetRowSi, mgetRowVector, min, mode, msi, multiplyElements, multiplyElements, multiplyElements, negate, scaleBy, setDisplayUnit, subtract, subtract, sumMethods 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
-
Field Details
-
dataSi
The data of the matrix, in SI unit.
-
-
Constructor Details
-
VectorN
Create a new VectorN with a unit, based on a DataGridSi storage object that contains SI data.- Parameters:
dataSi- the data of the vector, in SI unit.displayUnit- the display unit to use- Throws:
IllegalArgumentException- when the number of rows or columns does not have a positive value
-
-
Method Details
-
iterator
Description copied from class:VectorCreate and return an iterator over the scalars in this vector in proper sequence.- Specified by:
iteratorin interfaceIterable<Q extends Quantity<Q,U>> - Specified by:
iteratorin classVector<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, V extends VectorN<Q, U, V, SI, H>, SI extends VectorN<SIQuantity, SIUnit, SI, ?, ?>, H extends VectorN<?, ?, ?, ?, ?>> - Returns:
- an iterator over the scalars in this vector in proper sequence
-
getScalarArray
Description copied from class:VectorReturn the vector as an array of scalars. -
normL1
Description copied from interface:NormedReturn the L1-norm of this element, expressed as a quantity. The L1-norm is |x1| + |x2| + ... + |xn|.- Returns:
- the L1-norm of this element, expressed as a quantity
-
normL2
Description copied from interface:NormedReturn the L2-norm of this element, expressed as a quantity. The L2-norm is sqrt(x1^2 + x2^2 + ... + xn^2).- Returns:
- the L2-norm of this element, expressed as a quantity
-
normLp
Description copied from interface:NormedReturn the Lp-norm of this element, expressed as a quantity. The Ln-norm is (x1^p + x2^p + ... + xn^p)^(1/p).- Parameters:
p- the rank of the norm- Returns:
- the Lp-norm of this element, expressed as a quantity
-
normLinf
Description copied from interface:NormedReturn the L∞-norm of this element, expressed as a quantity. The L∞-norm is max(|x1|, |x2|, ..., |xn|).- Returns:
- the L∞-norm of this element, expressed as a quantity
-
rows
public int rows()Description copied from class:VectorMatrixReturn the number of rows. -
cols
public int cols()Description copied from class:VectorMatrixReturn the number of columns. -
si
public double[] si()Description copied from class:VectorMatrixReturn a row-major array of SI-values for this matrix or vector. Note that this is NOT a safe copy. -
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>, V extends VectorN<Q, U, V, SI, H>, SI extends VectorN<SIQuantity, SIUnit, SI, ?, ?>, H extends VectorN<?, ?, ?, ?, ?>> - 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.
-
hashCode
public int hashCode() -
equals
-
toString
Description copied from interface:ValueReturn a concise description of this value with the values expressed in the specified unit.- Specified by:
toStringin interfaceValue<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
toStringin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, V extends VectorN<Q, U, V, SI, H>, SI extends VectorN<SIQuantity, SIUnit, SI, ?, ?>, H extends VectorN<?, ?, ?, ?, ?>> - Parameters:
withUnit- the unit into which the values are converted for display- Returns:
- a String with the value contents expressed in the specified unit
-
toString
Description copied from interface:ValueReturn a concise description of this value.- Specified by:
toStringin interfaceValue<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>> - Overrides:
toStringin classVectorMatrix<Q extends Quantity<Q,U>, U extends UnitInterface<U, Q>, V extends VectorN<Q, U, V, SI, H>, SI extends VectorN<SIQuantity, SIUnit, SI, ?, ?>, H extends VectorN<?, ?, ?, ?, ?>> - Returns:
- a String with the value contents, without the type, with the unit attached.
-