View Javadoc
1   package org.djunits.value.vfloat.matrix.base;
2   
3   import org.djunits.unit.AbsoluteLinearUnit;
4   import org.djunits.unit.Unit;
5   import org.djunits.value.base.Matrix;
6   import org.djunits.value.vfloat.matrix.data.FloatMatrixData;
7   import org.djunits.value.vfloat.scalar.base.AbstractFloatScalarAbs;
8   import org.djunits.value.vfloat.scalar.base.AbstractFloatScalarRelWithAbs;
9   import org.djunits.value.vfloat.vector.base.AbstractFloatVectorAbs;
10  import org.djunits.value.vfloat.vector.base.AbstractFloatVectorRelWithAbs;
11  import org.djunits.value.vfloat.vector.data.FloatVectorData;
12  
13  /**
14   * AbstractMutableFloatMatrixRelWithAbs.java.
15   * <p>
16   * Copyright (c) 2019-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
17   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
18   * <p>
19   * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a>
20   * @param <AU> the absolute unit belonging to the relative unit
21   * @param <A> the absolute scalar type belonging to the absolute matrix type
22   * @param <AV> the absolute vector type belonging to the absolute matrix type
23   * @param <AM> the (immutable or mutable) absolute matrix type
24   * @param <RU> the relative unit belonging to the absolute unit
25   * @param <R> the relative scalar type belonging to the relative matrix type
26   * @param <RV> the relative vector type belonging to the relative matrix type
27   * @param <RM> the relative (immutable or mutable) matrix type with this unit
28   */
29  // @formatter:off
30  public abstract class AbstractFloatMatrixRelWithAbs<
31          AU  extends AbsoluteLinearUnit<AU, RU>, 
32          A   extends AbstractFloatScalarAbs<AU, A, RU, R>,
33          AV  extends AbstractFloatVectorAbs<AU, A, AV, RU, R, RV>,
34          AM  extends AbstractFloatMatrixAbs<AU, A, AV, AM, RU, R, RV, RM>, 
35          RU  extends Unit<RU>,
36          R   extends AbstractFloatScalarRelWithAbs<AU, A, RU, R>,
37          RV  extends AbstractFloatVectorRelWithAbs<AU, A, AV, RU, R, RV>,
38          RM  extends AbstractFloatMatrixRelWithAbs<AU, A, AV, AM, RU, R, RV, RM>>
39          extends AbstractFloatMatrixRel<RU, R, RV, RM>
40          implements Matrix.RelWithAbs<AU, A, AV, AM, RU, R, RV, RM>
41  // @formatter:on
42  {
43      /** */
44      private static final long serialVersionUID = 20190908L;
45  
46      /**
47       * Construct a new Relative Mutable FloatMatrix.
48       * @param data FloatMatrixData; an internal data object
49       * @param unit RU; the unit
50       */
51      protected AbstractFloatMatrixRelWithAbs(final FloatMatrixData data, final RU unit)
52      {
53          // data will be copied in AbstractMutableFloatMatrixRel
54          super(data, unit);
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public AM plus(final AM increment)
60      {
61          return instantiateMatrixAbs(this.getData().plus(increment.getData()), increment.getDisplayUnit().getStandardUnit());
62      }
63  
64      /**
65       * Instantiate a new absolute matrix of the class of this relative matrix. This can be used instead of the
66       * FloatMatrix.instiantiate() methods in case another matrix of this relative with absolute class is known. The method is
67       * faster than FloatMatrix.instantiate, and it will also work if the matrix is user-defined.
68       * @param dmd FloatMatrixData; the data used to instantiate the matrix
69       * @param displayUnit AU; the display unit of the absolute matrix
70       * @return AM; an absolute matrix of the correct type, belonging to this relative matrix type
71       */
72      public abstract AM instantiateMatrixAbs(FloatMatrixData dmd, AU displayUnit);
73  
74      /**
75       * Instantiate a new absolute vector of the class of this relative matrix. This can be used instead of the
76       * FloatVector.instiantiate() methods in case another matrix of this relative with absolute class is known. The method is
77       * faster than FloatVector.instantiate, and it will also work if the matrix or vector is user-defined.
78       * @param dvd FloatVectorData; the data used to instantiate the vector
79       * @param displayUnit AU; the display unit of the absolute vector
80       * @return AV; an absolute vector of the correct type, belonging to this relative matrix type
81       */
82      public abstract AV instantiateVectorAbs(FloatVectorData dvd, AU displayUnit);
83  
84      /**
85       * Instantiate a new absolute scalar for the class of this relative matrix. This can be used instead of the
86       * FloatScalar.instiantiate() methods in case a matrix of this class is known. The method is faster than
87       * FloatScalar.instantiate, and it will also work if the matrix and/or scalar are user-defined.
88       * @param valueSI float; the SI value of the absolute scalar
89       * @param displayUnit AU; the unit in which the absolute value will be displayed
90       * @return A; an absolute scalar of the correct type, belonging to this relative matrix type
91       */
92      public abstract A instantiateScalarAbsSI(float valueSI, AU displayUnit);
93  
94  }