View Javadoc
1   package org.djunits.value.vdouble.matrix;
2   
3   import java.util.Collection;
4   
5   import org.djunits.unit.LinearDensityUnit;
6   import org.djunits.value.storage.StorageType;
7   import org.djunits.value.vdouble.matrix.base.DoubleMatrixRel;
8   import org.djunits.value.vdouble.matrix.base.DoubleSparseValue;
9   import org.djunits.value.vdouble.matrix.data.DoubleMatrixData;
10  import org.djunits.value.vdouble.scalar.LinearDensity;
11  import org.djunits.value.vdouble.vector.LinearDensityVector;
12  import org.djunits.value.vdouble.vector.data.DoubleVectorData;
13  
14  import jakarta.annotation.Generated;
15  
16  /**
17   * Immutable Double LinearDensityMatrix, a matrix of values with a LinearDensityUnit.
18   * <p>
19   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
21   * </p>
22   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
23   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
24   */
25  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
26  public class LinearDensityMatrix
27          extends DoubleMatrixRel<LinearDensityUnit, LinearDensity, LinearDensityVector, LinearDensityMatrix>
28  
29  {
30      /** */
31      private static final long serialVersionUID = 20151109L;
32  
33      /**
34       * Construct a LinearDensityMatrix from an internal data object.
35       * @param data DoubleMatrixData; the internal data object for the matrix
36       * @param displayUnit LinearDensityUnit; the display unit of the matrix data
37       */
38      public LinearDensityMatrix(final DoubleMatrixData data, final LinearDensityUnit displayUnit)
39      {
40          super(data, displayUnit);
41      }
42  
43      /* CONSTRUCTORS WITH double[][] */
44  
45      /**
46       * Construct a LinearDensityMatrix from a double[][] object. The double values are expressed in the displayUnit, and will be
47       * printed using the displayUnit.
48       * @param data double[][]; the data for the matrix, expressed in the displayUnit
49       * @param displayUnit LinearDensityUnit; the unit of the values in the data array, and display unit when printing
50       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
51       */
52      public LinearDensityMatrix(final double[][] data, final LinearDensityUnit displayUnit, final StorageType storageType)
53      {
54          this(DoubleMatrixData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
55      }
56  
57      /**
58       * Construct a LinearDensityMatrix from a double[][] object. The double values are expressed in the displayUnit. Assume that
59       * the StorageType is DENSE since we offer the data as an array of an array.
60       * @param data double[][]; the data for the matrix
61       * @param displayUnit LinearDensityUnit; the unit of the values in the data array, and display unit when printing
62       */
63      public LinearDensityMatrix(final double[][] data, final LinearDensityUnit displayUnit)
64      {
65          this(data, displayUnit, StorageType.DENSE);
66      }
67  
68      /**
69       * Construct a LinearDensityMatrix from a double[][] object with SI-unit values.
70       * @param data double[][]; the data for the matrix, in SI units
71       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
72       */
73      public LinearDensityMatrix(final double[][] data, final StorageType storageType)
74      {
75          this(data, LinearDensityUnit.SI, storageType);
76      }
77  
78      /**
79       * Construct a LinearDensityMatrix from a double[][] object with SI-unit values. Assume that the StorageType is DENSE since
80       * we offer the data as an array of an array.
81       * @param data double[][]; the data for the matrix, in SI units
82       */
83      public LinearDensityMatrix(final double[][] data)
84      {
85          this(data, StorageType.DENSE);
86      }
87  
88      /* CONSTRUCTORS WITH LinearDensity[][] */
89  
90      /**
91       * Construct a LinearDensityMatrix from an array of an array of LinearDensity objects. The LinearDensity values are each
92       * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
93       * @param data LinearDensity[][]; the data for the matrix
94       * @param displayUnit LinearDensityUnit; the display unit of the values when printing
95       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
96       */
97      public LinearDensityMatrix(final LinearDensity[][] data, final LinearDensityUnit displayUnit, final StorageType storageType)
98      {
99          this(DoubleMatrixData.instantiate(data, storageType), displayUnit);
100     }
101 
102     /**
103      * Construct a LinearDensityMatrix from an array of an array of LinearDensity objects. The LinearDensity values are each
104      * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
105      * Assume that the StorageType is DENSE since we offer the data as an array of an array.
106      * @param data LinearDensity[][]; the data for the matrix
107      * @param displayUnit LinearDensityUnit; the display unit of the values when printing
108      */
109     public LinearDensityMatrix(final LinearDensity[][] data, final LinearDensityUnit displayUnit)
110     {
111         this(data, displayUnit, StorageType.DENSE);
112     }
113 
114     /**
115      * Construct a LinearDensityMatrix from an array of an array of LinearDensity objects. The LinearDensity values are each
116      * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing.
117      * since we offer the data as an array of an array.
118      * @param data LinearDensity[][]; the data for the matrix
119      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
120      */
121     public LinearDensityMatrix(final LinearDensity[][] data, final StorageType storageType)
122     {
123         this(data, LinearDensityUnit.SI, storageType);
124     }
125 
126     /**
127      * Construct a LinearDensityMatrix from an array of an array of LinearDensity objects. The LinearDensity values are each
128      * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing.
129      * Assume that the StorageType is DENSE since we offer the data as an array of an array.
130      * @param data LinearDensity[][]; the data for the matrix
131      */
132     public LinearDensityMatrix(final LinearDensity[][] data)
133     {
134         this(data, StorageType.DENSE);
135     }
136 
137     /* CONSTRUCTORS WITH Collection<DoubleSparseValue> */
138 
139     /**
140      * Construct a LinearDensityMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the
141      * unit in which the values in the collection are expressed, as well as the unit in which they will be printed.
142      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
143      * @param displayUnit LinearDensityUnit; the display unit of the matrix data, and the unit of the data points
144      * @param rows int; the number of rows of the matrix
145      * @param cols int; the number of columns of the matrix
146      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
147      */
148     public LinearDensityMatrix(final Collection<DoubleSparseValue<LinearDensityUnit, LinearDensity>> data,
149             final LinearDensityUnit displayUnit, final int rows, final int cols, final StorageType storageType)
150     {
151         this(DoubleMatrixData.instantiate(data, rows, cols, storageType), displayUnit);
152     }
153 
154     /**
155      * Construct a LinearDensityMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the
156      * unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Assume the
157      * storage type is SPARSE, since we offer the data as a collection.
158      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
159      * @param displayUnit LinearDensityUnit; the display unit of the matrix data, and the unit of the data points
160      * @param rows int; the number of rows of the matrix
161      * @param cols int; the number of columns of the matrix
162      */
163     public LinearDensityMatrix(final Collection<DoubleSparseValue<LinearDensityUnit, LinearDensity>> data,
164             final LinearDensityUnit displayUnit, final int rows, final int cols)
165     {
166         this(data, displayUnit, rows, cols, StorageType.SPARSE);
167     }
168 
169     /**
170      * Construct a LinearDensityMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the
171      * unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Use the SI
172      * unit or base unit as the displayUnit.
173      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
174      * @param rows int; the number of rows of the matrix
175      * @param cols int; the number of columns of the matrix
176      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
177      */
178     public LinearDensityMatrix(final Collection<DoubleSparseValue<LinearDensityUnit, LinearDensity>> data, final int rows,
179             final int cols, final StorageType storageType)
180     {
181         this(data, LinearDensityUnit.SI, rows, cols, storageType);
182     }
183 
184     /**
185      * Construct a LinearDensityMatrix from a (sparse) collection of DoubleSparseValue objects. The displayUnit indicates the
186      * unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Use the SI
187      * unit or base unit as the displayUnit. Assume the storage type is SPARSE, since we offer the data as a collection.
188      * @param data Collection&lt;DoubleSparseValue&gt;; the data for the matrix
189      * @param rows int; the number of rows of the matrix
190      * @param cols int; the number of columns of the matrix
191      */
192     public LinearDensityMatrix(final Collection<DoubleSparseValue<LinearDensityUnit, LinearDensity>> data, final int rows,
193             final int cols)
194     {
195         this(data, LinearDensityUnit.SI, rows, cols, StorageType.SPARSE);
196     }
197 
198     @Override
199     public Class<LinearDensity> getScalarClass()
200     {
201         return LinearDensity.class;
202     }
203 
204     @Override
205     public Class<LinearDensityVector> getVectorClass()
206     {
207         return LinearDensityVector.class;
208     }
209 
210     @Override
211     public LinearDensityMatrix instantiateMatrix(final DoubleMatrixData dmd, final LinearDensityUnit displayUnit)
212     {
213         return new LinearDensityMatrix(dmd, displayUnit);
214     }
215 
216     @Override
217     public LinearDensityVector instantiateVector(final DoubleVectorData dvd, final LinearDensityUnit displayUnit)
218     {
219         return new LinearDensityVector(dvd, displayUnit);
220     }
221 
222     @Override
223     public LinearDensity instantiateScalarSI(final double valueSI, final LinearDensityUnit displayUnit)
224     {
225         LinearDensity result = LinearDensity.instantiateSI(valueSI);
226         result.setDisplayUnit(displayUnit);
227         return result;
228     }
229 
230 }