## SVN Location

Source code can be checked out as an anonymous user from https://svn.tbm.tudelft.nl/DJUNITS/. Releases can be found at https://svn.tbm.tudelft.nl/DJUNITS/release.

## Package structure

DJUNITS is divided into a number of packages:

**org.djunits.locale**for localization of the units. Currently, localization files are provided for English and Dutch. The localization files can be found in src/main/resources. If you like to write a localization for your own language, please do so (but contact us first so we can prevent two persons doing the same task).

**org.djunits.unit**where the unit classes are stored. Each unit has one or more constructors. A SpeedUnit can e.g. be created as a factor of the standard, SI-based speed unit SpeedUnit.METER_PER_SECOND, or as a combination of a LengthUnit and a DurationUnit, e.g., LengthUnit.MILE and DurationUnit.HOUR, leading to a SpeedUnit that indicates speed in miles per hour. Conversions take place automatically. The unit package also contains difference 'scales' for units, such as the linear scale that is used in most units, the OffsetUnit scale that is used in e.g., Temperature, the PercentageUnit scale that is used in percentage angles, and the LogarithmicUnit scale that can be used in e.g., Decibels.

**org.djunits.unit.scale**which defines the scales that can be used for a unit. Examples are the LinearScale that is used in most units, the OffsetLinearScale that is used in e.g., Temperature, the GradeScale that is used in percentage angles, and the LogarithmicScale that can be used in e.g., Decibels. The Scale offers two methods: a method to convert to the standard unit of that type (e.g. from degree Fahrenheit to Kelvin) and a method to convert from the standard unit of that type to the given type (e.g. from Kelvin to degree Fahrenheit)

**org.djunits.unitsystem**defines the different unit systems such as SI [meter, kilogram, second, mol, Ampere, candela, and Kelvin], SI Derived [e.g., degree Celcius, Joule, Ohm or kWh], SI Accepted [e.g, minute, hour or kilometer], and Imperial [e.g., degree Fahrenheit, mile, or pound]. Additionally, some less used unit systems are defined such as AU (Atomic Units), MTS (meter-tonne-second), and CGS (centimeter-gram-second).

**org.djunits.value**provides the base interfaces for the value implementations. Example interfaces are Relative, Absolute, Scalar, and MathFunctions that each are used to ensure implementations of methods in the scalar, vector, and matrix subpackages.

**org.djunits.value.formatter**provides classes that can help in formatting unitized values.

**org.djunits.value.vdouble**contains the interface and implementation of the double precision math functions, such as cbrt, log10, exp1m, etc., as well as an interface that defines multiplication and division of double precision values.

**org.djunits.value.vdouble.scalar**provides two types of classes for double precision implementations. The first one is the generic DoubleScalar that can be instantiated with any unit in absolute or relative form through generalization:

DoubleScalar.Rel<NoiseUnit> noise =

The second class of scalars are the predefined scalars such as Area, Temperature, Duration, and Length. A number of these scalars have both an absolute and a relative implementation. Time/Duration, Position/Length, AbsoluteTemperature/Temperature, and Direction/Angle have both an absolute and a relative form. All other scalars are always relative. Each class has a multitude of mathematical operations that can be applied on the scalar, such as goniometric functions, logarithms, power functions, etc. Furthermore, many multiplications and divisions are implemented in a strongly typed way that is checked by the compiler. If an ElectricalPotential scalar (e.g. in Volts) is divided by an ElectricalCurrent scalar (e.g. in Amperes), the result can only be assigned to a scalar thas has an ElectricalResistance unit (e.g., in Ohms). Please note that the scalars are stored as a public double precision value internally with the name**new**DoubleScalar.Rel<>(10.0, NoiseUnit.DECIBEL);*si*, and are always in a base unit (SI if possible). In addition, the unit in which the scalar was created is stored (not necessarily the SI unit). In total the scalar consists therefore of the standard fields of an Object plus 64 bits for the si double and 64 bits of the pointer to its unit.

**org.djunits.value.vdouble.vector**contains Dense and Sparse implementations of vectors. In addition, the vectors can be absolute or relative, depending on the unit that is used. For now, only the generic DoubleVector is supported, which can be instantiated with any unit. An example is:

TemperatureUnit tempUnit = TemperatureUnit.KELVIN; double[] value = new double[]{273.15, 290.4, 280.5, 279.1}; DoubleVector.Abs<AbsoluteTemperatureUnit> dv = new DoubleVector.Abs<>(value, tempUnit, StorageType.DENSE);

Note that the vector is just defined as an absolute vector, independent of its (dense) implementation.

**org.djunits.value.vdouble.matrix**contains Dense and Sparse implementations of matrices. The way to use the matrices is very much like the examples above for vectors. Matrices and vectors can be added, subtracted, multiplied, and divided. All standard functions such as LU-decomposition, calculation of the determinant, etc. are available as well.

**org.djunits.value.vfloat.scalar**provides two types of classes for float implementations. The first one is the generic FloatScalar that can be instantiated with any unit in absolute or relative form through generalization:

FloatScalar.Rel<NoiseUnit> noise =

The second class of scalars are the predefined scalars such as Area, Temperature, Duration, and Length. A number of these scalars have both an absolute and a relative implementation, indicated by adding '.Rel' or '.Abs' after the class name. Time/Duration, Position/Length, AbsoluteTemperature/Temperature, and Direction/Angle have both an absolute and a relative form. All other scalars are always relative. Each class has a multitude of mathematical operations that can be applied on the scalar, such as goniometric functions, logarithms, power functions, etc. Furthermore, many multiplications and divisions are implemented in a strongly typed way that is checked by the compiler. If an ElectricalPotential scalar (e.g. in Volts) is divided by an ElectricalCurrent scalar (e.g. in Amperes), the result can only be allocated to an ElectricalResistance unit (e.g., in Ohms). Please note that the scalars are stored as a public float value internally with the name**new**FloatScalar.Rel<>(10.0f, NoiseUnit.DECIBEL);*si*, and are always in a base unit (SI if possible). In addition, the unit in which the scalar was created is stored (not necessarily the SI unit). In total the scalar consists therefore of the standard fields of an Object plus 32 bits for the si float and 64 bits of the pointer to its unit.

**org.djunits.value.vfloat.vector**contains Dense and Sparse implementations of vectors. In addition, the vectors can be absolute or relative, depending on the unit that is used. For now, only the generic DoubleVector is supported, which can be instantiated with any unit. An example is:

float[] value = new float[]{10.0f, 0.0f, 10.0f, 0.0f, 0.0f, 20.0f, 0.0f}; FloatVector.Rel<AreaUnit> dv = new FloatVector.Rel<>(value, AreaUnit.SQUARE_KM, StorageType.SPARSE); FloatVector.Rel<AreaUnit> dv2 = dv.exp();

Note that the vector is just defined as a relative vector, independent of its (sparse) implementation.

**org.djunits.value.vfloat.matrix**contains Dense and Sparse implementations of matrices. The way to use the matrices is very much like the examples above for vectors. Matrices and vectors can be added, subtracted, multiplied, and divided. All standard functions such as LU-decomposition, calculation of the determinant, etc. are available as well.