View Javadoc
1   package org.djunits.value.vfloat.matrix;
2   
3   import java.util.Collection;
4   
5   import org.djunits.unit.FrequencyUnit;
6   import org.djunits.value.storage.StorageType;
7   import org.djunits.value.vfloat.matrix.base.FloatMatrixRel;
8   import org.djunits.value.vfloat.matrix.base.FloatSparseValue;
9   import org.djunits.value.vfloat.matrix.data.FloatMatrixData;
10  import org.djunits.value.vfloat.scalar.FloatFrequency;
11  import org.djunits.value.vfloat.vector.FloatFrequencyVector;
12  import org.djunits.value.vfloat.vector.data.FloatVectorData;
13  
14  import jakarta.annotation.Generated;
15  
16  /**
17   * Immutable FloatFloatFrequencyMatrix, a matrix of values with a FrequencyUnit.
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 FloatFrequencyMatrix
27          extends FloatMatrixRel<FrequencyUnit, FloatFrequency, FloatFrequencyVector, FloatFrequencyMatrix>
28  
29  {
30      /** */
31      private static final long serialVersionUID = 20151109L;
32  
33      /**
34       * Construct a FloatFrequencyMatrix from an internal data object.
35       * @param data FloatMatrixData; the internal data object for the matrix
36       * @param displayUnit FrequencyUnit; the display unit of the matrix data
37       */
38      public FloatFrequencyMatrix(final FloatMatrixData data, final FrequencyUnit displayUnit)
39      {
40          super(data, displayUnit);
41      }
42  
43      /* CONSTRUCTORS WITH float[][] */
44  
45      /**
46       * Construct a FloatFrequencyMatrix from a float[][] object. The float values are expressed in the displayUnit, and will be
47       * printed using the displayUnit.
48       * @param data float[][]; the data for the matrix, expressed in the displayUnit
49       * @param displayUnit FrequencyUnit; 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 FloatFrequencyMatrix(final float[][] data, final FrequencyUnit displayUnit, final StorageType storageType)
53      {
54          this(FloatMatrixData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
55      }
56  
57      /**
58       * Construct a FloatFrequencyMatrix from a float[][] object. The float 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 float[][]; the data for the matrix
61       * @param displayUnit FrequencyUnit; the unit of the values in the data array, and display unit when printing
62       */
63      public FloatFrequencyMatrix(final float[][] data, final FrequencyUnit displayUnit)
64      {
65          this(data, displayUnit, StorageType.DENSE);
66      }
67  
68      /**
69       * Construct a FloatFrequencyMatrix from a float[][] object with SI-unit values.
70       * @param data float[][]; 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 FloatFrequencyMatrix(final float[][] data, final StorageType storageType)
74      {
75          this(data, FrequencyUnit.SI, storageType);
76      }
77  
78      /**
79       * Construct a FloatFrequencyMatrix from a float[][] 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 float[][]; the data for the matrix, in SI units
82       */
83      public FloatFrequencyMatrix(final float[][] data)
84      {
85          this(data, StorageType.DENSE);
86      }
87  
88      /* CONSTRUCTORS WITH Frequency[][] */
89  
90      /**
91       * Construct a FloatFrequencyMatrix from an array of an array of FloatFrequency objects. The FloatFrequency 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 FloatFrequency[][]; the data for the matrix
94       * @param displayUnit FrequencyUnit; 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 FloatFrequencyMatrix(final FloatFrequency[][] data, final FrequencyUnit displayUnit, final StorageType storageType)
98      {
99          this(FloatMatrixData.instantiate(data, storageType), displayUnit);
100     }
101 
102     /**
103      * Construct a FloatFrequencyMatrix from an array of an array of FloatFrequency objects. The FloatFrequency 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 FloatFrequency[][]; the data for the matrix
107      * @param displayUnit FrequencyUnit; the display unit of the values when printing
108      */
109     public FloatFrequencyMatrix(final FloatFrequency[][] data, final FrequencyUnit displayUnit)
110     {
111         this(data, displayUnit, StorageType.DENSE);
112     }
113 
114     /**
115      * Construct a FloatFrequencyMatrix from an array of an array of FloatFrequency objects. The FloatFrequency 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 FloatFrequency[][]; the data for the matrix
119      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
120      */
121     public FloatFrequencyMatrix(final FloatFrequency[][] data, final StorageType storageType)
122     {
123         this(data, FrequencyUnit.SI, storageType);
124     }
125 
126     /**
127      * Construct a FloatFrequencyMatrix from an array of an array of FloatFrequency objects. The FloatFrequency 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 FloatFrequency[][]; the data for the matrix
131      */
132     public FloatFrequencyMatrix(final FloatFrequency[][] data)
133     {
134         this(data, StorageType.DENSE);
135     }
136 
137     /* CONSTRUCTORS WITH Collection<FloatSparseValue> */
138 
139     /**
140      * Construct a FloatFrequencyMatrix from a (sparse) collection of FloatSparseValue 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;FloatSparseValue&gt;; the data for the matrix
143      * @param displayUnit FrequencyUnit; 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 FloatFrequencyMatrix(final Collection<FloatSparseValue<FrequencyUnit, FloatFrequency>> data,
149             final FrequencyUnit displayUnit, final int rows, final int cols, final StorageType storageType)
150     {
151         this(FloatMatrixData.instantiate(data, rows, cols, storageType), displayUnit);
152     }
153 
154     /**
155      * Construct a FloatFrequencyMatrix from a (sparse) collection of FloatSparseValue 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;FloatSparseValue&gt;; the data for the matrix
159      * @param displayUnit FrequencyUnit; 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 FloatFrequencyMatrix(final Collection<FloatSparseValue<FrequencyUnit, FloatFrequency>> data,
164             final FrequencyUnit displayUnit, final int rows, final int cols)
165     {
166         this(data, displayUnit, rows, cols, StorageType.SPARSE);
167     }
168 
169     /**
170      * Construct a FloatFrequencyMatrix from a (sparse) collection of FloatSparseValue 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;FloatSparseValue&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 FloatFrequencyMatrix(final Collection<FloatSparseValue<FrequencyUnit, FloatFrequency>> data, final int rows,
179             final int cols, final StorageType storageType)
180     {
181         this(data, FrequencyUnit.SI, rows, cols, storageType);
182     }
183 
184     /**
185      * Construct a FloatFrequencyMatrix from a (sparse) collection of FloatSparseValue 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;FloatSparseValue&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 FloatFrequencyMatrix(final Collection<FloatSparseValue<FrequencyUnit, FloatFrequency>> data, final int rows,
193             final int cols)
194     {
195         this(data, FrequencyUnit.SI, rows, cols, StorageType.SPARSE);
196     }
197 
198     @Override
199     public Class<FloatFrequency> getScalarClass()
200     {
201         return FloatFrequency.class;
202     }
203 
204     @Override
205     public Class<FloatFrequencyVector> getVectorClass()
206     {
207         return FloatFrequencyVector.class;
208     }
209 
210     @Override
211     public FloatFrequencyMatrix instantiateMatrix(final FloatMatrixData fmd, final FrequencyUnit displayUnit)
212     {
213         return new FloatFrequencyMatrix(fmd, displayUnit);
214     }
215 
216     @Override
217     public FloatFrequencyVector instantiateVector(final FloatVectorData fvd, final FrequencyUnit displayUnit)
218     {
219         return new FloatFrequencyVector(fvd, displayUnit);
220     }
221 
222     @Override
223     public FloatFrequency instantiateScalarSI(final float valueSI, final FrequencyUnit displayUnit)
224     {
225         FloatFrequency result = FloatFrequency.instantiateSI(valueSI);
226         result.setDisplayUnit(displayUnit);
227         return result;
228     }
229 
230 }