Class FloatVectorRel<U extends Unit<U>,S extends FloatScalarRel<U,S>,RV extends FloatVectorRel<U,S,RV>>

Type Parameters:
U - the unit
S - the scalar type belonging to the vector type
RV - the relative vector type with this unit
All Implemented Interfaces:
Serializable, Cloneable, Iterable<S>, Relative<U,RV>, Value<U,RV>
Direct Known Subclasses:
FloatAbsorbedDoseVector, FloatAccelerationVector, FloatAmountOfSubstanceVector, FloatAngularAccelerationVector, FloatAngularVelocityVector, FloatAreaVector, FloatCatalyticActivityVector, FloatDensityVector, FloatDimensionlessVector, FloatElectricalCapacitanceVector, FloatElectricalChargeVector, FloatElectricalConductanceVector, FloatElectricalCurrentVector, FloatElectricalInductanceVector, FloatElectricalPotentialVector, FloatElectricalResistanceVector, FloatEnergyVector, FloatEquivalentDoseVector, FloatFlowMassVector, FloatFlowVolumeVector, FloatForceVector, FloatFrequencyVector, FloatIlluminanceVector, FloatLinearDensityVector, FloatLuminousFluxVector, FloatLuminousIntensityVector, FloatMagneticFluxDensityVector, FloatMagneticFluxVector, FloatMassVector, FloatMomentumVector, FloatPowerVector, FloatPressureVector, FloatRadioActivityVector, FloatSIVector, FloatSolidAngleVector, FloatSpeedVector, FloatTorqueVector, FloatVectorRelWithAbs, FloatVolumeVector

public abstract class FloatVectorRel<U extends Unit<U>,S extends FloatScalarRel<U,S>,RV extends FloatVectorRel<U,S,RV>> extends FloatVector<U,S,RV> implements Relative<U,RV>
AbstractMutableFloatVectorRel.java.

Copyright (c) 2019-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.

Author:
Alexander Verbraeck
See Also:
  • Constructor Details

    • FloatVectorRel

      protected FloatVectorRel(FloatVectorData data, U unit)
      Construct a new Relative Mutable FloatVector.
      Parameters:
      data - FloatVectorData; an internal data object
      unit - U; the unit
  • Method Details

    • zSum

      public final S zSum()
      Compute the sum of all SI values of this vector.
      Returns:
      S; the sum of all values of this vector with the same display unit as this vector
    • plus

      public final RV plus(RV rel) throws ValueRuntimeException
      Add a Relative value to this Relative value. A new value is returned due to immutability.
      Specified by:
      plus in interface Relative<U extends Unit<U>,S extends FloatScalarRel<U,S>>
      Parameters:
      rel - R; the value to add
      Returns:
      R; the sum of this value and the operand as a new object
      Throws:
      ValueRuntimeException
    • minus

      public final RV minus(RV rel) throws ValueRuntimeException
      Subtract a Relative value from this Relative value. A new value is returned due to immutability.
      Specified by:
      minus in interface Relative<U extends Unit<U>,S extends FloatScalarRel<U,S>>
      Parameters:
      rel - R; the value to subtract
      Returns:
      R; the difference of this value and the operand
      Throws:
      ValueRuntimeException
    • incrementBy

      public RV incrementBy(S increment)
      Increment all values of this vector by the increment. This only works if the vector is mutable.
      Parameters:
      increment - S; the scalar by which to increment all values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case this vector is immutable
    • incrementBy

      public RV incrementBy(RV increment)
      Increment all values of this vector by the increment on a value by value basis. This only works if this vector is mutable.
      Parameters:
      increment - RV; the vector that contains the values by which to increment the corresponding values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case this vector is immutable or when the sizes of the vectors differ
    • decrementBy

      public RV decrementBy(S decrement)
      Decrement all values of this vector by the decrement. This only works if the vector is mutable.
      Parameters:
      decrement - S; the scalar by which to decrement all values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case this vector is immutable
    • decrementBy

      public RV decrementBy(RV decrement)
      Decrement all values of this vector by the decrement on a value by value basis. This only works if this vector is mutable.
      Parameters:
      decrement - RV; the vector that contains the values by which to decrement the corresponding values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case this vector is immutable or when the sizes of the vectors differ
    • multiplyBy

      public RV multiplyBy(float multiplier)
      Multiply all values of this vector by the multiplier. This only works if the vector is mutable.
      Parameters:
      multiplier - float; the factor by which to multiply all values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case the vector is immutable
    • divideBy

      public RV divideBy(float divisor)
      Divide all values of this vector by the divisor. This only works if the vector is mutable.
      Parameters:
      divisor - float; the value by which to divide all values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case the vector is immutable
    • multiplyBy

      public RV multiplyBy(double multiplier)
      Multiply all values of this vector by the multiplier. This only works if the vector is mutable.
      Parameters:
      multiplier - double; the factor by which to multiply all values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case the vector is immutable
    • divideBy

      public RV divideBy(double divisor)
      Divide all values of this vector by the divisor. This only works if the vector is mutable.
      Parameters:
      divisor - double; the value by which to divide all values
      Returns:
      RV; this modified vector
      Throws:
      ValueRuntimeException - in case the vector is immutable
    • times

      public final <UT extends Unit<UT>, ST extends FloatScalarRel<UT, ST>, VT extends FloatVectorRel<UT, ST, VT> & Relative<UT, VT>> FloatSIVector times(VT rel) throws ValueRuntimeException, UnitException
      Multiply a Relative value with this Relative value for a vector or matrix. The multiplication is done value by value and store the result in a new Relative value. If both operands are dense, the result is a dense vector or matrix, otherwise the result is a sparse vector or matrix.
      Type Parameters:
      UT - the unit type of the multiplier
      ST - the scalar type of the multiplier
      VT - the vector type of the multiplier
      Parameters:
      rel - VT; the right operand, which can be any vector type
      Returns:
      FloatSIVector; the multiplication of this vector and the operand
      Throws:
      ValueRuntimeException - in case this vector or matrix and the operand have a different size
      UnitException - on unit error
    • divide

      public final <UT extends Unit<UT>, ST extends FloatScalarRel<UT, ST>, VT extends FloatVectorRel<UT, ST, VT> & Relative<UT, VT>> FloatSIVector divide(VT rel) throws ValueRuntimeException, UnitException
      Divide this Relative value by a Relative value for a vector or matrix. The division is done value by value and store the result in a new Relative value. If both operands are dense, the result is a dense vector or matrix, otherwise the result is a sparse vector or matrix.
      Type Parameters:
      UT - the unit type of the multiplier
      ST - the scalar type of the multiplier
      VT - the vector type of the multiplier
      Parameters:
      rel - VT; the right operand, which can be any vector type
      Returns:
      FloatSIVector; the division of this vector and the operand
      Throws:
      ValueRuntimeException - in case this vector or matrix and the operand have a different size
      UnitException - on unit error
    • times

      public RV times(double multiplier)
      Returns a new scalar/vector/matrix with value(s) multiplied by a factor.
      Specified by:
      times in interface Relative<U extends Unit<U>,S extends FloatScalarRel<U,S>>
      Parameters:
      multiplier - double; the multiplier
      Returns:
      T; a new scalar/vector/matrix
    • divide

      public RV divide(double divisor)
      Returns a new scalar/vector/matrix with value(s) divided by a factor.
      Specified by:
      divide in interface Relative<U extends Unit<U>,S extends FloatScalarRel<U,S>>
      Parameters:
      divisor - double; the divisor
      Returns:
      T; the modified T
    • times

      public RV times(float multiplier)
      Returns a new scalar/vector/matrix with value(s) multiplied by a factor.
      Specified by:
      times in interface Relative<U extends Unit<U>,S extends FloatScalarRel<U,S>>
      Parameters:
      multiplier - float; the multiplier
      Returns:
      T; a new scalar/vector/matrix
    • divide

      public RV divide(float divisor)
      Returns a new scalar/vector/matrix with value(s) divided by a factor.
      Specified by:
      divide in interface Relative<U extends Unit<U>,S extends FloatScalarRel<U,S>>
      Parameters:
      divisor - float; the divisor
      Returns:
      T; the modified T