Class DoubleMatrix

java.lang.Object
org.djunits.value.vdouble.matrix.base.DoubleMatrix

public final class DoubleMatrix
extends Object
DoubleMatrix utility methods, e.g., for creating DoubleMatrixs from different types of data.

Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.

Author:
Alexander Verbraeck, Peter Knoppers
  • Method Details

    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(double[][] valuesInUnit, U unit, StorageType storageType)
      Instantiate the DoubleMatrix based on its unit. Rigid check on types for the compiler. The double array is of the form d[rows][columns] so each value can be found with d[row][column].
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      valuesInUnit - double[][]; the values in the given unit
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the matrix is SPARSE or DENSE
      Returns:
      M; an instantiated DoubleMatrix with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(double[][] valuesInUnit, U unit, StorageType storageType, Class<M> matrixClass)
      Instantiate the DoubleMatrix based on its unit. Rigid check on types for the compiler. The class for the matrix is explicitly provided, e.g., for user-defined matrix classes. The double array is of the form d[rows][columns] so each value can be found with d[row][column].
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      valuesInUnit - double[]; the values in the given unit
      unit - U; the unit in which the values are expressed and displayed
      storageType - StorageType; whether the matrix is SPARSE or DENSE
      matrixClass - Class<M>; the class of the matrix to instantiate
      Returns:
      M; an instantiated DoubleMatrix with the values expressed in their unit
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiateSI​(double[][] valuesSI, U displayUnit, StorageType storageType)
      Instantiate the DoubleMatrix based on its unit. Rigid check on types for the compiler. The double array is of the form d[rows][columns] so each value can be found with d[row][column].
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      valuesSI - double[][]; the values in the SI unit.
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the matrix is SPARSE or DENSE
      Returns:
      M; an instantiated DoubleMatrix with the SI values and display unit
    • instantiateSI

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiateSI​(double[][] valuesSI, U displayUnit, StorageType storageType, Class<M> matrixClass)
      Instantiate the DoubleMatrix based on its unit. Rigid check on types for the compiler. The class for the matrix is explicitly provided, e.g., for user-defined matrix classes. The double array is of the form d[rows][columns] so each value can be found with d[row][column].
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      valuesSI - double[][]; the values in the SI unit
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; whether the matrix is SPARSE or DENSE
      matrixClass - Class<M>; the class of the matrix to instantiate
      Returns:
      M; an instantiated DoubleMatrix with the SI values and display unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(DoubleMatrixData values, U unit)
      Instantiate the Mutable DoubleMatrix based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      values - DoubleMatrixData; the values
      unit - U; the unit in which the values are expressed
      Returns:
      M; an instantiated mutable DoubleMatrix with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(DoubleMatrixData values, U unit, Class<M> matrixClass)
      Instantiate the Mutable DoubleMatrix based on its unit. Rigid check on types for the compiler. The class for the matrix is explicitly provided, e.g., for user-defined matrix classes.
      Type Parameters:
      U - the unit
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the matrix type
      Parameters:
      values - DoubleMatrixData; the values
      unit - U; the unit in which the values are expressed
      matrixClass - Class<M>; the class of the matrix to instantiate
      Returns:
      M; an instantiated mutable DoubleMatrix with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(S[][] values, U displayUnit, StorageType storageType)
      Construct a new Relative Immutable Double Matrix. Rigid check on types for the compiler. The scalar array is of the form s[rows][columns] so each value can be found with s[row][column].
      Type Parameters:
      U - the unit
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the matrix type
      Parameters:
      values - S[][]; the values of the entries in the new Relative Immutable Double Matrix
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; the data type to use (e.g., DENSE or SPARSE)
      Returns:
      M; an instantiated mutable DoubleMatrix with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(S[][] values, U displayUnit, StorageType storageType, Class<M> matrixClass)
      Construct a new Relative Immutable Double Matrix. Rigid check on types for the compiler. The class for the matrix is explicitly provided, e.g., for user-defined matrix classes. The scalar array is of the form s[rows][columns] so each value can be found with s[row][column].
      Type Parameters:
      U - the unit
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the matrix type
      Parameters:
      values - S[][]; the values of the entries in the new Relative Immutable Double Matrix
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; the data type to use (e.g., DENSE or SPARSE)
      matrixClass - Class<M>; the class of the matrix to instantiate
      Returns:
      M; an instantiated mutable DoubleMatrix with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(Collection<DoubleSparseValue<U,​S>> values, int rows, int cols, U displayUnit, StorageType storageType)
      Construct a new Relative Immutable Double Matrix. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the matrix type
      Parameters:
      values - Collection<DoubleSparseValue<U, S>>; the (sparse [X, Y, SI]) values to store
      rows - int; the number of rows of the matrix
      cols - int; the number of columns of the matrix
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; the data type to use (e.g., DENSE or SPARSE)
      Returns:
      M; an instantiated mutable DoubleMatrix with the values expressed in their unit
    • instantiate

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiate​(Collection<DoubleSparseValue<U,​S>> values, int rows, int cols, U displayUnit, StorageType storageType, Class<M> matrixClass)
      Construct a new Relative Immutable Double Matrix. Rigid check on types for the compiler. The class for the matrix is explicitly provided, e.g., for user-defined matrix classes.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      values - Collection<DoubleSparseValue<U, S>>; the (sparse [X, Y, SI]) values to store
      rows - int; the number of rows of the matrix
      cols - int; the number of columns of the matrix
      displayUnit - U; the unit in which the values will be displayed
      storageType - StorageType; the data type to use (e.g., DENSE or SPARSE)
      matrixClass - Class<M>; the class of the matrix to instantiate
      Returns:
      M; an instantiated mutable DoubleMatrix with the values expressed in their unit
    • instantiateAnonymous

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiateAnonymous​(DoubleMatrixData values, Unit<?> unit)
      Instantiate the Immutable DoubleMatrix based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      values - DoubleMatrixData; the values
      unit - Unit<?>; the unit in which the values are expressed
      Returns:
      M; an instantiated DoubleMatrix with the values expressed in their unit
    • instantiateAnonymous

      public static <U extends Unit<U>,​ S extends DoubleScalarInterface<U,​ S>,​ V extends DoubleVectorInterface<U,​ S,​ V>,​ M extends DoubleMatrixInterface<U,​ S,​ V,​ M>> M instantiateAnonymous​(DoubleMatrixData values, Unit<?> unit, Class<M> matrixClass)
      Instantiate the Immutable DoubleMatrix based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type. The class for the matrix is explicitly provided, e.g., for user-defined matrix classes.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      U - the unit type
      S - the corresponding scalar type
      V - the corresponding vector type
      M - the corresponding matrix type
      Parameters:
      values - DoubleMatrixData; the values
      unit - Unit<?>; the unit in which the values are expressed
      matrixClass - Class<M>; the class of the matrix to instantiate
      Returns:
      M; an instantiated DoubleMatrix with the values expressed in their unit