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