Class VectorN<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>

java.lang.Object
org.djunits.vecmat.def.VectorMatrix<Q,V,SI,H,VT>
org.djunits.vecmat.def.Vector<Q,V,SI,H,VT>
org.djunits.vecmat.dn.VectorN<Q,V,SI,H,VT>
Type Parameters:
Q - the quantity type
V - the vector type (Row or Col)
SI - the vector type with generics <SIQuantity, SIUnit<
H - the generic vector type with generics <?, ?< for Hadamard operations
VT - the type of the transposed version of the vector
All Implemented Interfaces:
Serializable, Iterable<Q>, Additive<V>, Scalable<V>, Value<V,Q>, Hadamard<H,SI>, Normed<Q>
Direct Known Subclasses:
VectorN.Col, VectorN.Row

public abstract class VectorN<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>> extends Vector<Q,V,SI,H,VT>
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:
  • Field Details

    • dataSi

      protected final DataGridSi<?> dataSi
      The data of the matrix, in SI unit.
  • Constructor Details

    • VectorN

      protected VectorN(DataGridSi<?> dataSi, Unit<?,Q> displayUnit)
      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

      public Iterator<Q> iterator()
      Description copied from class: Vector
      Create and return an iterator over the scalars in this vector in proper sequence.
      Specified by:
      iterator in interface Iterable<Q extends Quantity<Q>>
      Specified by:
      iterator in class Vector<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>
      Returns:
      an iterator over the scalars in this vector in proper sequence
    • getScalarArray

      public Q[] getScalarArray()
      Description copied from class: Vector
      Return the vector as an array of scalars.
      Specified by:
      getScalarArray in class Vector<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>
      Returns:
      the vector as an array of scalars
    • normL1

      public Q normL1()
      Description copied from interface: Normed
      Return 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

      public Q normL2()
      Description copied from interface: Normed
      Return 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

      public Q normLp(int p)
      Description copied from interface: Normed
      Return 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

      public Q normLinf()
      Description copied from interface: Normed
      Return 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: VectorMatrix
      Return the number of rows.
      Specified by:
      rows in class VectorMatrix<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>
      Returns:
      the number of rows
    • cols

      public int cols()
      Description copied from class: VectorMatrix
      Return the number of columns.
      Specified by:
      cols in class VectorMatrix<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>
      Returns:
      the number of columns
    • getSiArray

      public double[] getSiArray()
      Description copied from class: VectorMatrix
      Return a row-major array of SI-values for this matrix or vector. This is guaranteed to be a safe copy.
      Specified by:
      getSiArray in class VectorMatrix<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>
      Returns:
      the row-major array of SI-values (safe copy)
    • unsafeSiArray

      public double[] unsafeSiArray()
      Description copied from class: VectorMatrix
      Return a row-major possibly UNSAFE array of SI-values for this matrix or vector. The method might give access to the underlying data structure, so treat the data carefully.
      Specified by:
      unsafeSiArray in class VectorMatrix<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>
      Returns:
      the row-major array of SI-values (safe copy)
    • nonZeroCount

      public int nonZeroCount()
      Description copied from class: VectorMatrix
      Return the number of non-zero entries in the vector, matrix or table. Note that NaN and Infinity count as a non-zero element. The value -0.0 counts as 0.0.
      Specified by:
      nonZeroCount in class VectorMatrix<Q extends Quantity<Q>,V extends VectorN<Q,V,SI,H,VT>,SI extends VectorN<SIQuantity,SI,?,?,?>,H extends VectorN<?,?,?,?,?>,VT extends VectorN<Q,VT,?,?,V>>
      Returns:
      the number of non-zero entries in the vector, matrix or table
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object