View Javadoc
1   package org.djunits.value.vdouble.matrix;
2   
3   import javax.annotation.Generated;
4   
5   import org.djunits.Throw;
6   import org.djunits.unit.AbsorbedDoseUnit;
7   import org.djunits.unit.AccelerationUnit;
8   import org.djunits.unit.AmountOfSubstanceUnit;
9   import org.djunits.unit.AngleUnit;
10  import org.djunits.unit.AngularAccelerationUnit;
11  import org.djunits.unit.AngularVelocityUnit;
12  import org.djunits.unit.AreaUnit;
13  import org.djunits.unit.CatalyticActivityUnit;
14  import org.djunits.unit.DensityUnit;
15  import org.djunits.unit.DimensionlessUnit;
16  import org.djunits.unit.DurationUnit;
17  import org.djunits.unit.ElectricalCapacitanceUnit;
18  import org.djunits.unit.ElectricalChargeUnit;
19  import org.djunits.unit.ElectricalConductanceUnit;
20  import org.djunits.unit.ElectricalCurrentUnit;
21  import org.djunits.unit.ElectricalInductanceUnit;
22  import org.djunits.unit.ElectricalPotentialUnit;
23  import org.djunits.unit.ElectricalResistanceUnit;
24  import org.djunits.unit.EnergyUnit;
25  import org.djunits.unit.EquivalentDoseUnit;
26  import org.djunits.unit.FlowMassUnit;
27  import org.djunits.unit.FlowVolumeUnit;
28  import org.djunits.unit.ForceUnit;
29  import org.djunits.unit.FrequencyUnit;
30  import org.djunits.unit.IlluminanceUnit;
31  import org.djunits.unit.LengthUnit;
32  import org.djunits.unit.LinearDensityUnit;
33  import org.djunits.unit.LuminousFluxUnit;
34  import org.djunits.unit.LuminousIntensityUnit;
35  import org.djunits.unit.MagneticFluxDensityUnit;
36  import org.djunits.unit.MagneticFluxUnit;
37  import org.djunits.unit.MassUnit;
38  import org.djunits.unit.MomentumUnit;
39  import org.djunits.unit.PowerUnit;
40  import org.djunits.unit.PressureUnit;
41  import org.djunits.unit.RadioActivityUnit;
42  import org.djunits.unit.SIUnit;
43  import org.djunits.unit.SolidAngleUnit;
44  import org.djunits.unit.SpeedUnit;
45  import org.djunits.unit.TemperatureUnit;
46  import org.djunits.unit.TorqueUnit;
47  import org.djunits.unit.Unit;
48  import org.djunits.unit.VolumeUnit;
49  import org.djunits.unit.si.SIDimensions;
50  import org.djunits.unit.util.UnitRuntimeException;
51  import org.djunits.value.ValueRuntimeException;
52  import org.djunits.value.storage.StorageType;
53  import org.djunits.value.vdouble.matrix.base.AbstractDoubleMatrixRel;
54  import org.djunits.value.vdouble.matrix.base.DoubleMatrix;
55  import org.djunits.value.vdouble.matrix.data.DoubleMatrixData;
56  import org.djunits.value.vdouble.scalar.SIScalar;
57  import org.djunits.value.vdouble.scalar.base.AbstractDoubleScalarRel;
58  import org.djunits.value.vdouble.vector.SIVector;
59  import org.djunits.value.vdouble.vector.base.AbstractDoubleVectorRel;
60  import org.djunits.value.vdouble.vector.data.DoubleVectorData;
61  
62  /**
63   * Easy access methods for the generic Relative SI DoubleMatrix.
64   * <p>
65   * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. <br>
66   * All rights reserved. <br>
67   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
68   * </p>
69   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
70   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
71   */
72  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2020-01-19T15:21:24.964166400Z")
73  public class SIMatrix extends AbstractDoubleMatrixRel<SIUnit, SIScalar, SIVector, SIMatrix>
74  {
75      /** */
76      private static final long serialVersionUID = 20150901L;
77  
78      /**
79       * Construct a new Relative Double SIMatrix.
80       * @param values double[][]; the values of the entries in the new Relative Double SIMatrix
81       * @param unit SIUnit; the unit of the new Relative Double SIMatrix
82       * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
83       * @return SIMatrix; the SIMatrix of the given unit
84       * @throws ValueRuntimeException when values is null
85       */
86      public static SIMatrix instantiate(final double[][] values, final SIUnit unit, final StorageType storageType)
87              throws ValueRuntimeException
88      {
89          return new SIMatrix(DoubleMatrixData.instantiate(values, unit.getScale(), storageType), unit);
90      }
91  
92      /**
93       * @param data DoubleMatrixData; an internal data object
94       * @param unit SIUnit; the unit
95       */
96      public SIMatrix(final DoubleMatrixData data, final SIUnit unit)
97      {
98          super(data, unit);
99      }
100 
101     /** {@inheritDoc} */
102     @Override
103     public Class<SIScalar> getScalarClass()
104     {
105         return SIScalar.class;
106     }
107 
108     /** {@inheritDoc} */
109     @Override
110     public Class<SIVector> getVectorClass()
111     {
112         return SIVector.class;
113     }
114 
115     /**
116      * Returns an SIMatrix based on an array of values and the textual representation of the unit.
117      * @param values double[][]; the values to use
118      * @param unitString String; the textual representation of the unit
119      * @param storageType StorageType; the storage type to use
120      * @return SIMatrix; the matrix representation of the values in their unit
121      * @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
122      * @throws NullPointerException when the unitString argument is null
123      */
124     public static SIMatrix of(final double[][] values, final String unitString, final StorageType storageType)
125     {
126         Throw.whenNull(values, "Error parsing SIMatrix: value is null");
127         Throw.whenNull(unitString, "Error parsing SIMatrix: unitString is null");
128         Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing SIMatrix: empty unitString");
129         Throw.whenNull(storageType, "Error parsing SIMatrix: storageType is null");
130         try
131         {
132             SIUnit unit = Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(unitString));
133             if (unit != null)
134             {
135                 return SIMatrix.instantiate(values, unit, storageType);
136             }
137         }
138         catch (Exception exception)
139         {
140             throw new IllegalArgumentException("Error parsing SIUnit from " + unitString, exception);
141         }
142         throw new IllegalArgumentException("Error parsing SIMatrix with unit " + unitString);
143     }
144 
145     /** {@inheritDoc} */
146     @Override
147     public SIMatrix instantiateMatrix(final DoubleMatrixData dmd, final SIUnit unit)
148     {
149         return new SIMatrix(dmd, unit);
150     }
151 
152     /** {@inheritDoc} */
153     @Override
154     public SIVector instantiateVector(final DoubleVectorData dvd, final SIUnit unit)
155     {
156         return new SIVector(dvd, unit);
157     }
158 
159     /** {@inheritDoc} */
160     @Override
161     public SIScalar instantiateScalarSI(final double valueSI, final SIUnit unit)
162     {
163         return new SIScalar(valueSI, unit);
164     }
165 
166     /**********************************************************************************/
167     /******************************** 'CAST AS' METHODS *******************************/
168     /**********************************************************************************/
169 
170     /**
171      * Return the current matrix transformed to a matrix in the given unit. Of course the SI dimensionality has to match,
172      * otherwise the matrix cannot be transformed. The compiler will check the alignment between the return value and the unit.
173      * @param displayUnit KU; the unit in which the matrix needs to be expressed
174      * @return M; the matrix that has been transformed into the right matrix type and unit
175      * @param <U> the unit type
176      * @param <S> the scalar type
177      * @param <V> the vector type
178      * @param <M> the matrix type
179      */
180     public final <U extends Unit<U>, S extends AbstractDoubleScalarRel<U, S>, V extends AbstractDoubleVectorRel<U, S, V>,
181             M extends AbstractDoubleMatrixRel<U, S, V, M>> M as(final U displayUnit)
182     {
183         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(displayUnit.getQuantity().getSiDimensions())),
184                 UnitRuntimeException.class, "SIMatrix with unit %s cannot be converted to a matrix with unit %s",
185                 getDisplayUnit(), displayUnit);
186         M result = DoubleMatrix.instantiate(this.data, displayUnit.getStandardUnit());
187         result.setDisplayUnit(displayUnit);
188         return result;
189     }
190 
191     /**
192      * Return the current matrix as a absorbeddose matrix.
193      * @return AbsorbedDoseMatrix; the current matrix as a absorbeddose matrix
194      */
195     public final AbsorbedDoseMatrix asAbsorbedDose()
196     {
197         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AbsorbedDoseUnit.BASE.getSiDimensions())),
198                 UnitRuntimeException.class, "cannot cast %s to AbsorbedDoseMatrix", this.toString());
199         return new AbsorbedDoseMatrix(this.data, AbsorbedDoseUnit.SI);
200     }
201 
202     /**
203      * Return the current matrix as a absorbeddose matrix, and provide a display unit.
204      * @param displayUnit the unit in which the value will be displayed
205      * @return AbsorbedDoseMatrix; the current matrix as a absorbeddose matrix
206      */
207     public final AbsorbedDoseMatrix asAbsorbedDose(final AbsorbedDoseUnit displayUnit)
208     {
209         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AbsorbedDoseUnit.BASE.getSiDimensions())),
210                 UnitRuntimeException.class, "cannot cast %s to AbsorbedDoseMatrix", this.toString());
211         AbsorbedDoseMatrixrbedDoseMatrix.html#AbsorbedDoseMatrix">AbsorbedDoseMatrix result = new AbsorbedDoseMatrix(this.data, displayUnit.getStandardUnit());
212         result.setDisplayUnit(displayUnit);
213         return result;
214     }
215 
216     /**
217      * Return the current matrix as a acceleration matrix.
218      * @return AccelerationMatrix; the current matrix as a acceleration matrix
219      */
220     public final AccelerationMatrix asAcceleration()
221     {
222         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AccelerationUnit.BASE.getSiDimensions())),
223                 UnitRuntimeException.class, "cannot cast %s to AccelerationMatrix", this.toString());
224         return new AccelerationMatrix(this.data, AccelerationUnit.SI);
225     }
226 
227     /**
228      * Return the current matrix as a acceleration matrix, and provide a display unit.
229      * @param displayUnit the unit in which the value will be displayed
230      * @return AccelerationMatrix; the current matrix as a acceleration matrix
231      */
232     public final AccelerationMatrix asAcceleration(final AccelerationUnit displayUnit)
233     {
234         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AccelerationUnit.BASE.getSiDimensions())),
235                 UnitRuntimeException.class, "cannot cast %s to AccelerationMatrix", this.toString());
236         AccelerationMatrixlerationMatrix.html#AccelerationMatrix">AccelerationMatrix result = new AccelerationMatrix(this.data, displayUnit.getStandardUnit());
237         result.setDisplayUnit(displayUnit);
238         return result;
239     }
240 
241     /**
242      * Return the current matrix as a amountofsubstance matrix.
243      * @return AmountOfSubstanceMatrix; the current matrix as a amountofsubstance matrix
244      */
245     public final AmountOfSubstanceMatrix asAmountOfSubstance()
246     {
247         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AmountOfSubstanceUnit.BASE.getSiDimensions())),
248                 UnitRuntimeException.class, "cannot cast %s to AmountOfSubstanceMatrix", this.toString());
249         return new AmountOfSubstanceMatrix(this.data, AmountOfSubstanceUnit.SI);
250     }
251 
252     /**
253      * Return the current matrix as a amountofsubstance matrix, and provide a display unit.
254      * @param displayUnit the unit in which the value will be displayed
255      * @return AmountOfSubstanceMatrix; the current matrix as a amountofsubstance matrix
256      */
257     public final AmountOfSubstanceMatrix asAmountOfSubstance(final AmountOfSubstanceUnit displayUnit)
258     {
259         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AmountOfSubstanceUnit.BASE.getSiDimensions())),
260                 UnitRuntimeException.class, "cannot cast %s to AmountOfSubstanceMatrix", this.toString());
261         AmountOfSubstanceMatrixubstanceMatrix.html#AmountOfSubstanceMatrix">AmountOfSubstanceMatrix result = new AmountOfSubstanceMatrix(this.data, displayUnit.getStandardUnit());
262         result.setDisplayUnit(displayUnit);
263         return result;
264     }
265 
266     /**
267      * Return the current matrix as a angularacceleration matrix.
268      * @return AngularAccelerationMatrix; the current matrix as a angularacceleration matrix
269      */
270     public final AngularAccelerationMatrix asAngularAcceleration()
271     {
272         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularAccelerationUnit.BASE.getSiDimensions())),
273                 UnitRuntimeException.class, "cannot cast %s to AngularAccelerationMatrix", this.toString());
274         return new AngularAccelerationMatrix(this.data, AngularAccelerationUnit.SI);
275     }
276 
277     /**
278      * Return the current matrix as a angularacceleration matrix, and provide a display unit.
279      * @param displayUnit the unit in which the value will be displayed
280      * @return AngularAccelerationMatrix; the current matrix as a angularacceleration matrix
281      */
282     public final AngularAccelerationMatrix asAngularAcceleration(final AngularAccelerationUnit displayUnit)
283     {
284         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularAccelerationUnit.BASE.getSiDimensions())),
285                 UnitRuntimeException.class, "cannot cast %s to AngularAccelerationMatrix", this.toString());
286         AngularAccelerationMatrixlerationMatrix.html#AngularAccelerationMatrix">AngularAccelerationMatrix result = new AngularAccelerationMatrix(this.data, displayUnit.getStandardUnit());
287         result.setDisplayUnit(displayUnit);
288         return result;
289     }
290 
291     /**
292      * Return the current matrix as a angularvelocity matrix.
293      * @return AngularVelocityMatrix; the current matrix as a angularvelocity matrix
294      */
295     public final AngularVelocityMatrix asAngularVelocity()
296     {
297         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularVelocityUnit.BASE.getSiDimensions())),
298                 UnitRuntimeException.class, "cannot cast %s to AngularVelocityMatrix", this.toString());
299         return new AngularVelocityMatrix(this.data, AngularVelocityUnit.SI);
300     }
301 
302     /**
303      * Return the current matrix as a angularvelocity matrix, and provide a display unit.
304      * @param displayUnit the unit in which the value will be displayed
305      * @return AngularVelocityMatrix; the current matrix as a angularvelocity matrix
306      */
307     public final AngularVelocityMatrix asAngularVelocity(final AngularVelocityUnit displayUnit)
308     {
309         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngularVelocityUnit.BASE.getSiDimensions())),
310                 UnitRuntimeException.class, "cannot cast %s to AngularVelocityMatrix", this.toString());
311         AngularVelocityMatrixVelocityMatrix.html#AngularVelocityMatrix">AngularVelocityMatrix result = new AngularVelocityMatrix(this.data, displayUnit.getStandardUnit());
312         result.setDisplayUnit(displayUnit);
313         return result;
314     }
315 
316     /**
317      * Return the current matrix as a area matrix.
318      * @return AreaMatrix; the current matrix as a area matrix
319      */
320     public final AreaMatrix asArea()
321     {
322         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AreaUnit.BASE.getSiDimensions())),
323                 UnitRuntimeException.class, "cannot cast %s to AreaMatrix", this.toString());
324         return new AreaMatrix(this.data, AreaUnit.SI);
325     }
326 
327     /**
328      * Return the current matrix as a area matrix, and provide a display unit.
329      * @param displayUnit the unit in which the value will be displayed
330      * @return AreaMatrix; the current matrix as a area matrix
331      */
332     public final AreaMatrix asArea(final AreaUnit displayUnit)
333     {
334         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AreaUnit.BASE.getSiDimensions())),
335                 UnitRuntimeException.class, "cannot cast %s to AreaMatrix", this.toString());
336         AreaMatrixrix/AreaMatrix.html#AreaMatrix">AreaMatrix result = new AreaMatrix(this.data, displayUnit.getStandardUnit());
337         result.setDisplayUnit(displayUnit);
338         return result;
339     }
340 
341     /**
342      * Return the current matrix as a catalyticactivity matrix.
343      * @return CatalyticActivityMatrix; the current matrix as a catalyticactivity matrix
344      */
345     public final CatalyticActivityMatrix asCatalyticActivity()
346     {
347         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(CatalyticActivityUnit.BASE.getSiDimensions())),
348                 UnitRuntimeException.class, "cannot cast %s to CatalyticActivityMatrix", this.toString());
349         return new CatalyticActivityMatrix(this.data, CatalyticActivityUnit.SI);
350     }
351 
352     /**
353      * Return the current matrix as a catalyticactivity matrix, and provide a display unit.
354      * @param displayUnit the unit in which the value will be displayed
355      * @return CatalyticActivityMatrix; the current matrix as a catalyticactivity matrix
356      */
357     public final CatalyticActivityMatrix asCatalyticActivity(final CatalyticActivityUnit displayUnit)
358     {
359         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(CatalyticActivityUnit.BASE.getSiDimensions())),
360                 UnitRuntimeException.class, "cannot cast %s to CatalyticActivityMatrix", this.toString());
361         CatalyticActivityMatrixActivityMatrix.html#CatalyticActivityMatrix">CatalyticActivityMatrix result = new CatalyticActivityMatrix(this.data, displayUnit.getStandardUnit());
362         result.setDisplayUnit(displayUnit);
363         return result;
364     }
365 
366     /**
367      * Return the current matrix as a density matrix.
368      * @return DensityMatrix; the current matrix as a density matrix
369      */
370     public final DensityMatrix asDensity()
371     {
372         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DensityUnit.BASE.getSiDimensions())),
373                 UnitRuntimeException.class, "cannot cast %s to DensityMatrix", this.toString());
374         return new DensityMatrix(this.data, DensityUnit.SI);
375     }
376 
377     /**
378      * Return the current matrix as a density matrix, and provide a display unit.
379      * @param displayUnit the unit in which the value will be displayed
380      * @return DensityMatrix; the current matrix as a density matrix
381      */
382     public final DensityMatrix asDensity(final DensityUnit displayUnit)
383     {
384         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DensityUnit.BASE.getSiDimensions())),
385                 UnitRuntimeException.class, "cannot cast %s to DensityMatrix", this.toString());
386         DensityMatrix/DensityMatrix.html#DensityMatrix">DensityMatrix result = new DensityMatrix(this.data, displayUnit.getStandardUnit());
387         result.setDisplayUnit(displayUnit);
388         return result;
389     }
390 
391     /**
392      * Return the current matrix as a dimensionless matrix.
393      * @return DimensionlessMatrix; the current matrix as a dimensionless matrix
394      */
395     public final DimensionlessMatrix asDimensionless()
396     {
397         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DimensionlessUnit.BASE.getSiDimensions())),
398                 UnitRuntimeException.class, "cannot cast %s to DimensionlessMatrix", this.toString());
399         return new DimensionlessMatrix(this.data, DimensionlessUnit.SI);
400     }
401 
402     /**
403      * Return the current matrix as a dimensionless matrix, and provide a display unit.
404      * @param displayUnit the unit in which the value will be displayed
405      * @return DimensionlessMatrix; the current matrix as a dimensionless matrix
406      */
407     public final DimensionlessMatrix asDimensionless(final DimensionlessUnit displayUnit)
408     {
409         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DimensionlessUnit.BASE.getSiDimensions())),
410                 UnitRuntimeException.class, "cannot cast %s to DimensionlessMatrix", this.toString());
411         DimensionlessMatrixsionlessMatrix.html#DimensionlessMatrix">DimensionlessMatrix result = new DimensionlessMatrix(this.data, displayUnit.getStandardUnit());
412         result.setDisplayUnit(displayUnit);
413         return result;
414     }
415 
416     /**
417      * Return the current matrix as a electricalcapacitance matrix.
418      * @return ElectricalCapacitanceMatrix; the current matrix as a electricalcapacitance matrix
419      */
420     public final ElectricalCapacitanceMatrix asElectricalCapacitance()
421     {
422         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCapacitanceUnit.BASE.getSiDimensions())),
423                 UnitRuntimeException.class, "cannot cast %s to ElectricalCapacitanceMatrix", this.toString());
424         return new ElectricalCapacitanceMatrix(this.data, ElectricalCapacitanceUnit.SI);
425     }
426 
427     /**
428      * Return the current matrix as a electricalcapacitance matrix, and provide a display unit.
429      * @param displayUnit the unit in which the value will be displayed
430      * @return ElectricalCapacitanceMatrix; the current matrix as a electricalcapacitance matrix
431      */
432     public final ElectricalCapacitanceMatrix asElectricalCapacitance(final ElectricalCapacitanceUnit displayUnit)
433     {
434         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCapacitanceUnit.BASE.getSiDimensions())),
435                 UnitRuntimeException.class, "cannot cast %s to ElectricalCapacitanceMatrix", this.toString());
436         ElectricalCapacitanceMatrixacitanceMatrix.html#ElectricalCapacitanceMatrix">ElectricalCapacitanceMatrix result = new ElectricalCapacitanceMatrix(this.data, displayUnit.getStandardUnit());
437         result.setDisplayUnit(displayUnit);
438         return result;
439     }
440 
441     /**
442      * Return the current matrix as a electricalcharge matrix.
443      * @return ElectricalChargeMatrix; the current matrix as a electricalcharge matrix
444      */
445     public final ElectricalChargeMatrix asElectricalCharge()
446     {
447         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalChargeUnit.BASE.getSiDimensions())),
448                 UnitRuntimeException.class, "cannot cast %s to ElectricalChargeMatrix", this.toString());
449         return new ElectricalChargeMatrix(this.data, ElectricalChargeUnit.SI);
450     }
451 
452     /**
453      * Return the current matrix as a electricalcharge matrix, and provide a display unit.
454      * @param displayUnit the unit in which the value will be displayed
455      * @return ElectricalChargeMatrix; the current matrix as a electricalcharge matrix
456      */
457     public final ElectricalChargeMatrix asElectricalCharge(final ElectricalChargeUnit displayUnit)
458     {
459         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalChargeUnit.BASE.getSiDimensions())),
460                 UnitRuntimeException.class, "cannot cast %s to ElectricalChargeMatrix", this.toString());
461         ElectricalChargeMatrixalChargeMatrix.html#ElectricalChargeMatrix">ElectricalChargeMatrix result = new ElectricalChargeMatrix(this.data, displayUnit.getStandardUnit());
462         result.setDisplayUnit(displayUnit);
463         return result;
464     }
465 
466     /**
467      * Return the current matrix as a electricalconductance matrix.
468      * @return ElectricalConductanceMatrix; the current matrix as a electricalconductance matrix
469      */
470     public final ElectricalConductanceMatrix asElectricalConductance()
471     {
472         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalConductanceUnit.BASE.getSiDimensions())),
473                 UnitRuntimeException.class, "cannot cast %s to ElectricalConductanceMatrix", this.toString());
474         return new ElectricalConductanceMatrix(this.data, ElectricalConductanceUnit.SI);
475     }
476 
477     /**
478      * Return the current matrix as a electricalconductance matrix, and provide a display unit.
479      * @param displayUnit the unit in which the value will be displayed
480      * @return ElectricalConductanceMatrix; the current matrix as a electricalconductance matrix
481      */
482     public final ElectricalConductanceMatrix asElectricalConductance(final ElectricalConductanceUnit displayUnit)
483     {
484         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalConductanceUnit.BASE.getSiDimensions())),
485                 UnitRuntimeException.class, "cannot cast %s to ElectricalConductanceMatrix", this.toString());
486         ElectricalConductanceMatrixductanceMatrix.html#ElectricalConductanceMatrix">ElectricalConductanceMatrix result = new ElectricalConductanceMatrix(this.data, displayUnit.getStandardUnit());
487         result.setDisplayUnit(displayUnit);
488         return result;
489     }
490 
491     /**
492      * Return the current matrix as a electricalcurrent matrix.
493      * @return ElectricalCurrentMatrix; the current matrix as a electricalcurrent matrix
494      */
495     public final ElectricalCurrentMatrix asElectricalCurrent()
496     {
497         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCurrentUnit.BASE.getSiDimensions())),
498                 UnitRuntimeException.class, "cannot cast %s to ElectricalCurrentMatrix", this.toString());
499         return new ElectricalCurrentMatrix(this.data, ElectricalCurrentUnit.SI);
500     }
501 
502     /**
503      * Return the current matrix as a electricalcurrent matrix, and provide a display unit.
504      * @param displayUnit the unit in which the value will be displayed
505      * @return ElectricalCurrentMatrix; the current matrix as a electricalcurrent matrix
506      */
507     public final ElectricalCurrentMatrix asElectricalCurrent(final ElectricalCurrentUnit displayUnit)
508     {
509         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalCurrentUnit.BASE.getSiDimensions())),
510                 UnitRuntimeException.class, "cannot cast %s to ElectricalCurrentMatrix", this.toString());
511         ElectricalCurrentMatrixlCurrentMatrix.html#ElectricalCurrentMatrix">ElectricalCurrentMatrix result = new ElectricalCurrentMatrix(this.data, displayUnit.getStandardUnit());
512         result.setDisplayUnit(displayUnit);
513         return result;
514     }
515 
516     /**
517      * Return the current matrix as a electricalinductance matrix.
518      * @return ElectricalInductanceMatrix; the current matrix as a electricalinductance matrix
519      */
520     public final ElectricalInductanceMatrix asElectricalInductance()
521     {
522         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalInductanceUnit.BASE.getSiDimensions())),
523                 UnitRuntimeException.class, "cannot cast %s to ElectricalInductanceMatrix", this.toString());
524         return new ElectricalInductanceMatrix(this.data, ElectricalInductanceUnit.SI);
525     }
526 
527     /**
528      * Return the current matrix as a electricalinductance matrix, and provide a display unit.
529      * @param displayUnit the unit in which the value will be displayed
530      * @return ElectricalInductanceMatrix; the current matrix as a electricalinductance matrix
531      */
532     public final ElectricalInductanceMatrix asElectricalInductance(final ElectricalInductanceUnit displayUnit)
533     {
534         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalInductanceUnit.BASE.getSiDimensions())),
535                 UnitRuntimeException.class, "cannot cast %s to ElectricalInductanceMatrix", this.toString());
536         ElectricalInductanceMatrixductanceMatrix.html#ElectricalInductanceMatrix">ElectricalInductanceMatrix result = new ElectricalInductanceMatrix(this.data, displayUnit.getStandardUnit());
537         result.setDisplayUnit(displayUnit);
538         return result;
539     }
540 
541     /**
542      * Return the current matrix as a electricalpotential matrix.
543      * @return ElectricalPotentialMatrix; the current matrix as a electricalpotential matrix
544      */
545     public final ElectricalPotentialMatrix asElectricalPotential()
546     {
547         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalPotentialUnit.BASE.getSiDimensions())),
548                 UnitRuntimeException.class, "cannot cast %s to ElectricalPotentialMatrix", this.toString());
549         return new ElectricalPotentialMatrix(this.data, ElectricalPotentialUnit.SI);
550     }
551 
552     /**
553      * Return the current matrix as a electricalpotential matrix, and provide a display unit.
554      * @param displayUnit the unit in which the value will be displayed
555      * @return ElectricalPotentialMatrix; the current matrix as a electricalpotential matrix
556      */
557     public final ElectricalPotentialMatrix asElectricalPotential(final ElectricalPotentialUnit displayUnit)
558     {
559         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalPotentialUnit.BASE.getSiDimensions())),
560                 UnitRuntimeException.class, "cannot cast %s to ElectricalPotentialMatrix", this.toString());
561         ElectricalPotentialMatrixotentialMatrix.html#ElectricalPotentialMatrix">ElectricalPotentialMatrix result = new ElectricalPotentialMatrix(this.data, displayUnit.getStandardUnit());
562         result.setDisplayUnit(displayUnit);
563         return result;
564     }
565 
566     /**
567      * Return the current matrix as a electricalresistance matrix.
568      * @return ElectricalResistanceMatrix; the current matrix as a electricalresistance matrix
569      */
570     public final ElectricalResistanceMatrix asElectricalResistance()
571     {
572         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalResistanceUnit.BASE.getSiDimensions())),
573                 UnitRuntimeException.class, "cannot cast %s to ElectricalResistanceMatrix", this.toString());
574         return new ElectricalResistanceMatrix(this.data, ElectricalResistanceUnit.SI);
575     }
576 
577     /**
578      * Return the current matrix as a electricalresistance matrix, and provide a display unit.
579      * @param displayUnit the unit in which the value will be displayed
580      * @return ElectricalResistanceMatrix; the current matrix as a electricalresistance matrix
581      */
582     public final ElectricalResistanceMatrix asElectricalResistance(final ElectricalResistanceUnit displayUnit)
583     {
584         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ElectricalResistanceUnit.BASE.getSiDimensions())),
585                 UnitRuntimeException.class, "cannot cast %s to ElectricalResistanceMatrix", this.toString());
586         ElectricalResistanceMatrixsistanceMatrix.html#ElectricalResistanceMatrix">ElectricalResistanceMatrix result = new ElectricalResistanceMatrix(this.data, displayUnit.getStandardUnit());
587         result.setDisplayUnit(displayUnit);
588         return result;
589     }
590 
591     /**
592      * Return the current matrix as a energy matrix.
593      * @return EnergyMatrix; the current matrix as a energy matrix
594      */
595     public final EnergyMatrix asEnergy()
596     {
597         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EnergyUnit.BASE.getSiDimensions())),
598                 UnitRuntimeException.class, "cannot cast %s to EnergyMatrix", this.toString());
599         return new EnergyMatrix(this.data, EnergyUnit.SI);
600     }
601 
602     /**
603      * Return the current matrix as a energy matrix, and provide a display unit.
604      * @param displayUnit the unit in which the value will be displayed
605      * @return EnergyMatrix; the current matrix as a energy matrix
606      */
607     public final EnergyMatrix asEnergy(final EnergyUnit displayUnit)
608     {
609         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EnergyUnit.BASE.getSiDimensions())),
610                 UnitRuntimeException.class, "cannot cast %s to EnergyMatrix", this.toString());
611         EnergyMatrixx/EnergyMatrix.html#EnergyMatrix">EnergyMatrix result = new EnergyMatrix(this.data, displayUnit.getStandardUnit());
612         result.setDisplayUnit(displayUnit);
613         return result;
614     }
615 
616     /**
617      * Return the current matrix as a equivalentdose matrix.
618      * @return EquivalentDoseMatrix; the current matrix as a equivalentdose matrix
619      */
620     public final EquivalentDoseMatrix asEquivalentDose()
621     {
622         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EquivalentDoseUnit.BASE.getSiDimensions())),
623                 UnitRuntimeException.class, "cannot cast %s to EquivalentDoseMatrix", this.toString());
624         return new EquivalentDoseMatrix(this.data, EquivalentDoseUnit.SI);
625     }
626 
627     /**
628      * Return the current matrix as a equivalentdose matrix, and provide a display unit.
629      * @param displayUnit the unit in which the value will be displayed
630      * @return EquivalentDoseMatrix; the current matrix as a equivalentdose matrix
631      */
632     public final EquivalentDoseMatrix asEquivalentDose(final EquivalentDoseUnit displayUnit)
633     {
634         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(EquivalentDoseUnit.BASE.getSiDimensions())),
635                 UnitRuntimeException.class, "cannot cast %s to EquivalentDoseMatrix", this.toString());
636         EquivalentDoseMatrixlentDoseMatrix.html#EquivalentDoseMatrix">EquivalentDoseMatrix result = new EquivalentDoseMatrix(this.data, displayUnit.getStandardUnit());
637         result.setDisplayUnit(displayUnit);
638         return result;
639     }
640 
641     /**
642      * Return the current matrix as a flowmass matrix.
643      * @return FlowMassMatrix; the current matrix as a flowmass matrix
644      */
645     public final FlowMassMatrix asFlowMass()
646     {
647         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowMassUnit.BASE.getSiDimensions())),
648                 UnitRuntimeException.class, "cannot cast %s to FlowMassMatrix", this.toString());
649         return new FlowMassMatrix(this.data, FlowMassUnit.SI);
650     }
651 
652     /**
653      * Return the current matrix as a flowmass matrix, and provide a display unit.
654      * @param displayUnit the unit in which the value will be displayed
655      * @return FlowMassMatrix; the current matrix as a flowmass matrix
656      */
657     public final FlowMassMatrix asFlowMass(final FlowMassUnit displayUnit)
658     {
659         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowMassUnit.BASE.getSiDimensions())),
660                 UnitRuntimeException.class, "cannot cast %s to FlowMassMatrix", this.toString());
661         FlowMassMatrixFlowMassMatrix.html#FlowMassMatrix">FlowMassMatrix result = new FlowMassMatrix(this.data, displayUnit.getStandardUnit());
662         result.setDisplayUnit(displayUnit);
663         return result;
664     }
665 
666     /**
667      * Return the current matrix as a flowvolume matrix.
668      * @return FlowVolumeMatrix; the current matrix as a flowvolume matrix
669      */
670     public final FlowVolumeMatrix asFlowVolume()
671     {
672         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowVolumeUnit.BASE.getSiDimensions())),
673                 UnitRuntimeException.class, "cannot cast %s to FlowVolumeMatrix", this.toString());
674         return new FlowVolumeMatrix(this.data, FlowVolumeUnit.SI);
675     }
676 
677     /**
678      * Return the current matrix as a flowvolume matrix, and provide a display unit.
679      * @param displayUnit the unit in which the value will be displayed
680      * @return FlowVolumeMatrix; the current matrix as a flowvolume matrix
681      */
682     public final FlowVolumeMatrix asFlowVolume(final FlowVolumeUnit displayUnit)
683     {
684         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FlowVolumeUnit.BASE.getSiDimensions())),
685                 UnitRuntimeException.class, "cannot cast %s to FlowVolumeMatrix", this.toString());
686         FlowVolumeMatrixowVolumeMatrix.html#FlowVolumeMatrix">FlowVolumeMatrix result = new FlowVolumeMatrix(this.data, displayUnit.getStandardUnit());
687         result.setDisplayUnit(displayUnit);
688         return result;
689     }
690 
691     /**
692      * Return the current matrix as a force matrix.
693      * @return ForceMatrix; the current matrix as a force matrix
694      */
695     public final ForceMatrix asForce()
696     {
697         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ForceUnit.BASE.getSiDimensions())),
698                 UnitRuntimeException.class, "cannot cast %s to ForceMatrix", this.toString());
699         return new ForceMatrix(this.data, ForceUnit.SI);
700     }
701 
702     /**
703      * Return the current matrix as a force matrix, and provide a display unit.
704      * @param displayUnit the unit in which the value will be displayed
705      * @return ForceMatrix; the current matrix as a force matrix
706      */
707     public final ForceMatrix asForce(final ForceUnit displayUnit)
708     {
709         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(ForceUnit.BASE.getSiDimensions())),
710                 UnitRuntimeException.class, "cannot cast %s to ForceMatrix", this.toString());
711         ForceMatrixix/ForceMatrix.html#ForceMatrix">ForceMatrix result = new ForceMatrix(this.data, displayUnit.getStandardUnit());
712         result.setDisplayUnit(displayUnit);
713         return result;
714     }
715 
716     /**
717      * Return the current matrix as a frequency matrix.
718      * @return FrequencyMatrix; the current matrix as a frequency matrix
719      */
720     public final FrequencyMatrix asFrequency()
721     {
722         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FrequencyUnit.BASE.getSiDimensions())),
723                 UnitRuntimeException.class, "cannot cast %s to FrequencyMatrix", this.toString());
724         return new FrequencyMatrix(this.data, FrequencyUnit.SI);
725     }
726 
727     /**
728      * Return the current matrix as a frequency matrix, and provide a display unit.
729      * @param displayUnit the unit in which the value will be displayed
730      * @return FrequencyMatrix; the current matrix as a frequency matrix
731      */
732     public final FrequencyMatrix asFrequency(final FrequencyUnit displayUnit)
733     {
734         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(FrequencyUnit.BASE.getSiDimensions())),
735                 UnitRuntimeException.class, "cannot cast %s to FrequencyMatrix", this.toString());
736         FrequencyMatrixrequencyMatrix.html#FrequencyMatrix">FrequencyMatrix result = new FrequencyMatrix(this.data, displayUnit.getStandardUnit());
737         result.setDisplayUnit(displayUnit);
738         return result;
739     }
740 
741     /**
742      * Return the current matrix as a illuminance matrix.
743      * @return IlluminanceMatrix; the current matrix as a illuminance matrix
744      */
745     public final IlluminanceMatrix asIlluminance()
746     {
747         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(IlluminanceUnit.BASE.getSiDimensions())),
748                 UnitRuntimeException.class, "cannot cast %s to IlluminanceMatrix", this.toString());
749         return new IlluminanceMatrix(this.data, IlluminanceUnit.SI);
750     }
751 
752     /**
753      * Return the current matrix as a illuminance matrix, and provide a display unit.
754      * @param displayUnit the unit in which the value will be displayed
755      * @return IlluminanceMatrix; the current matrix as a illuminance matrix
756      */
757     public final IlluminanceMatrix asIlluminance(final IlluminanceUnit displayUnit)
758     {
759         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(IlluminanceUnit.BASE.getSiDimensions())),
760                 UnitRuntimeException.class, "cannot cast %s to IlluminanceMatrix", this.toString());
761         IlluminanceMatrixuminanceMatrix.html#IlluminanceMatrix">IlluminanceMatrix result = new IlluminanceMatrix(this.data, displayUnit.getStandardUnit());
762         result.setDisplayUnit(displayUnit);
763         return result;
764     }
765 
766     /**
767      * Return the current matrix as a lineardensity matrix.
768      * @return LinearDensityMatrix; the current matrix as a lineardensity matrix
769      */
770     public final LinearDensityMatrix asLinearDensity()
771     {
772         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LinearDensityUnit.BASE.getSiDimensions())),
773                 UnitRuntimeException.class, "cannot cast %s to LinearDensityMatrix", this.toString());
774         return new LinearDensityMatrix(this.data, LinearDensityUnit.SI);
775     }
776 
777     /**
778      * Return the current matrix as a lineardensity matrix, and provide a display unit.
779      * @param displayUnit the unit in which the value will be displayed
780      * @return LinearDensityMatrix; the current matrix as a lineardensity matrix
781      */
782     public final LinearDensityMatrix asLinearDensity(final LinearDensityUnit displayUnit)
783     {
784         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LinearDensityUnit.BASE.getSiDimensions())),
785                 UnitRuntimeException.class, "cannot cast %s to LinearDensityMatrix", this.toString());
786         LinearDensityMatrixrDensityMatrix.html#LinearDensityMatrix">LinearDensityMatrix result = new LinearDensityMatrix(this.data, displayUnit.getStandardUnit());
787         result.setDisplayUnit(displayUnit);
788         return result;
789     }
790 
791     /**
792      * Return the current matrix as a luminousflux matrix.
793      * @return LuminousFluxMatrix; the current matrix as a luminousflux matrix
794      */
795     public final LuminousFluxMatrix asLuminousFlux()
796     {
797         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousFluxUnit.BASE.getSiDimensions())),
798                 UnitRuntimeException.class, "cannot cast %s to LuminousFluxMatrix", this.toString());
799         return new LuminousFluxMatrix(this.data, LuminousFluxUnit.SI);
800     }
801 
802     /**
803      * Return the current matrix as a luminousflux matrix, and provide a display unit.
804      * @param displayUnit the unit in which the value will be displayed
805      * @return LuminousFluxMatrix; the current matrix as a luminousflux matrix
806      */
807     public final LuminousFluxMatrix asLuminousFlux(final LuminousFluxUnit displayUnit)
808     {
809         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousFluxUnit.BASE.getSiDimensions())),
810                 UnitRuntimeException.class, "cannot cast %s to LuminousFluxMatrix", this.toString());
811         LuminousFluxMatrixnousFluxMatrix.html#LuminousFluxMatrix">LuminousFluxMatrix result = new LuminousFluxMatrix(this.data, displayUnit.getStandardUnit());
812         result.setDisplayUnit(displayUnit);
813         return result;
814     }
815 
816     /**
817      * Return the current matrix as a luminousintensity matrix.
818      * @return LuminousIntensityMatrix; the current matrix as a luminousintensity matrix
819      */
820     public final LuminousIntensityMatrix asLuminousIntensity()
821     {
822         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousIntensityUnit.BASE.getSiDimensions())),
823                 UnitRuntimeException.class, "cannot cast %s to LuminousIntensityMatrix", this.toString());
824         return new LuminousIntensityMatrix(this.data, LuminousIntensityUnit.SI);
825     }
826 
827     /**
828      * Return the current matrix as a luminousintensity matrix, and provide a display unit.
829      * @param displayUnit the unit in which the value will be displayed
830      * @return LuminousIntensityMatrix; the current matrix as a luminousintensity matrix
831      */
832     public final LuminousIntensityMatrix asLuminousIntensity(final LuminousIntensityUnit displayUnit)
833     {
834         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LuminousIntensityUnit.BASE.getSiDimensions())),
835                 UnitRuntimeException.class, "cannot cast %s to LuminousIntensityMatrix", this.toString());
836         LuminousIntensityMatrixntensityMatrix.html#LuminousIntensityMatrix">LuminousIntensityMatrix result = new LuminousIntensityMatrix(this.data, displayUnit.getStandardUnit());
837         result.setDisplayUnit(displayUnit);
838         return result;
839     }
840 
841     /**
842      * Return the current matrix as a magneticfluxdensity matrix.
843      * @return MagneticFluxDensityMatrix; the current matrix as a magneticfluxdensity matrix
844      */
845     public final MagneticFluxDensityMatrix asMagneticFluxDensity()
846     {
847         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxDensityUnit.BASE.getSiDimensions())),
848                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxDensityMatrix", this.toString());
849         return new MagneticFluxDensityMatrix(this.data, MagneticFluxDensityUnit.SI);
850     }
851 
852     /**
853      * Return the current matrix as a magneticfluxdensity matrix, and provide a display unit.
854      * @param displayUnit the unit in which the value will be displayed
855      * @return MagneticFluxDensityMatrix; the current matrix as a magneticfluxdensity matrix
856      */
857     public final MagneticFluxDensityMatrix asMagneticFluxDensity(final MagneticFluxDensityUnit displayUnit)
858     {
859         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxDensityUnit.BASE.getSiDimensions())),
860                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxDensityMatrix", this.toString());
861         MagneticFluxDensityMatrixxDensityMatrix.html#MagneticFluxDensityMatrix">MagneticFluxDensityMatrix result = new MagneticFluxDensityMatrix(this.data, displayUnit.getStandardUnit());
862         result.setDisplayUnit(displayUnit);
863         return result;
864     }
865 
866     /**
867      * Return the current matrix as a magneticflux matrix.
868      * @return MagneticFluxMatrix; the current matrix as a magneticflux matrix
869      */
870     public final MagneticFluxMatrix asMagneticFlux()
871     {
872         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxUnit.BASE.getSiDimensions())),
873                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxMatrix", this.toString());
874         return new MagneticFluxMatrix(this.data, MagneticFluxUnit.SI);
875     }
876 
877     /**
878      * Return the current matrix as a magneticflux matrix, and provide a display unit.
879      * @param displayUnit the unit in which the value will be displayed
880      * @return MagneticFluxMatrix; the current matrix as a magneticflux matrix
881      */
882     public final MagneticFluxMatrix asMagneticFlux(final MagneticFluxUnit displayUnit)
883     {
884         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MagneticFluxUnit.BASE.getSiDimensions())),
885                 UnitRuntimeException.class, "cannot cast %s to MagneticFluxMatrix", this.toString());
886         MagneticFluxMatrixeticFluxMatrix.html#MagneticFluxMatrix">MagneticFluxMatrix result = new MagneticFluxMatrix(this.data, displayUnit.getStandardUnit());
887         result.setDisplayUnit(displayUnit);
888         return result;
889     }
890 
891     /**
892      * Return the current matrix as a mass matrix.
893      * @return MassMatrix; the current matrix as a mass matrix
894      */
895     public final MassMatrix asMass()
896     {
897         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MassUnit.BASE.getSiDimensions())),
898                 UnitRuntimeException.class, "cannot cast %s to MassMatrix", this.toString());
899         return new MassMatrix(this.data, MassUnit.SI);
900     }
901 
902     /**
903      * Return the current matrix as a mass matrix, and provide a display unit.
904      * @param displayUnit the unit in which the value will be displayed
905      * @return MassMatrix; the current matrix as a mass matrix
906      */
907     public final MassMatrix asMass(final MassUnit displayUnit)
908     {
909         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MassUnit.BASE.getSiDimensions())),
910                 UnitRuntimeException.class, "cannot cast %s to MassMatrix", this.toString());
911         MassMatrixrix/MassMatrix.html#MassMatrix">MassMatrix result = new MassMatrix(this.data, displayUnit.getStandardUnit());
912         result.setDisplayUnit(displayUnit);
913         return result;
914     }
915 
916     /**
917      * Return the current matrix as a momentum matrix.
918      * @return MomentumMatrix; the current matrix as a momentum matrix
919      */
920     public final MomentumMatrix asMomentum()
921     {
922         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MomentumUnit.BASE.getSiDimensions())),
923                 UnitRuntimeException.class, "cannot cast %s to MomentumMatrix", this.toString());
924         return new MomentumMatrix(this.data, MomentumUnit.SI);
925     }
926 
927     /**
928      * Return the current matrix as a momentum matrix, and provide a display unit.
929      * @param displayUnit the unit in which the value will be displayed
930      * @return MomentumMatrix; the current matrix as a momentum matrix
931      */
932     public final MomentumMatrix asMomentum(final MomentumUnit displayUnit)
933     {
934         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(MomentumUnit.BASE.getSiDimensions())),
935                 UnitRuntimeException.class, "cannot cast %s to MomentumMatrix", this.toString());
936         MomentumMatrixMomentumMatrix.html#MomentumMatrix">MomentumMatrix result = new MomentumMatrix(this.data, displayUnit.getStandardUnit());
937         result.setDisplayUnit(displayUnit);
938         return result;
939     }
940 
941     /**
942      * Return the current matrix as a power matrix.
943      * @return PowerMatrix; the current matrix as a power matrix
944      */
945     public final PowerMatrix asPower()
946     {
947         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PowerUnit.BASE.getSiDimensions())),
948                 UnitRuntimeException.class, "cannot cast %s to PowerMatrix", this.toString());
949         return new PowerMatrix(this.data, PowerUnit.SI);
950     }
951 
952     /**
953      * Return the current matrix as a power matrix, and provide a display unit.
954      * @param displayUnit the unit in which the value will be displayed
955      * @return PowerMatrix; the current matrix as a power matrix
956      */
957     public final PowerMatrix asPower(final PowerUnit displayUnit)
958     {
959         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PowerUnit.BASE.getSiDimensions())),
960                 UnitRuntimeException.class, "cannot cast %s to PowerMatrix", this.toString());
961         PowerMatrixix/PowerMatrix.html#PowerMatrix">PowerMatrix result = new PowerMatrix(this.data, displayUnit.getStandardUnit());
962         result.setDisplayUnit(displayUnit);
963         return result;
964     }
965 
966     /**
967      * Return the current matrix as a pressure matrix.
968      * @return PressureMatrix; the current matrix as a pressure matrix
969      */
970     public final PressureMatrix asPressure()
971     {
972         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PressureUnit.BASE.getSiDimensions())),
973                 UnitRuntimeException.class, "cannot cast %s to PressureMatrix", this.toString());
974         return new PressureMatrix(this.data, PressureUnit.SI);
975     }
976 
977     /**
978      * Return the current matrix as a pressure matrix, and provide a display unit.
979      * @param displayUnit the unit in which the value will be displayed
980      * @return PressureMatrix; the current matrix as a pressure matrix
981      */
982     public final PressureMatrix asPressure(final PressureUnit displayUnit)
983     {
984         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(PressureUnit.BASE.getSiDimensions())),
985                 UnitRuntimeException.class, "cannot cast %s to PressureMatrix", this.toString());
986         PressureMatrixPressureMatrix.html#PressureMatrix">PressureMatrix result = new PressureMatrix(this.data, displayUnit.getStandardUnit());
987         result.setDisplayUnit(displayUnit);
988         return result;
989     }
990 
991     /**
992      * Return the current matrix as a radioactivity matrix.
993      * @return RadioActivityMatrix; the current matrix as a radioactivity matrix
994      */
995     public final RadioActivityMatrix asRadioActivity()
996     {
997         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(RadioActivityUnit.BASE.getSiDimensions())),
998                 UnitRuntimeException.class, "cannot cast %s to RadioActivityMatrix", this.toString());
999         return new RadioActivityMatrix(this.data, RadioActivityUnit.SI);
1000     }
1001 
1002     /**
1003      * Return the current matrix as a radioactivity matrix, and provide a display unit.
1004      * @param displayUnit the unit in which the value will be displayed
1005      * @return RadioActivityMatrix; the current matrix as a radioactivity matrix
1006      */
1007     public final RadioActivityMatrix asRadioActivity(final RadioActivityUnit displayUnit)
1008     {
1009         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(RadioActivityUnit.BASE.getSiDimensions())),
1010                 UnitRuntimeException.class, "cannot cast %s to RadioActivityMatrix", this.toString());
1011         RadioActivityMatrixActivityMatrix.html#RadioActivityMatrix">RadioActivityMatrix result = new RadioActivityMatrix(this.data, displayUnit.getStandardUnit());
1012         result.setDisplayUnit(displayUnit);
1013         return result;
1014     }
1015 
1016     /**
1017      * Return the current matrix as a solidangle matrix.
1018      * @return SolidAngleMatrix; the current matrix as a solidangle matrix
1019      */
1020     public final SolidAngleMatrix asSolidAngle()
1021     {
1022         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SolidAngleUnit.BASE.getSiDimensions())),
1023                 UnitRuntimeException.class, "cannot cast %s to SolidAngleMatrix", this.toString());
1024         return new SolidAngleMatrix(this.data, SolidAngleUnit.SI);
1025     }
1026 
1027     /**
1028      * Return the current matrix as a solidangle matrix, and provide a display unit.
1029      * @param displayUnit the unit in which the value will be displayed
1030      * @return SolidAngleMatrix; the current matrix as a solidangle matrix
1031      */
1032     public final SolidAngleMatrix asSolidAngle(final SolidAngleUnit displayUnit)
1033     {
1034         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SolidAngleUnit.BASE.getSiDimensions())),
1035                 UnitRuntimeException.class, "cannot cast %s to SolidAngleMatrix", this.toString());
1036         SolidAngleMatrixlidAngleMatrix.html#SolidAngleMatrix">SolidAngleMatrix result = new SolidAngleMatrix(this.data, displayUnit.getStandardUnit());
1037         result.setDisplayUnit(displayUnit);
1038         return result;
1039     }
1040 
1041     /**
1042      * Return the current matrix as a speed matrix.
1043      * @return SpeedMatrix; the current matrix as a speed matrix
1044      */
1045     public final SpeedMatrix asSpeed()
1046     {
1047         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SpeedUnit.BASE.getSiDimensions())),
1048                 UnitRuntimeException.class, "cannot cast %s to SpeedMatrix", this.toString());
1049         return new SpeedMatrix(this.data, SpeedUnit.SI);
1050     }
1051 
1052     /**
1053      * Return the current matrix as a speed matrix, and provide a display unit.
1054      * @param displayUnit the unit in which the value will be displayed
1055      * @return SpeedMatrix; the current matrix as a speed matrix
1056      */
1057     public final SpeedMatrix asSpeed(final SpeedUnit displayUnit)
1058     {
1059         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(SpeedUnit.BASE.getSiDimensions())),
1060                 UnitRuntimeException.class, "cannot cast %s to SpeedMatrix", this.toString());
1061         SpeedMatrixix/SpeedMatrix.html#SpeedMatrix">SpeedMatrix result = new SpeedMatrix(this.data, displayUnit.getStandardUnit());
1062         result.setDisplayUnit(displayUnit);
1063         return result;
1064     }
1065 
1066     /**
1067      * Return the current matrix as a torque matrix.
1068      * @return TorqueMatrix; the current matrix as a torque matrix
1069      */
1070     public final TorqueMatrix asTorque()
1071     {
1072         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TorqueUnit.BASE.getSiDimensions())),
1073                 UnitRuntimeException.class, "cannot cast %s to TorqueMatrix", this.toString());
1074         return new TorqueMatrix(this.data, TorqueUnit.SI);
1075     }
1076 
1077     /**
1078      * Return the current matrix as a torque matrix, and provide a display unit.
1079      * @param displayUnit the unit in which the value will be displayed
1080      * @return TorqueMatrix; the current matrix as a torque matrix
1081      */
1082     public final TorqueMatrix asTorque(final TorqueUnit displayUnit)
1083     {
1084         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TorqueUnit.BASE.getSiDimensions())),
1085                 UnitRuntimeException.class, "cannot cast %s to TorqueMatrix", this.toString());
1086         TorqueMatrixx/TorqueMatrix.html#TorqueMatrix">TorqueMatrix result = new TorqueMatrix(this.data, displayUnit.getStandardUnit());
1087         result.setDisplayUnit(displayUnit);
1088         return result;
1089     }
1090 
1091     /**
1092      * Return the current matrix as a volume matrix.
1093      * @return VolumeMatrix; the current matrix as a volume matrix
1094      */
1095     public final VolumeMatrix asVolume()
1096     {
1097         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(VolumeUnit.BASE.getSiDimensions())),
1098                 UnitRuntimeException.class, "cannot cast %s to VolumeMatrix", this.toString());
1099         return new VolumeMatrix(this.data, VolumeUnit.SI);
1100     }
1101 
1102     /**
1103      * Return the current matrix as a volume matrix, and provide a display unit.
1104      * @param displayUnit the unit in which the value will be displayed
1105      * @return VolumeMatrix; the current matrix as a volume matrix
1106      */
1107     public final VolumeMatrix asVolume(final VolumeUnit displayUnit)
1108     {
1109         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(VolumeUnit.BASE.getSiDimensions())),
1110                 UnitRuntimeException.class, "cannot cast %s to VolumeMatrix", this.toString());
1111         VolumeMatrixx/VolumeMatrix.html#VolumeMatrix">VolumeMatrix result = new VolumeMatrix(this.data, displayUnit.getStandardUnit());
1112         result.setDisplayUnit(displayUnit);
1113         return result;
1114     }
1115 
1116     /**
1117      * Return the current matrix as a angle matrix.
1118      * @return AngleMatrix; the current matrix as a angle matrix
1119      */
1120     public final AngleMatrix asAngle()
1121     {
1122         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngleUnit.BASE.getSiDimensions())),
1123                 UnitRuntimeException.class, "cannot cast %s to AngleMatrix", this.toString());
1124         return new AngleMatrix(this.data, AngleUnit.SI);
1125     }
1126 
1127     /**
1128      * Return the current matrix as a angle matrix, and provide a display unit.
1129      * @param displayUnit the unit in which the value will be displayed
1130      * @return AngleMatrix; the current matrix as a angle matrix
1131      */
1132     public final AngleMatrix asAngle(final AngleUnit displayUnit)
1133     {
1134         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(AngleUnit.BASE.getSiDimensions())),
1135                 UnitRuntimeException.class, "cannot cast %s to AngleMatrix", this.toString());
1136         AngleMatrixix/AngleMatrix.html#AngleMatrix">AngleMatrix result = new AngleMatrix(this.data, displayUnit.getStandardUnit());
1137         result.setDisplayUnit(displayUnit);
1138         return result;
1139     }
1140 
1141     /**
1142      * Return the current matrix as a length matrix.
1143      * @return LengthMatrix; the current matrix as a length matrix
1144      */
1145     public final LengthMatrix asLength()
1146     {
1147         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LengthUnit.BASE.getSiDimensions())),
1148                 UnitRuntimeException.class, "cannot cast %s to LengthMatrix", this.toString());
1149         return new LengthMatrix(this.data, LengthUnit.SI);
1150     }
1151 
1152     /**
1153      * Return the current matrix as a length matrix, and provide a display unit.
1154      * @param displayUnit the unit in which the value will be displayed
1155      * @return LengthMatrix; the current matrix as a length matrix
1156      */
1157     public final LengthMatrix asLength(final LengthUnit displayUnit)
1158     {
1159         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(LengthUnit.BASE.getSiDimensions())),
1160                 UnitRuntimeException.class, "cannot cast %s to LengthMatrix", this.toString());
1161         LengthMatrixx/LengthMatrix.html#LengthMatrix">LengthMatrix result = new LengthMatrix(this.data, displayUnit.getStandardUnit());
1162         result.setDisplayUnit(displayUnit);
1163         return result;
1164     }
1165 
1166     /**
1167      * Return the current matrix as a temperature matrix.
1168      * @return TemperatureMatrix; the current matrix as a temperature matrix
1169      */
1170     public final TemperatureMatrix asTemperature()
1171     {
1172         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TemperatureUnit.BASE.getSiDimensions())),
1173                 UnitRuntimeException.class, "cannot cast %s to TemperatureMatrix", this.toString());
1174         return new TemperatureMatrix(this.data, TemperatureUnit.SI);
1175     }
1176 
1177     /**
1178      * Return the current matrix as a temperature matrix, and provide a display unit.
1179      * @param displayUnit the unit in which the value will be displayed
1180      * @return TemperatureMatrix; the current matrix as a temperature matrix
1181      */
1182     public final TemperatureMatrix asTemperature(final TemperatureUnit displayUnit)
1183     {
1184         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(TemperatureUnit.BASE.getSiDimensions())),
1185                 UnitRuntimeException.class, "cannot cast %s to TemperatureMatrix", this.toString());
1186         TemperatureMatrixperatureMatrix.html#TemperatureMatrix">TemperatureMatrix result = new TemperatureMatrix(this.data, displayUnit.getStandardUnit());
1187         result.setDisplayUnit(displayUnit);
1188         return result;
1189     }
1190 
1191     /**
1192      * Return the current matrix as a duration matrix.
1193      * @return DurationMatrix; the current matrix as a duration matrix
1194      */
1195     public final DurationMatrix asDuration()
1196     {
1197         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DurationUnit.BASE.getSiDimensions())),
1198                 UnitRuntimeException.class, "cannot cast %s to DurationMatrix", this.toString());
1199         return new DurationMatrix(this.data, DurationUnit.SI);
1200     }
1201 
1202     /**
1203      * Return the current matrix as a duration matrix, and provide a display unit.
1204      * @param displayUnit the unit in which the value will be displayed
1205      * @return DurationMatrix; the current matrix as a duration matrix
1206      */
1207     public final DurationMatrix asDuration(final DurationUnit displayUnit)
1208     {
1209         Throw.when(!(getDisplayUnit().getQuantity().getSiDimensions().equals(DurationUnit.BASE.getSiDimensions())),
1210                 UnitRuntimeException.class, "cannot cast %s to DurationMatrix", this.toString());
1211         DurationMatrixDurationMatrix.html#DurationMatrix">DurationMatrix result = new DurationMatrix(this.data, displayUnit.getStandardUnit());
1212         result.setDisplayUnit(displayUnit);
1213         return result;
1214     }
1215 
1216 }