MassMatrix.java

  1. package org.djunits.value.vdouble.matrix;

  2. import java.util.Collection;

  3. import org.djunits.unit.MassUnit;
  4. import org.djunits.value.storage.StorageType;
  5. import org.djunits.value.vdouble.matrix.base.DoubleMatrixRel;
  6. import org.djunits.value.vdouble.matrix.base.DoubleSparseValue;
  7. import org.djunits.value.vdouble.matrix.data.DoubleMatrixData;
  8. import org.djunits.value.vdouble.scalar.Mass;
  9. import org.djunits.value.vdouble.vector.MassVector;
  10. import org.djunits.value.vdouble.vector.data.DoubleVectorData;

  11. import jakarta.annotation.Generated;

  12. /**
  13.  * Immutable Double MassMatrix, a matrix of values with a MassUnit.
  14.  * <p>
  15.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  16.  * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
  17.  * </p>
  18.  * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  19.  * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
  20.  */
  21. @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
  22. public class MassMatrix extends DoubleMatrixRel<MassUnit, Mass, MassVector, MassMatrix>

  23. {
  24.     /** */
  25.     private static final long serialVersionUID = 20151109L;

  26.     /**
  27.      * Construct a MassMatrix from an internal data object.
  28.      * @param data DoubleMatrixData; the internal data object for the matrix
  29.      * @param displayUnit MassUnit; the display unit of the matrix data
  30.      */
  31.     public MassMatrix(final DoubleMatrixData data, final MassUnit displayUnit)
  32.     {
  33.         super(data, displayUnit);
  34.     }

  35.     /* CONSTRUCTORS WITH double[][] */

  36.     /**
  37.      * Construct a MassMatrix from a double[][] object. The double values are expressed in the displayUnit, and will be printed
  38.      * using the displayUnit.
  39.      * @param data double[][]; the data for the matrix, expressed in the displayUnit
  40.      * @param displayUnit MassUnit; the unit of the values in the data array, and display unit when printing
  41.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
  42.      */
  43.     public MassMatrix(final double[][] data, final MassUnit displayUnit, final StorageType storageType)
  44.     {
  45.         this(DoubleMatrixData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
  46.     }

  47.     /**
  48.      * Construct a MassMatrix from a double[][] object. The double values are expressed in the displayUnit. Assume that the
  49.      * StorageType is DENSE since we offer the data as an array of an array.
  50.      * @param data double[][]; the data for the matrix
  51.      * @param displayUnit MassUnit; the unit of the values in the data array, and display unit when printing
  52.      */
  53.     public MassMatrix(final double[][] data, final MassUnit displayUnit)
  54.     {
  55.         this(data, displayUnit, StorageType.DENSE);
  56.     }

  57.     /**
  58.      * Construct a MassMatrix from a double[][] object with SI-unit values.
  59.      * @param data double[][]; the data for the matrix, in SI units
  60.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
  61.      */
  62.     public MassMatrix(final double[][] data, final StorageType storageType)
  63.     {
  64.         this(data, MassUnit.SI, storageType);
  65.     }

  66.     /**
  67.      * Construct a MassMatrix from a double[][] object with SI-unit values. Assume that the StorageType is DENSE since we offer
  68.      * the data as an array of an array.
  69.      * @param data double[][]; the data for the matrix, in SI units
  70.      */
  71.     public MassMatrix(final double[][] data)
  72.     {
  73.         this(data, StorageType.DENSE);
  74.     }

  75.     /* CONSTRUCTORS WITH Mass[][] */

  76.     /**
  77.      * Construct a MassMatrix from an array of an array of Mass objects. The Mass values are each expressed in their own unit,
  78.      * but will be internally stored as SI values, all expressed in the displayUnit when printing.
  79.      * @param data Mass[][]; the data for the matrix
  80.      * @param displayUnit MassUnit; the display unit of the values when printing
  81.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
  82.      */
  83.     public MassMatrix(final Mass[][] data, final MassUnit displayUnit, final StorageType storageType)
  84.     {
  85.         this(DoubleMatrixData.instantiate(data, storageType), displayUnit);
  86.     }

  87.     /**
  88.      * Construct a MassMatrix from an array of an array of Mass objects. The Mass values are each expressed in their own unit,
  89.      * but will be internally stored as SI values, all expressed in the displayUnit when printing. Assume that the StorageType
  90.      * is DENSE since we offer the data as an array of an array.
  91.      * @param data Mass[][]; the data for the matrix
  92.      * @param displayUnit MassUnit; the display unit of the values when printing
  93.      */
  94.     public MassMatrix(final Mass[][] data, final MassUnit displayUnit)
  95.     {
  96.         this(data, displayUnit, StorageType.DENSE);
  97.     }

  98.     /**
  99.      * Construct a MassMatrix from an array of an array of Mass objects. The Mass values are each expressed in their own unit,
  100.      * but will be internally stored as SI values, and expressed using SI units when printing. since we offer the data as an
  101.      * array of an array.
  102.      * @param data Mass[][]; the data for the matrix
  103.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
  104.      */
  105.     public MassMatrix(final Mass[][] data, final StorageType storageType)
  106.     {
  107.         this(data, MassUnit.SI, storageType);
  108.     }

  109.     /**
  110.      * Construct a MassMatrix from an array of an array of Mass objects. The Mass values are each expressed in their own unit,
  111.      * but will be internally stored as SI values, and expressed using SI units when printing. Assume that the StorageType is
  112.      * DENSE since we offer the data as an array of an array.
  113.      * @param data Mass[][]; the data for the matrix
  114.      */
  115.     public MassMatrix(final Mass[][] data)
  116.     {
  117.         this(data, StorageType.DENSE);
  118.     }

  119.     /* CONSTRUCTORS WITH Collection<DoubleSparseValue> */

  120.     /**
  121.      * Construct a MassMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the unit in
  122.      * which the values in the collection are expressed, as well as the unit in which they will be printed.
  123.      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
  124.      * @param displayUnit MassUnit; the display unit of the matrix data, and the unit of the data points
  125.      * @param rows int; the number of rows of the matrix
  126.      * @param cols int; the number of columns of the matrix
  127.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
  128.      */
  129.     public MassMatrix(final Collection<DoubleSparseValue<MassUnit, Mass>> data, final MassUnit displayUnit, final int rows,
  130.             final int cols, final StorageType storageType)
  131.     {
  132.         this(DoubleMatrixData.instantiate(data, rows, cols, storageType), displayUnit);
  133.     }

  134.     /**
  135.      * Construct a MassMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the unit in
  136.      * which the values in the collection are expressed, as well as the unit in which they will be printed. Assume the storage
  137.      * type is SPARSE, since we offer the data as a collection.
  138.      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
  139.      * @param displayUnit MassUnit; the display unit of the matrix data, and the unit of the data points
  140.      * @param rows int; the number of rows of the matrix
  141.      * @param cols int; the number of columns of the matrix
  142.      */
  143.     public MassMatrix(final Collection<DoubleSparseValue<MassUnit, Mass>> data, final MassUnit displayUnit, final int rows,
  144.             final int cols)
  145.     {
  146.         this(data, displayUnit, rows, cols, StorageType.SPARSE);
  147.     }

  148.     /**
  149.      * Construct a MassMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the unit in
  150.      * which the values in the collection are expressed, as well as the unit in which they will be printed. Use the SI unit or
  151.      * base unit as the displayUnit.
  152.      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
  153.      * @param rows int; the number of rows of the matrix
  154.      * @param cols int; the number of columns of the matrix
  155.      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
  156.      */
  157.     public MassMatrix(final Collection<DoubleSparseValue<MassUnit, Mass>> data, final int rows, final int cols,
  158.             final StorageType storageType)
  159.     {
  160.         this(data, MassUnit.SI, rows, cols, storageType);
  161.     }

  162.     /**
  163.      * Construct a MassMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the unit in
  164.      * which the values in the collection are expressed, as well as the unit in which they will be printed. Use the SI unit or
  165.      * base unit as the displayUnit. Assume the storage type is SPARSE, since we offer the data as a collection.
  166.      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
  167.      * @param rows int; the number of rows of the matrix
  168.      * @param cols int; the number of columns of the matrix
  169.      */
  170.     public MassMatrix(final Collection<DoubleSparseValue<MassUnit, Mass>> data, final int rows, final int cols)
  171.     {
  172.         this(data, MassUnit.SI, rows, cols, StorageType.SPARSE);
  173.     }

  174.     @Override
  175.     public Class<Mass> getScalarClass()
  176.     {
  177.         return Mass.class;
  178.     }

  179.     @Override
  180.     public Class<MassVector> getVectorClass()
  181.     {
  182.         return MassVector.class;
  183.     }

  184.     @Override
  185.     public MassMatrix instantiateMatrix(final DoubleMatrixData dmd, final MassUnit displayUnit)
  186.     {
  187.         return new MassMatrix(dmd, displayUnit);
  188.     }

  189.     @Override
  190.     public MassVector instantiateVector(final DoubleVectorData dvd, final MassUnit displayUnit)
  191.     {
  192.         return new MassVector(dvd, displayUnit);
  193.     }

  194.     @Override
  195.     public Mass instantiateScalarSI(final double valueSI, final MassUnit displayUnit)
  196.     {
  197.         Mass result = Mass.instantiateSI(valueSI);
  198.         result.setDisplayUnit(displayUnit);
  199.         return result;
  200.     }

  201. }