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.RelWithAbs;
6   import org.djunits.value.vfloat.matrix.data.FloatMatrixData;
7   import org.djunits.value.vfloat.scalar.base.FloatScalarAbs;
8   import org.djunits.value.vfloat.scalar.base.FloatScalarRelWithAbs;
9   import org.djunits.value.vfloat.vector.base.FloatVectorAbs;
10  import org.djunits.value.vfloat.vector.base.FloatVectorRelWithAbs;
11  import org.djunits.value.vfloat.vector.data.FloatVectorData;
12  
13  /**
14   * AbstractMutableFloatMatrixRelWithAbs.java.
15   * <p>
16   * Copyright (c) 2019-2024 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 FloatMatrixRelWithAbs<
31          AU  extends AbsoluteLinearUnit<AU, RU>, 
32          A   extends FloatScalarAbs<AU, A, RU, R>,
33          AV  extends FloatVectorAbs<AU, A, AV, RU, R, RV>,
34          AM  extends FloatMatrixAbs<AU, A, AV, AM, RU, R, RV, RM>, 
35          RU  extends Unit<RU>,
36          R   extends FloatScalarRelWithAbs<AU, A, RU, R>,
37          RV  extends FloatVectorRelWithAbs<AU, A, AV, RU, R, RV>,
38          RM  extends FloatMatrixRelWithAbs<AU, A, AV, AM, RU, R, RV, RM>>
39          extends FloatMatrixRel<RU, R, RV, RM>
40          implements RelWithAbs<AU, AM, RU, 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 FloatMatrixRelWithAbs(final FloatMatrixData data, final RU unit)
52      {
53          // data will be copied in AbstractMutableFloatMatrixRel
54          super(data, unit);
55      }
56  
57      @Override
58      public AM plus(final AM increment)
59      {
60          return instantiateMatrixAbs(this.getData().plus(increment.getData()), increment.getDisplayUnit().getStandardUnit());
61      }
62  
63      /**
64       * Instantiate a new absolute matrix of the class of this relative matrix. This can be used instead of the
65       * FloatMatrix.instiantiate() methods in case another matrix of this relative with absolute class is known. The method is
66       * faster than FloatMatrix.instantiate, and it will also work if the matrix is user-defined.
67       * @param dmd FloatMatrixData; the data used to instantiate the matrix
68       * @param displayUnit AU; the display unit of the absolute matrix
69       * @return AM; an absolute matrix of the correct type, belonging to this relative matrix type
70       */
71      public abstract AM instantiateMatrixAbs(FloatMatrixData dmd, AU displayUnit);
72  
73      /**
74       * Instantiate a new absolute vector of the class of this relative matrix. This can be used instead of the
75       * FloatVector.instiantiate() methods in case another matrix of this relative with absolute class is known. The method is
76       * faster than FloatVector.instantiate, and it will also work if the matrix or vector is user-defined.
77       * @param dvd FloatVectorData; the data used to instantiate the vector
78       * @param displayUnit AU; the display unit of the absolute vector
79       * @return AV; an absolute vector of the correct type, belonging to this relative matrix type
80       */
81      public abstract AV instantiateVectorAbs(FloatVectorData dvd, AU displayUnit);
82  
83      /**
84       * Instantiate a new absolute scalar for the class of this relative matrix. This can be used instead of the
85       * FloatScalar.instiantiate() methods in case a matrix of this class is known. The method is faster than
86       * FloatScalar.instantiate, and it will also work if the matrix and/or scalar are user-defined.
87       * @param valueSI float; the SI value of the absolute scalar
88       * @param displayUnit AU; the unit in which the absolute value will be displayed
89       * @return A; an absolute scalar of the correct type, belonging to this relative matrix type
90       */
91      public abstract A instantiateScalarAbsSI(float valueSI, AU displayUnit);
92  
93  }