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