View Javadoc
1   package org.djunits.value.vdouble.matrix;
2   
3   import org.djunits.unit.DurationUnit;
4   import org.djunits.value.StorageType;
5   import org.djunits.value.ValueException;
6   import org.djunits.value.vdouble.scalar.Duration;
7   
8   /**
9    * Immutable Duration Matrix.
10   * <p>
11   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>.
13   * <p>
14   * $LastChangedDate: 2015-09-29 14:14:28 +0200 (Tue, 29 Sep 2015) $, @version $Revision: 73 $, by $Author: pknoppers $, initial
15   * version Sep 5, 2015 <br>
16   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
18   */
19  public class DurationMatrix extends AbstractDoubleMatrixRel<DurationUnit, DurationMatrix, MutableDurationMatrix, Duration>
20  {
21      /** */
22      private static final long serialVersionUID = 20151006L;
23  
24      /**
25       * Construct a new Relative Immutable Double DurationMatrix.
26       * @param values double[][]; the values of the entries in the new Relative Immutable Double DurationMatrix
27       * @param unit U; the unit of the new Relative Immutable Double DurationMatrix
28       * @param storageType the data type to use (e.g., DENSE or SPARSE)
29       * @throws ValueException when values is null
30       */
31      public DurationMatrix(final double[][] values, final DurationUnit unit, final StorageType storageType) throws ValueException
32      {
33          super(values, unit, storageType);
34      }
35  
36      /**
37       * Construct a new Relative Immutable Double DurationMatrix.
38       * @param values DoubleScalar.Rel&lt;U&gt;[][]; the values of the entries in the new Relative Immutable Double
39       *            DurationMatrix
40       * @param storageType the data type to use (e.g., DENSE or SPARSE)
41       * @throws ValueException when values has zero entries
42       */
43      public DurationMatrix(final Duration[][] values, final StorageType storageType) throws ValueException
44      {
45          super(values, storageType);
46      }
47  
48      /**
49       * Construct a new Relative Immutable Double DurationMatrix.
50       * @param data an internal data object
51       * @param unit the unit
52       */
53      DurationMatrix(final DoubleMatrixData data, final DurationUnit unit)
54      {
55          super(data, unit);
56      }
57  
58      /** {@inheritDoc} */
59      @Override
60      public final DurationMatrix toDense()
61      {
62          return this.data.isDense() ? this : instantiateType(this.data.toDense(), getUnit());
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public final DurationMatrix toSparse()
68      {
69          return this.data.isSparse() ? this : instantiateType(this.data.toSparse(), getUnit());
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      protected final DurationMatrix instantiateType(final DoubleMatrixData dmd, final DurationUnit unit)
75      {
76          return new DurationMatrix(dmd, unit);
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      protected final MutableDurationMatrix instantiateMutableType(final DoubleMatrixData dmd, final DurationUnit unit)
82      {
83          return new MutableDurationMatrix(dmd, unit);
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      protected final Duration instantiateScalar(final double value, final DurationUnit unit)
89      {
90          return new Duration(value, unit);
91      }
92  
93  }