1 package org.djunits.value.vdouble.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.vdouble.matrix.data.DoubleMatrixData;
7 import org.djunits.value.vdouble.scalar.base.DoubleScalarAbs;
8 import org.djunits.value.vdouble.scalar.base.DoubleScalarRelWithAbs;
9 import org.djunits.value.vdouble.vector.base.DoubleVectorAbs;
10 import org.djunits.value.vdouble.vector.base.DoubleVectorRelWithAbs;
11 import org.djunits.value.vdouble.vector.data.DoubleVectorData;
12
13 /**
14 * AbstractMutableDoubleMatrixRelWithAbs.java.
15 * <p>
16 * Copyright (c) 2019-2025 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 DoubleMatrixRelWithAbs<
31 AU extends AbsoluteLinearUnit<AU, RU>,
32 A extends DoubleScalarAbs<AU, A, RU, R>,
33 AV extends DoubleVectorAbs<AU, A, AV, RU, R, RV>,
34 AM extends DoubleMatrixAbs<AU, A, AV, AM, RU, R, RV, RM>,
35 RU extends Unit<RU>,
36 R extends DoubleScalarRelWithAbs<AU, A, RU, R>,
37 RV extends DoubleVectorRelWithAbs<AU, A, AV, RU, R, RV>,
38 RM extends DoubleMatrixRelWithAbs<AU, A, AV, AM, RU, R, RV, RM>>
39 extends DoubleMatrixRel<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 DoubleMatrix.
48 * @param data an internal data object
49 * @param unit the unit
50 */
51 protected DoubleMatrixRelWithAbs(final DoubleMatrixData data, final RU unit)
52 {
53 // data will be copied in AbstractMutableDoubleMatrixRel
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 * DoubleMatrix.instiantiate() methods in case another matrix of this relative with absolute class is known. The method is
66 * faster than DoubleMatrix.instantiate, and it will also work if the matrix is user-defined.
67 * @param dmd the data used to instantiate the matrix
68 * @param displayUnit the display unit of the absolute matrix
69 * @return an absolute matrix of the correct type, belonging to this relative matrix type
70 */
71 public abstract AM instantiateMatrixAbs(DoubleMatrixData 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 * DoubleVector.instiantiate() methods in case another matrix of this relative with absolute class is known. The method is
76 * faster than DoubleVector.instantiate, and it will also work if the matrix or vector is user-defined.
77 * @param dvd the data used to instantiate the vector
78 * @param displayUnit the display unit of the absolute vector
79 * @return an absolute vector of the correct type, belonging to this relative matrix type
80 */
81 public abstract AV instantiateVectorAbs(DoubleVectorData 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 * DoubleScalar.instiantiate() methods in case a matrix of this class is known. The method is faster than
86 * DoubleScalar.instantiate, and it will also work if the matrix and/or scalar are user-defined.
87 * @param valueSI the SI value of the absolute scalar
88 * @param displayUnit the unit in which the absolute value will be displayed
89 * @return an absolute scalar of the correct type, belonging to this relative matrix type
90 */
91 public abstract A instantiateScalarAbsSI(double valueSI, AU displayUnit);
92
93 }