View Javadoc
1   package org.djunits.value.vfloat.matrix;
2   
3   import java.util.Collection;
4   
5   import org.djunits.unit.DimensionlessUnit;
6   import org.djunits.value.function.DimensionlessFunctions;
7   import org.djunits.value.storage.StorageType;
8   import org.djunits.value.vfloat.function.FloatMathFunctions;
9   import org.djunits.value.vfloat.matrix.base.FloatMatrixRel;
10  import org.djunits.value.vfloat.matrix.base.FloatSparseValue;
11  import org.djunits.value.vfloat.matrix.data.FloatMatrixData;
12  import org.djunits.value.vfloat.scalar.FloatDimensionless;
13  import org.djunits.value.vfloat.vector.FloatDimensionlessVector;
14  import org.djunits.value.vfloat.vector.data.FloatVectorData;
15  
16  import jakarta.annotation.Generated;
17  
18  /**
19   * Immutable FloatFloatDimensionlessMatrix, a matrix of values with a DimensionlessUnit.
20   * <p>
21   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
22   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
23   * </p>
24   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
25   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
26   */
27  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
28  public class FloatDimensionlessMatrix
29          extends FloatMatrixRel<DimensionlessUnit, FloatDimensionless, FloatDimensionlessVector, FloatDimensionlessMatrix>
30          implements DimensionlessFunctions<DimensionlessUnit, FloatDimensionlessMatrix>
31  {
32      /** */
33      private static final long serialVersionUID = 20151109L;
34  
35      /**
36       * Construct a FloatDimensionlessMatrix from an internal data object.
37       * @param data FloatMatrixData; the internal data object for the matrix
38       * @param displayUnit DimensionlessUnit; the display unit of the matrix data
39       */
40      public FloatDimensionlessMatrix(final FloatMatrixData data, final DimensionlessUnit displayUnit)
41      {
42          super(data, displayUnit);
43      }
44  
45      /* CONSTRUCTORS WITH float[][] */
46  
47      /**
48       * Construct a FloatDimensionlessMatrix from a float[][] object. The float values are expressed in the displayUnit, and will
49       * be printed using the displayUnit.
50       * @param data float[][]; the data for the matrix, expressed in the displayUnit
51       * @param displayUnit DimensionlessUnit; the unit of the values in the data array, and display unit when printing
52       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
53       */
54      public FloatDimensionlessMatrix(final float[][] data, final DimensionlessUnit displayUnit, final StorageType storageType)
55      {
56          this(FloatMatrixData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
57      }
58  
59      /**
60       * Construct a FloatDimensionlessMatrix from a float[][] object. The float values are expressed in the displayUnit. Assume
61       * that the StorageType is DENSE since we offer the data as an array of an array.
62       * @param data float[][]; the data for the matrix
63       * @param displayUnit DimensionlessUnit; the unit of the values in the data array, and display unit when printing
64       */
65      public FloatDimensionlessMatrix(final float[][] data, final DimensionlessUnit displayUnit)
66      {
67          this(data, displayUnit, StorageType.DENSE);
68      }
69  
70      /**
71       * Construct a FloatDimensionlessMatrix from a float[][] object with SI-unit values.
72       * @param data float[][]; the data for the matrix, in SI units
73       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
74       */
75      public FloatDimensionlessMatrix(final float[][] data, final StorageType storageType)
76      {
77          this(data, DimensionlessUnit.SI, storageType);
78      }
79  
80      /**
81       * Construct a FloatDimensionlessMatrix from a float[][] object with SI-unit values. Assume that the StorageType is DENSE
82       * since we offer the data as an array of an array.
83       * @param data float[][]; the data for the matrix, in SI units
84       */
85      public FloatDimensionlessMatrix(final float[][] data)
86      {
87          this(data, StorageType.DENSE);
88      }
89  
90      /* CONSTRUCTORS WITH Dimensionless[][] */
91  
92      /**
93       * Construct a FloatDimensionlessMatrix from an array of an array of FloatDimensionless objects. The FloatDimensionless
94       * values are each expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit
95       * when printing.
96       * @param data FloatDimensionless[][]; the data for the matrix
97       * @param displayUnit DimensionlessUnit; 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 FloatDimensionlessMatrix(final FloatDimensionless[][] data, final DimensionlessUnit displayUnit,
101             final StorageType storageType)
102     {
103         this(FloatMatrixData.instantiate(data, storageType), displayUnit);
104     }
105 
106     /**
107      * Construct a FloatDimensionlessMatrix from an array of an array of FloatDimensionless objects. The FloatDimensionless
108      * values are each expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit
109      * when printing. Assume that the StorageType is DENSE since we offer the data as an array of an array.
110      * @param data FloatDimensionless[][]; the data for the matrix
111      * @param displayUnit DimensionlessUnit; the display unit of the values when printing
112      */
113     public FloatDimensionlessMatrix(final FloatDimensionless[][] data, final DimensionlessUnit displayUnit)
114     {
115         this(data, displayUnit, StorageType.DENSE);
116     }
117 
118     /**
119      * Construct a FloatDimensionlessMatrix from an array of an array of FloatDimensionless objects. The FloatDimensionless
120      * values are each expressed in their own unit, but will be internally stored as SI values, and expressed using SI units
121      * when printing. since we offer the data as an array of an array.
122      * @param data FloatDimensionless[][]; the data for the matrix
123      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
124      */
125     public FloatDimensionlessMatrix(final FloatDimensionless[][] data, final StorageType storageType)
126     {
127         this(data, DimensionlessUnit.SI, storageType);
128     }
129 
130     /**
131      * Construct a FloatDimensionlessMatrix from an array of an array of FloatDimensionless objects. The FloatDimensionless
132      * values are each expressed in their own unit, but will be internally stored as SI values, and expressed using SI units
133      * when printing. Assume that the StorageType is DENSE since we offer the data as an array of an array.
134      * @param data FloatDimensionless[][]; the data for the matrix
135      */
136     public FloatDimensionlessMatrix(final FloatDimensionless[][] data)
137     {
138         this(data, StorageType.DENSE);
139     }
140 
141     /* CONSTRUCTORS WITH Collection<FloatSparseValue> */
142 
143     /**
144      * Construct a FloatDimensionlessMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates
145      * the unit in which the values in the collection are expressed, as well as the unit in which they will be printed.
146      * @param data Collection&lt;FloatSparseValue&gt;; the data for the matrix
147      * @param displayUnit DimensionlessUnit; the display unit of the matrix data, and the unit of the data points
148      * @param rows int; the number of rows of the matrix
149      * @param cols int; the number of columns of the matrix
150      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
151      */
152     public FloatDimensionlessMatrix(final Collection<FloatSparseValue<DimensionlessUnit, FloatDimensionless>> data,
153             final DimensionlessUnit displayUnit, final int rows, final int cols, final StorageType storageType)
154     {
155         this(FloatMatrixData.instantiate(data, rows, cols, storageType), displayUnit);
156     }
157 
158     /**
159      * Construct a FloatDimensionlessMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates
160      * the unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Assume
161      * the storage type is SPARSE, since we offer the data as a collection.
162      * @param data Collection&lt;FloatSparseValue&gt;; the data for the matrix
163      * @param displayUnit DimensionlessUnit; the display unit of the matrix data, and the unit of the data points
164      * @param rows int; the number of rows of the matrix
165      * @param cols int; the number of columns of the matrix
166      */
167     public FloatDimensionlessMatrix(final Collection<FloatSparseValue<DimensionlessUnit, FloatDimensionless>> data,
168             final DimensionlessUnit displayUnit, final int rows, final int cols)
169     {
170         this(data, displayUnit, rows, cols, StorageType.SPARSE);
171     }
172 
173     /**
174      * Construct a FloatDimensionlessMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates
175      * the unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Use the
176      * SI unit or base unit as the displayUnit.
177      * @param data Collection&lt;FloatSparseValue&gt;; the data for the matrix
178      * @param rows int; the number of rows of the matrix
179      * @param cols int; the number of columns of the matrix
180      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix
181      */
182     public FloatDimensionlessMatrix(final Collection<FloatSparseValue<DimensionlessUnit, FloatDimensionless>> data,
183             final int rows, final int cols, final StorageType storageType)
184     {
185         this(data, DimensionlessUnit.SI, rows, cols, storageType);
186     }
187 
188     /**
189      * Construct a FloatDimensionlessMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates
190      * the unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Use the
191      * SI unit or base unit as the displayUnit. Assume the storage type is SPARSE, since we offer the data as a collection.
192      * @param data Collection&lt;FloatSparseValue&gt;; the data for the matrix
193      * @param rows int; the number of rows of the matrix
194      * @param cols int; the number of columns of the matrix
195      */
196     public FloatDimensionlessMatrix(final Collection<FloatSparseValue<DimensionlessUnit, FloatDimensionless>> data,
197             final int rows, final int cols)
198     {
199         this(data, DimensionlessUnit.SI, rows, cols, StorageType.SPARSE);
200     }
201 
202     @Override
203     public Class<FloatDimensionless> getScalarClass()
204     {
205         return FloatDimensionless.class;
206     }
207 
208     @Override
209     public Class<FloatDimensionlessVector> getVectorClass()
210     {
211         return FloatDimensionlessVector.class;
212     }
213 
214     @Override
215     public FloatDimensionlessMatrix instantiateMatrix(final FloatMatrixData fmd, final DimensionlessUnit displayUnit)
216     {
217         return new FloatDimensionlessMatrix(fmd, displayUnit);
218     }
219 
220     @Override
221     public FloatDimensionlessVector instantiateVector(final FloatVectorData fvd, final DimensionlessUnit displayUnit)
222     {
223         return new FloatDimensionlessVector(fvd, displayUnit);
224     }
225 
226     @Override
227     public FloatDimensionless instantiateScalarSI(final float valueSI, final DimensionlessUnit displayUnit)
228     {
229         FloatDimensionless result = FloatDimensionless.instantiateSI(valueSI);
230         result.setDisplayUnit(displayUnit);
231         return result;
232     }
233 
234     @Override
235     public final FloatDimensionlessMatrix acos()
236     {
237         assign(FloatMathFunctions.ACOS);
238         return this;
239     }
240 
241     @Override
242     public final FloatDimensionlessMatrix asin()
243     {
244         assign(FloatMathFunctions.ASIN);
245         return this;
246     }
247 
248     @Override
249     public final FloatDimensionlessMatrix atan()
250     {
251         assign(FloatMathFunctions.ATAN);
252         return this;
253     }
254 
255     @Override
256     public final FloatDimensionlessMatrix cbrt()
257     {
258         assign(FloatMathFunctions.CBRT);
259         return this;
260     }
261 
262     @Override
263     public final FloatDimensionlessMatrix cos()
264     {
265         assign(FloatMathFunctions.COS);
266         return this;
267     }
268 
269     @Override
270     public final FloatDimensionlessMatrix cosh()
271     {
272         assign(FloatMathFunctions.COSH);
273         return this;
274     }
275 
276     @Override
277     public final FloatDimensionlessMatrix exp()
278     {
279         assign(FloatMathFunctions.EXP);
280         return this;
281     }
282 
283     @Override
284     public final FloatDimensionlessMatrix expm1()
285     {
286         assign(FloatMathFunctions.EXPM1);
287         return this;
288     }
289 
290     @Override
291     public final FloatDimensionlessMatrix log()
292     {
293         assign(FloatMathFunctions.LOG);
294         return this;
295     }
296 
297     @Override
298     public final FloatDimensionlessMatrix log10()
299     {
300         assign(FloatMathFunctions.LOG10);
301         return this;
302     }
303 
304     @Override
305     public final FloatDimensionlessMatrix log1p()
306     {
307         assign(FloatMathFunctions.LOG1P);
308         return this;
309     }
310 
311     @Override
312     public final FloatDimensionlessMatrix pow(final double x)
313     {
314         assign(FloatMathFunctions.POW((float) x));
315         return this;
316     }
317 
318     @Override
319     public final FloatDimensionlessMatrix signum()
320     {
321         assign(FloatMathFunctions.SIGNUM);
322         return this;
323     }
324 
325     @Override
326     public final FloatDimensionlessMatrix sin()
327     {
328         assign(FloatMathFunctions.SIN);
329         return this;
330     }
331 
332     @Override
333     public final FloatDimensionlessMatrix sinh()
334     {
335         assign(FloatMathFunctions.SINH);
336         return this;
337     }
338 
339     @Override
340     public final FloatDimensionlessMatrix sqrt()
341     {
342         assign(FloatMathFunctions.SQRT);
343         return this;
344     }
345 
346     @Override
347     public final FloatDimensionlessMatrix tan()
348     {
349         assign(FloatMathFunctions.TAN);
350         return this;
351     }
352 
353     @Override
354     public final FloatDimensionlessMatrix tanh()
355     {
356         assign(FloatMathFunctions.TANH);
357         return this;
358     }
359 
360     @Override
361     public final FloatDimensionlessMatrix inv()
362     {
363         assign(FloatMathFunctions.INV);
364         return this;
365     }
366 
367 }