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