CPD Results
The following document contains the results of PMD's CPD 7.7.0.
Duplications
| File | Line |
|---|---|
| org/djunits/vecmat/dnxm/MatrixNxM.java | 392 |
| org/djunits/vecmat/table/QuantityTable.java | 257 |
return new MatrixNxM<TQ, TU>(this.dataSi.instantiateNew(si()), targetUnit.getBaseUnit()).setDisplayUnit(targetUnit);
}
/**
* Convert this matrix to a {@link Matrix1x1}. The shape must be 1 x 1.
* @return a {@code Matrix1x1} with identical SI data and display unit
* @throws IllegalStateException if this matrix is not 1 x 1
*/
public Matrix1x1<Q, U> asMatrix1x1()
{
Throw.when(rows() != 1 || cols() != 1, IllegalStateException.class,
"asMatrix1x1() called, but matrix is no 1x1 but %dx%d", rows(), cols());
return Matrix1x1.of(si(), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Convert this matrix to a {@link Matrix2x2}. The shape must be 2 x 2.
* @return a {@code Matrix2x2} with identical SI data and display unit
* @throws IllegalStateException if this matrix is not 2 x 2
*/
public Matrix2x2<Q, U> asMatrix2x2()
{
Throw.when(rows() != 2 || cols() != 2, IllegalStateException.class,
"asMatrix2x2() called, but matrix is no 2x2 but %dx%d", rows(), cols());
return Matrix2x2.of(si(), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Convert this matrix to a {@link Matrix3x3}. The shape must be 3 x 3.
* @return a {@code Matrix3x3} with identical SI data and display unit
* @throws IllegalStateException if this matrix is not 3 x 3
*/
public Matrix3x3<Q, U> asMatrix3x3()
{
Throw.when(rows() != 3 || cols() != 3, IllegalStateException.class,
"asMatrix3x3() called, but matrix is no 3x3 but %dx%d", rows(), cols());
return Matrix3x3.of(si(), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Convert this matrix to a {@link MatrixNxN}. The shape must be square.
* @return a {@code MatrixNxN} with identical SI data and display unit
* @throws IllegalStateException if this matrix is not square
*/
public MatrixNxN<Q, U> asMatrixNxN()
{
Throw.when(rows() != cols(), IllegalStateException.class, "asMatrixNxN() called, but matrix is no square but %dx%d",
rows(), cols());
return new MatrixNxN<Q, U>(new DenseDoubleDataSi(si(), rows(), cols()), getDisplayUnit().getBaseUnit())
.setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 1-element column vector. Shape must be 1 x 1.
* @return a {@code Vector1} with identical SI data and display unit
* @throws IllegalStateException if shape is not 1 x 1
*/
public Vector1<Q, U> asVector1()
{
Throw.when(rows() != 1 || cols() != 1, IllegalStateException.class, "Matrix is not 1x1");
final double[] data = si();
return new Vector1<Q, U>(data[0], getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 2-element column vector. Shape must be 2 x 1.
* @return a {@code Vector2.Col} with identical SI data and display unit
* @throws IllegalStateException if shape is not 2 x 1
*/
public Vector2.Col<Q, U> asVector2Col()
{
Throw.when(rows() != 2 || cols() != 1, IllegalStateException.class, "Matrix is not 2x1");
final double[] data = si();
return new Vector2.Col<Q, U>(data[0], data[1], getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 3-element column vector. Shape must be 3 x 1.
* @return a {@code Vector3.Col} with identical SI data and display unit
* @throws IllegalStateException if shape is not 3 x 1
*/
public Vector3.Col<Q, U> asVector3Col()
{
Throw.when(rows() != 3 || cols() != 1, IllegalStateException.class, "Matrix is not 3x1");
final double[] data = si();
return new Vector3.Col<Q, U>(data[0], data[1], data[2], getDisplayUnit().getBaseUnit())
.setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as an N-element column vector. Shape must be N x 1.
* @return a {@code VectorN.Col} with identical SI data and display unit
* @throws IllegalStateException if {@code cols() != 1}
*/
public VectorN.Col<Q, U> asVectorNCol()
{
Throw.when(cols() != 1, IllegalStateException.class, "Matrix is not Nx1");
return VectorN.Col.ofSi(si(), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 2-element row vector. Shape must be 1 x 2.
* @return a {@code Vector2.Row} with identical SI data and display unit
* @throws IllegalStateException if shape is not 1 x 2
*/
public Vector2.Row<Q, U> asVector2Row()
{
Throw.when(rows() != 1 || cols() != 2, IllegalStateException.class, "Matrix is not 1x2");
final double[] data = si();
return new Vector2.Row<Q, U>(data[0], data[1], getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 3-element row vector. Shape must be 1 x 3.
* @return a {@code Vector3.Row} with identical SI data and display unit
* @throws IllegalStateException if shape is not 1 x 3
*/
public Vector3.Row<Q, U> asVector3Row()
{
Throw.when(rows() != 1 || cols() != 3, IllegalStateException.class, "Matrix is not 1x3");
final double[] data = si();
return new Vector3.Row<Q, U>(data[0], data[1], data[2], getDisplayUnit().getBaseUnit())
.setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as an N-element row vector. Shape must be 1 x N.
* @return a {@code VectorN.Row} with identical SI data and display unit
* @throws IllegalStateException if {@code rows() != 1}
*/
public VectorN.Row<Q, U> asVectorNRow()
{
Throw.when(rows() != 1, IllegalStateException.class, "Matrix is not 1xN");
return VectorN.Row.of(si(), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
} | |
| File | Line |
|---|---|
| org/djunits/vecmat/dnxm/MatrixNxM.java | 145 |
| org/djunits/vecmat/table/QuantityTable.java | 143 |
return new MatrixNxM<SIQuantity, SIUnit>(this.dataSi.instantiateNew(siNew), siUnit);
}
/**
* Return the internal datagrid object, so we can retrieve data from it.
* @return the internal datagrid object
*/
public DataGridSi<?> getDataGrid()
{
return this.dataSi;
}
@Override
public double[] si()
{
return this.dataSi.getDataArray();
}
@Override
public double si(final int row, final int col) throws IndexOutOfBoundsException
{
checkRow(row);
checkCol(col);
return this.dataSi.get(row, col);
}
@Override
public VectorN.Row<Q, U> getRowVector(final int row)
{
return VectorN.Row.ofSi(getRowSi(row), getDisplayUnit());
}
@Override
public VectorN.Row<Q, U> mgetRowVector(final int mRow)
{
return VectorN.Row.ofSi(mgetRowSi(mRow), getDisplayUnit());
}
@Override
public VectorN.Col<Q, U> getColumnVector(final int col)
{
return VectorN.Col.ofSi(getColumnSi(col), getDisplayUnit());
}
@Override
public VectorN.Col<Q, U> mgetColumnVector(final int mCol)
{
return VectorN.Col.ofSi(mgetColumnSi(mCol), getDisplayUnit());
}
@Override
public double[] getRowSi(final int row)
{
checkRow(row);
return this.dataSi.getRowArray(row);
}
@Override
public double[] getColumnSi(final int col)
{
checkCol(col);
return this.dataSi.getColArray(col);
}
@Override
public int rows()
{
return this.dataSi.rows();
}
@Override
public int cols()
{
return this.dataSi.cols();
}
@Override
public int hashCode()
{
return Objects.hash(this.dataSi);
}
@SuppressWarnings("checkstyle:needbraces")
@Override
public boolean equals(final Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false; | |
| File | Line |
|---|---|
| org/djunits/vecmat/dn/VectorN.java | 441 |
| org/djunits/vecmat/dnxm/MatrixNxM.java | 441 |
| org/djunits/vecmat/table/QuantityTable.java | 306 |
return new VectorN.Col<TQ, TU>(this.dataSi, targetUnit.getBaseUnit()).setDisplayUnit(targetUnit);
}
/**
* Return this matrix as a 1-element column vector. Shape must be 1 x 1.
* @return a {@code Vector1} with identical SI data and display unit
* @throws IllegalStateException if shape is not 1 x 1
*/
public Vector1<Q, U> asVector1()
{
Throw.when(rows() != 1 || cols() != 1, IllegalStateException.class, "Matrix is not 1x1");
final double[] data = si();
return new Vector1<Q, U>(data[0], getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 2-element column vector. Shape must be 2 x 1.
* @return a {@code Vector2.Col} with identical SI data and display unit
* @throws IllegalStateException if shape is not 2 x 1
*/
public Vector2.Col<Q, U> asVector2Col()
{
Throw.when(rows() != 2 || cols() != 1, IllegalStateException.class, "Matrix is not 2x1");
final double[] data = si();
return new Vector2.Col<Q, U>(data[0], data[1], getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 3-element column vector. Shape must be 3 x 1.
* @return a {@code Vector3.Col} with identical SI data and display unit
* @throws IllegalStateException if shape is not 3 x 1
*/
public Vector3.Col<Q, U> asVector3Col()
{
Throw.when(rows() != 3 || cols() != 1, IllegalStateException.class, "Matrix is not 3x1");
final double[] data = si();
return new Vector3.Col<Q, U>(data[0], data[1], data[2], getDisplayUnit().getBaseUnit())
.setDisplayUnit(getDisplayUnit());
} | |
| File | Line |
|---|---|
| org/djunits/quantity/def/AbsoluteQuantity.java | 483 |
| org/djunits/quantity/def/Quantity.java | 448 |
public String format(final double d, final String format)
{
String s = String.format(format, d);
if (s.contains("e") || s.contains("E"))
{
return s;
}
while (s.endsWith("0") && s.length() > 2)
{
s = s.substring(0, s.length() - 1);
}
String last = s.substring(s.length() - 1);
if (!"01234567890".contains(last))
{
s += "0";
}
return s;
}
/**
* Concise description of this value.
* @return a String with the value, non-verbose, with the unit attached.
*/
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
/**
* Somewhat verbose description of this value with the values expressed in the specified unit.
* @param displayUnit the unit into which the values are converted for display
* @return printable string with the value contents expressed in the specified unit
*/
@Override
@SuppressWarnings("checkstyle:hiddenfield")
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
/**
* Somewhat verbose description of this value with optional type and unit information.
* @param verbose if true; include type info; if false; exclude type info
* @param withUnit if true; include the unit; of false; exclude the unit
* @return printable string with the value contents
*/
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
/**
* Somewhat verbose description of this value with the values expressed in the specified unit.
* @param displayUnit the unit into which the values are converted for display
* @param verbose if true; include type info; if false; exclude type info
* @param withUnit if true; include the unit; of false; exclude the unit
* @return printable string with the value contents
*/
@SuppressWarnings("checkstyle:hiddenfield")
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
buf.append("Abs "); | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 202 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 241 |
this.sparseData[index] = value.si();
this.indexes[index++] = value.getRow() * this.cols + value.getColumn();
}
}
/**
* Check the correctness of the indexes array.
* @param indexArray the indexes with the data coordinates, where index = row * cols() + col (0-based)
* @throws IllegalArgumentException when indexes is not in strictly increasing order
* @throws IndexOutOfBoundsException when one of the entries in indexes is out of bounds
*/
protected void checkIndexes(final int[] indexArray)
{
for (int i = 0; i < indexArray.length; i++)
{
if (indexArray[i] < 0 || indexArray[i] >= this.rows * this.cols)
{
throw new IndexOutOfBoundsException(
String.format("indexes[%d] out of bounds, %d rows x %d cols; value should be 0..%d", i, this.rows,
this.cols, this.rows * this.cols - 1));
}
}
for (int i = 1; i < indexArray.length; i++)
{
if (indexArray[i] <= indexArray[i - 1])
{
throw new IllegalArgumentException(
"indexes[] must be strictly increasing, found " + indexArray[i - 1] + " then " + indexArray[i]);
}
}
}
/**
* Store sparse data[] and indexes[].
* @param denseData the dense data in row-major format
*/
@SuppressWarnings("checkstyle:needbraces")
public void storeSparse(final double[] denseData)
{
int nonzero = 0;
for (int i = 0; i < denseData.length; i++)
if (denseData[i] != 0.0)
nonzero++;
this.sparseData = new double[nonzero]; | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 356 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 443 |
}
/**
* Check whether the row and column are within bounds.
* @param row the row number
* @param col the column number
* @throws IndexOutOfBoundsException when row > rows() or col > cols() or row < 0 or col < 0
*/
private void checkRowCol(final int row, final int col) throws IndexOutOfBoundsException
{
Throw.when(row < 0 || row >= this.rows, IndexOutOfBoundsException.class, "row %d not in range 0..%d", row,
this.rows - 1);
Throw.when(col < 0 || col >= this.cols, IndexOutOfBoundsException.class, "column %d not in range 0..%d", col,
this.cols - 1);
}
@Override
public double get(final int row, final int col)
{
checkRowCol(row, col);
int index = row * this.cols + col; // zero-based
final int pos = Arrays.binarySearch(this.indexes, index);
return (pos >= 0) ? this.sparseData[pos] : 0.0;
}
@SuppressWarnings("checkstyle:needbraces")
@Override
public double[] getDataArray()
{
double[] denseData = new double[rows() * cols()];
for (int i = 0; i < this.sparseData.length; i++)
denseData[this.indexes[i]] = this.sparseData[i];
return denseData;
}
@Override
public SparseDoubleDataSi copy() | |
| File | Line |
|---|---|
| org/djunits/quantity/Energy.java | 132 |
| org/djunits/quantity/Torque.java | 132 |
public final Dimensionless divide(final Energy v)
{
return new Dimensionless(this.si() / v.si(), Unitless.BASE);
}
/**
* Calculate the division of Energy and Force, which results in a Length scalar.
* @param v scalar
* @return scalar as a division of Energy and Force
*/
public final Length divide(final Force v)
{
return new Length(this.si() / v.si(), Length.Unit.SI);
}
/**
* Calculate the division of Energy and Length, which results in a Force scalar.
* @param v scalar
* @return scalar as a division of Energy and Length
*/
public final Force divide(final Length v)
{
return new Force(this.si() / v.si(), Force.Unit.SI);
}
/**
* Calculate the multiplication of Energy and LinearDensity, which results in a Force scalar.
* @param v scalar
* @return scalar as a multiplication of Energy and LinearDensity
*/
public final Force multiply(final LinearObjectDensity v)
{
return new Force(this.si() * v.si(), Force.Unit.SI);
}
/**
* Calculate the division of Energy and Duration, which results in a Power scalar.
* @param v scalar
* @return scalar as a division of Energy and Duration
*/
public final Power divide(final Duration v)
{
return new Power(this.si() / v.si(), Power.Unit.SI);
}
/**
* Calculate the division of Energy and Power, which results in a Duration scalar.
* @param v scalar
* @return scalar as a division of Energy and Power
*/
public final Duration divide(final Power v)
{
return new Duration(this.si() / v.si(), Duration.Unit.SI);
}
/**
* Calculate the division of Energy and Volume, which results in a Pressure scalar.
* @param v scalar
* @return scalar as a division of Energy and Volume
*/
public final Pressure divide(final Volume v) | |
| File | Line |
|---|---|
| org/djunits/vecmat/dn/VectorN.java | 739 |
| org/djunits/vecmat/dnxm/MatrixNxM.java | 489 |
| org/djunits/vecmat/table/QuantityTable.java | 354 |
return new Vector1<Q, U>(data[0], getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 2-element row vector. Shape must be 1 x 2.
* @return a {@code Vector2.Row} with identical SI data and display unit
* @throws IllegalStateException if shape is not 1 x 2
*/
public Vector2.Row<Q, U> asVector2Row()
{
Throw.when(rows() != 1 || cols() != 2, IllegalStateException.class, "Matrix is not 1x2");
final double[] data = si();
return new Vector2.Row<Q, U>(data[0], data[1], getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
/**
* Return this matrix as a 3-element row vector. Shape must be 1 x 3.
* @return a {@code Vector3.Row} with identical SI data and display unit
* @throws IllegalStateException if shape is not 1 x 3
*/
public Vector3.Row<Q, U> asVector3Row()
{
Throw.when(rows() != 1 || cols() != 3, IllegalStateException.class, "Matrix is not 1x3");
final double[] data = si();
return new Vector3.Row<Q, U>(data[0], data[1], data[2], getDisplayUnit().getBaseUnit())
.setDisplayUnit(getDisplayUnit());
} | |
| File | Line |
|---|---|
| org/djunits/quantity/def/AbsoluteQuantity.java | 105 |
| org/djunits/quantity/def/Quantity.java | 92 |
}
/**
* Return the "pretty" and localized name of the quantity.
* @return the "pretty" and localized name of the quantity
*/
public String getName()
{
String name = Units.localizedQuantityName(Locale.getDefault(), getClass().getSimpleName());
final StringBuilder sb = new StringBuilder(name.length() + 8);
sb.append(name.charAt(0)); // keep first character exactly as-is
for (int i = 1; i < name.length(); i++)
{
final char c = name.charAt(i);
if (Character.isUpperCase(c))
{
if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ' ')
{
sb.append(' ');
}
sb.append(Character.toLowerCase(c));
}
else
{
sb.append(c);
}
}
return sb.toString();
}
/**********************************************************************************/
/******************************** SI-RELATED METHODS ******************************/
/**********************************************************************************/
/**
* Return the SI unit of this quantity.
* @return the SI unit of this quantity
*/
public SIUnit siUnit()
{
return getDisplayUnit().siUnit();
}
/**
* Return the SI value of the quantity.
* @return the SI value of the quantity
*/
public double si()
{
return this.quantity.si(); | |
| File | Line |
|---|---|
| org/djunits/vecmat/dnxm/MatrixNxM.java | 97 |
| org/djunits/vecmat/table/QuantityTable.java | 96 |
public static <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> MatrixNxM<Q, U> of(final double[][] valueGridInUnit,
final U displayUnit)
{
Throw.whenNull(valueGridInUnit, "valueGridInUnit");
Throw.whenNull(displayUnit, "displayUnit");
int rows = valueGridInUnit.length;
Throw.when(rows == 0, IllegalArgumentException.class, "valueGridInUnit has 0 rows");
int cols = valueGridInUnit[0].length;
Throw.when(cols == 0, IllegalArgumentException.class, "row 0 in valueGridInUnit has 0 columns");
double[] aSi = new double[rows * cols];
for (int r = 0; r < rows; r++)
{
Throw.when(valueGridInUnit[r].length != cols, IllegalArgumentException.class,
"valueGridInUnit is not a NxM array; row %d has a length of %d, not %d", r, valueGridInUnit[r].length,
cols);
for (int c = 0; c < cols; c++)
aSi[cols * r + c] = displayUnit.toBaseValue(valueGridInUnit[r][c]);
}
return new MatrixNxM<Q, U>(new DenseDoubleDataSi(aSi, rows, cols), displayUnit); | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 420 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 507 |
return new SparseDoubleDataSi(denseData, newRows, newCols);
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(getDataArray());
result = prime * result + Objects.hash(this.cols, this.rows);
return result;
}
@SuppressWarnings("checkstyle:needbraces")
@Override
public boolean equals(final Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
{
if (obj instanceof DataGridSi dg)
return this.cols == dg.cols() && this.rows == dg.rows() && Arrays.equals(getDataArray(), dg.getDataArray());
return false;
} | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/DenseFloatDataSi.java | 212 |
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 420 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 507 |
return new DenseFloatDataSi(floatData, newRows, newCols);
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(getDataArray());
result = prime * result + Objects.hash(this.cols, this.rows);
return result;
}
@SuppressWarnings("checkstyle:needbraces")
@Override
public boolean equals(final Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
{
if (obj instanceof DataGridSi dg)
return this.cols == dg.cols() && this.rows == dg.rows() && Arrays.equals(getDataArray(), dg.getDataArray());
return false;
} | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/DenseDoubleDataSi.java | 55 |
| org/djunits/vecmat/storage/DenseDoubleDataSi.java | 80 |
public DenseDoubleDataSi(final double[][] data)
{
Throw.whenNull(data, "data");
Throw.when(data.length == 0, IllegalArgumentException.class, "Number of rows in the data matrix = 0");
this.rows = data.length;
this.cols = data[0].length;
this.data = new double[this.rows * this.cols];
for (int r = 0; r < this.rows; r++)
{
Throw.when(data[r].length != this.cols, IllegalArgumentException.class,
"Number of columns in row %d (%d) is not equal to number of columns in row 0 (%d)", r, data[r].length,
this.cols);
for (int c = 0; c < this.cols; c++)
this.data[r * this.cols + c] = data[r][c]; | |
| File | Line |
|---|---|
| org/djunits/vecmat/d2/Vector2.java | 579 |
| org/djunits/vecmat/d3/Vector3.java | 637 |
return instantiateSi(xSi(), ySi()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> getColumnVector(final int col)
{
checkCol(col);
return new Vector1<Q, U>(si(0, col), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> mgetColumnVector(final int mCol)
{
mcheckCol(mCol);
return new Vector1<Q, U>(msi(1, mCol), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public double[] getRowSi(final int row)
{
checkRow(row);
return new double[] {xSi(), ySi()}; | |
| File | Line |
|---|---|
| org/djunits/vecmat/dnxm/MatrixNxM.java | 70 |
| org/djunits/vecmat/table/QuantityTable.java | 68 |
public static <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> MatrixNxM<Q, U> of(final double[] valueArrayInUnit,
final int rows, final int cols, final U displayUnit)
{
Throw.whenNull(valueArrayInUnit, "valueArrayInUnit");
Throw.whenNull(displayUnit, "displayUnit");
Throw.when(rows <= 0, IllegalArgumentException.class, "rows <= 0");
Throw.when(cols <= 0, IllegalArgumentException.class, "cols <= 0");
Throw.when(rows * cols != valueArrayInUnit.length, IllegalArgumentException.class,
"valueArrayInUnit does not contain the correct number of entries (%d x %d != %d)", rows, cols,
valueArrayInUnit.length);
double[] aSi = new double[rows * cols];
for (int i = 0; i < valueArrayInUnit.length; i++)
aSi[i] = displayUnit.toBaseValue(valueArrayInUnit[i]);
return new MatrixNxM<Q, U>(new DenseDoubleDataSi(aSi, rows, cols), displayUnit); | |
| File | Line |
|---|---|
| org/djunits/vecmat/def/Matrix.java | 73 |
| org/djunits/vecmat/dnxm/MatrixNxM.java | 299 |
public MatrixNxM<SIQuantity, SIUnit> multiply(final MatrixNxM<?, ?> matrix)
{
checkMultiply(matrix);
double[] result = MatrixMath.multiply(si(), matrix.si(), rows(), cols(), matrix.cols());
SIUnit siUnit = getDisplayUnit().siUnit().plus(matrix.getDisplayUnit().siUnit());
if (matrix.getDataGrid().isDouble())
{
return new MatrixNxM<SIQuantity, SIUnit>(new DenseDoubleDataSi(result, rows(), matrix.cols()), siUnit);
}
return new MatrixNxM<SIQuantity, SIUnit>(new DenseFloatDataSi(result, rows(), matrix.cols()), siUnit);
} | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 87 |
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 162 |
public SparseDoubleDataSi(final double[][] denseData)
{
Throw.whenNull(denseData, "denseData");
Throw.when(denseData.length == 0, IllegalArgumentException.class, "Number of rows in the data matrix = 0");
this.rows = denseData.length;
this.cols = denseData[0].length;
for (int r = 1; r < this.rows; r++)
Throw.when(denseData[r].length != this.cols, IllegalArgumentException.class,
"Number of columns in row %d (%d) is not equal to number of columns in row 0 (%d)", r, denseData[r].length,
this.cols);
storeSparse(denseData);
}
/**
* Instantiate a data object with one array in row-major format. Note that a safe copy of the data is stored.
* @param sparseData the sparse data in row-major format
* @param indexes the indexes with the data coordinates, where index = row * cols() + col (0-based)
* @param rows the number of rows
* @param cols the number of columns
* @throws IllegalArgumentException when the size of the data object is not equal to rows*cols, or when the number of rows
* or columns is not positive, or when indexes is not in strictly increasing order
* @throws IndexOutOfBoundsException when one of the entries in indexes is out of bounds
* @param <Q> the quantity type
* @param <U> the unit type
*/
@SuppressWarnings("checkstyle:needbraces")
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[] sparseData, | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 162 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 201 |
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[][] denseData)
{
Throw.whenNull(denseData, "denseData");
Throw.when(denseData.length == 0, IllegalArgumentException.class, "Number of rows in the data matrix = 0");
this.rows = denseData.length;
this.cols = denseData[0].length;
for (int r = 1; r < this.rows; r++)
Throw.when(denseData[r].length != this.cols, IllegalArgumentException.class,
"Number of columns in row %d (%d) is not equal to number of columns in row 0 (%d)", r, denseData[r].length,
this.cols);
storeSparse(denseData);
}
/**
* Instantiate a data object with an indexed collection of values. Note that a safe copy of the data is stored.
* @param indexedData the sparse data in an indexed format
* @param rows the number of rows
* @param cols the number of columns
* @throws IndexOutOfBoundsException when a row or column index of an element is out of bounds
* @param <Q> the quantity type
* @param <U> the unit type
*/
@SuppressWarnings("checkstyle:needbraces")
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi( | |
| File | Line |
|---|---|
| org/djunits/vecmat/d2/Vector2.java | 579 |
| org/djunits/vecmat/dn/VectorN.java | 631 |
return instantiateSi(xSi(), ySi()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> getColumnVector(final int col)
{
checkCol(col);
return new Vector1<Q, U>(si(0, col), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> mgetColumnVector(final int mCol)
{
mcheckCol(mCol);
return new Vector1<Q, U>(msi(1, mCol), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public double[] getRowSi(final int row)
{
checkRow(row);
return new double[] {xSi(), ySi()}; | |
| File | Line |
|---|---|
| org/djunits/vecmat/d3/Vector3.java | 637 |
| org/djunits/vecmat/dn/VectorN.java | 631 |
return instantiateSi(xSi(), ySi(), zSi()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> getColumnVector(final int col)
{
checkCol(col);
return new Vector1<Q, U>(si(0, col), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> mgetColumnVector(final int mCol)
{
mcheckCol(mCol);
return new Vector1<Q, U>(msi(1, mCol), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public double[] getRowSi(final int row)
{
checkRow(row);
return new double[] {xSi(), ySi(), zSi()}; | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 87 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 126 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 201 |
public SparseDoubleDataSi(final double[][] denseData)
{
Throw.whenNull(denseData, "denseData");
Throw.when(denseData.length == 0, IllegalArgumentException.class, "Number of rows in the data matrix = 0");
this.rows = denseData.length;
this.cols = denseData[0].length;
for (int r = 1; r < this.rows; r++)
Throw.when(denseData[r].length != this.cols, IllegalArgumentException.class,
"Number of columns in row %d (%d) is not equal to number of columns in row 0 (%d)", r, denseData[r].length,
this.cols);
storeSparse(denseData);
}
/**
* Instantiate a data object with one array in row-major format. Note that a safe copy of the data is stored.
* @param sparseData the sparse data in row-major format
* @param indexes the indexes with the data coordinates, where index = row * cols() + col (0-based)
* @param rows the number of rows
* @param cols the number of columns
* @throws IllegalArgumentException when the size of the data object is not equal to rows*cols, or when the number of rows
* or columns is not positive, or when indexes is not in strictly increasing order
* @throws IndexOutOfBoundsException when one of the entries in indexes is out of bounds
* @param <Q> the quantity type
* @param <U> the unit type
*/
@SuppressWarnings("checkstyle:needbraces")
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[] sparseData, | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 141 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 180 |
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[] denseData, final int rows,
final int cols)
{
Throw.whenNull(denseData, "denseData");
Throw.when(rows <= 0, IllegalArgumentException.class, "Number of rows <= 0");
Throw.when(cols <= 0, IllegalArgumentException.class, "Number of columns <= 0");
Throw.when(denseData.length != rows * cols, IllegalArgumentException.class,
"denseData.length (%d) != rows x cols (%d x %d)", denseData.length, rows, cols);
this.rows = rows;
this.cols = cols;
storeSparse(denseData);
}
/**
* Instantiate a data object with a dense double[rows][cols]. A sparse, safe copy of the data is stored.
* @param denseData the data in row-major format as a double[][]
* @throws IllegalArgumentException when the data matrix is ragged
* @param <Q> the quantity type
* @param <U> the unit type
*/
@SuppressWarnings("checkstyle:needbraces")
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[][] denseData) | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 46 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 46 |
protected SparseDoubleDataSi(final double[] sparseData, final int[] indexes, final int rows, final int cols)
{
Throw.whenNull(sparseData, "sparseData");
Throw.whenNull(indexes, "indexes");
Throw.when(rows <= 0, IllegalArgumentException.class, "Number of rows <= 0");
Throw.when(cols <= 0, IllegalArgumentException.class, "Number of columns <= 0");
Throw.when(sparseData.length != indexes.length, IllegalArgumentException.class,
"sparseData array (%d) has different length from indexes array (%d)", sparseData.length, indexes.length);
this.rows = rows;
this.cols = cols;
checkIndexes(indexes);
this.sparseData = sparseData;
this.indexes = indexes;
}
/**
* Instantiate a data object with one array in row-major format. Note that NO safe copy of the data is stored.
* @param denseData the dense data in row-major format
* @param rows the number of rows
* @param cols the number of columns
* @throws IllegalArgumentException when the size of the data object is not equal to rows*cols, or when the number of rows
* or columns is not positive
*/
public SparseDoubleDataSi(final double[] denseData, final int rows, final int cols) | |
| File | Line |
|---|---|
| org/djunits/vecmat/dnxm/MatrixNxM.java | 335 |
| org/djunits/vecmat/dnxm/MatrixNxM.java | 351 |
public VectorN.Col<SIQuantity, SIUnit> multiply(final Vector2.Col<?, ?> vector)
{
checkMultiply(vector);
double[] result = MatrixMath.multiply(si(), vector.si(), rows(), cols(), vector.cols());
SIUnit siUnit = getDisplayUnit().siUnit().plus(vector.getDisplayUnit().siUnit());
return new VectorN.Col<SIQuantity, SIUnit>(new DenseDoubleDataSi(result, rows(), vector.cols()), siUnit);
}
/**
* Multiply this vector or matrix with a Vector3.Col, resulting in a Vector3.Col. The multiplication is a (Mx3) x (3x1)
* matrix multiplication resulting in an (Mx1) column vector.
* @param vector the vector to multiply with
* @return a VectorN.Col of an SIQuantity as the result of the matrix multiplication
* @throws IllegalArgumentException when the number of columns of this matrix does not equal the number of rows of the
* vector to multiply with
*/
public VectorN.Col<SIQuantity, SIUnit> multiply(final Vector3.Col<?, ?> vector) | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 113 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 152 |
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[] sparseData,
final int[] indexes, final int rows, final int cols)
{
Throw.whenNull(sparseData, "sparseData");
Throw.whenNull(indexes, "indexes");
Throw.when(rows <= 0, IllegalArgumentException.class, "Number of rows <= 0");
Throw.when(cols <= 0, IllegalArgumentException.class, "Number of columns <= 0");
Throw.when(sparseData.length != indexes.length, IllegalArgumentException.class,
"sparseData array (%d) has different length from indexes array (%d)", sparseData.length, indexes.length);
this.rows = rows;
this.cols = cols;
checkIndexes(indexes);
this.sparseData = new double[sparseData.length]; | |
| File | Line |
|---|---|
| org/djunits/vecmat/d2/Vector2.java | 394 |
| org/djunits/vecmat/d3/Vector3.java | 428 |
return row == 0 ? xSi() : ySi();
}
@Override
public Vector1<Q, U> getRowVector(final int row)
{
checkRow(row);
return new Vector1<Q, U>(si(row, 0), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> mgetRowVector(final int mRow)
{
mcheckRow(mRow);
return new Vector1<Q, U>(msi(mRow, 1), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector2.Col<Q, U> getColumnVector(final int col) | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 87 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 107 |
public SparseDoubleDataSi(final double[][] denseData)
{
Throw.whenNull(denseData, "denseData");
Throw.when(denseData.length == 0, IllegalArgumentException.class, "Number of rows in the data matrix = 0");
this.rows = denseData.length;
this.cols = denseData[0].length;
for (int r = 1; r < this.rows; r++)
Throw.when(denseData[r].length != this.cols, IllegalArgumentException.class,
"Number of columns in row %d (%d) is not equal to number of columns in row 0 (%d)", r, denseData[r].length,
this.cols);
storeSparse(denseData);
}
/**
* Instantiate a data object with one array in row-major format. Note that a safe copy of the data is stored.
* @param sparseData the sparse data in row-major format
* @param indexes the indexes with the data coordinates, where index = row * cols() + col (0-based)
* @param rows the number of rows
* @param cols the number of columns
* @throws IllegalArgumentException when the size of the data object is not equal to rows*cols, or when the number of rows
* or columns is not positive, or when indexes is not in strictly increasing order
* @throws IndexOutOfBoundsException when one of the entries in indexes is out of bounds
* @param <Q> the quantity type
* @param <U> the unit type
*/
@SuppressWarnings("checkstyle:needbraces")
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[] sparseData, | |
| File | Line |
|---|---|
| org/djunits/vecmat/d2/Vector2.java | 394 |
| org/djunits/vecmat/dn/VectorN.java | 325 |
return row == 0 ? xSi() : ySi();
}
@Override
public Vector1<Q, U> getRowVector(final int row)
{
checkRow(row);
return new Vector1<Q, U>(si(row, 0), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> mgetRowVector(final int mRow)
{
mcheckRow(mRow);
return new Vector1<Q, U>(msi(mRow, 1), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector2.Col<Q, U> getColumnVector(final int col) | |
| File | Line |
|---|---|
| org/djunits/vecmat/d3/Vector3.java | 428 |
| org/djunits/vecmat/dn/VectorN.java | 325 |
return row == 0 ? xSi() : row == 1 ? ySi() : zSi();
}
@Override
public Vector1<Q, U> getRowVector(final int row)
{
checkRow(row);
return new Vector1<Q, U>(si(row, 0), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector1<Q, U> mgetRowVector(final int mRow)
{
mcheckRow(mRow);
return new Vector1<Q, U>(msi(mRow, 1), getDisplayUnit().getBaseUnit()).setDisplayUnit(getDisplayUnit());
}
@Override
public Vector3.Col<Q, U> getColumnVector(final int col) | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 46 |
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 113 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 46 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 152 |
protected SparseDoubleDataSi(final double[] sparseData, final int[] indexes, final int rows, final int cols)
{
Throw.whenNull(sparseData, "sparseData");
Throw.whenNull(indexes, "indexes");
Throw.when(rows <= 0, IllegalArgumentException.class, "Number of rows <= 0");
Throw.when(cols <= 0, IllegalArgumentException.class, "Number of columns <= 0");
Throw.when(sparseData.length != indexes.length, IllegalArgumentException.class,
"sparseData array (%d) has different length from indexes array (%d)", sparseData.length, indexes.length);
this.rows = rows;
this.cols = cols;
checkIndexes(indexes);
this.sparseData = sparseData; | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 162 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 107 |
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi(final Q[][] denseData)
{
Throw.whenNull(denseData, "denseData");
Throw.when(denseData.length == 0, IllegalArgumentException.class, "Number of rows in the data matrix = 0");
this.rows = denseData.length;
this.cols = denseData[0].length;
for (int r = 1; r < this.rows; r++)
Throw.when(denseData[r].length != this.cols, IllegalArgumentException.class,
"Number of columns in row %d (%d) is not equal to number of columns in row 0 (%d)", r, denseData[r].length,
this.cols);
storeSparse(denseData);
}
/**
* Instantiate a data object with an indexed collection of values. Note that a safe copy of the data is stored.
* @param indexedData the sparse data in an indexed format
* @param rows the number of rows
* @param cols the number of columns
* @throws IndexOutOfBoundsException when a row or column index of an element is out of bounds
* @param <Q> the quantity type
* @param <U> the unit type
*/
@SuppressWarnings("checkstyle:needbraces")
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> SparseDoubleDataSi( | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseDoubleDataSi.java | 301 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 388 |
this.sparseData[index] = denseData[i].si();
this.indexes[index] = i;
index++;
}
}
/**
* Store sparse data[] and indexes[].
* @param denseData the dense data in row-major format
* @param <Q> the quantity type
* @param <U> the unit type
*/
@SuppressWarnings("checkstyle:needbraces")
public <Q extends Quantity<Q, U>, U extends UnitInterface<U, Q>> void storeSparse(final Q[][] denseData)
{
int nonzero = 0;
for (int i = 0; i < denseData.length; i++)
for (int j = 0; j < denseData[i].length; j++)
if (denseData[i][j].ne0())
nonzero++;
this.sparseData = new double[nonzero]; | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 107 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 126 |
| org/djunits/vecmat/storage/SparseFloatDataSi.java | 201 |
public SparseFloatDataSi(final double[][] denseData)
{
Throw.whenNull(denseData, "denseData");
Throw.when(denseData.length == 0, IllegalArgumentException.class, "Number of rows in the data matrix = 0");
this.rows = denseData.length;
this.cols = denseData[0].length;
for (int r = 1; r < this.rows; r++)
Throw.when(denseData[r].length != this.cols, IllegalArgumentException.class,
"Number of columns in row %d (%d) is not equal to number of columns in row 0 (%d)", r, denseData[r].length,
this.cols);
storeSparse(denseData);
}
/**
* Instantiate a data object with a dense double[rows][cols]. A sparse, safe copy of the data is stored.
* @param denseData the data in row-major format as a float[][]
* @throws IllegalArgumentException when the matrix is ragged
*/
@SuppressWarnings("checkstyle:needbraces")
public SparseFloatDataSi(final float[][] denseData) | |
| File | Line |
|---|---|
| org/djunits/quantity/Angle.java | 263 |
| org/djunits/quantity/AngularAcceleration.java | 214 |
| org/djunits/quantity/AngularVelocity.java | 184 |
grad.deriveUnit("cds", "c\"", "centesimal arcsecond", 1.0 / 10000.0, UnitSystem.OTHER);
/**
* Create a new Angle unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
/** {@inheritDoc} */
@Override
public Angle ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/vecmat/dnxm/MatrixNxM.java | 251 |
| org/djunits/vecmat/dnxm/MatrixNxM.java | 267 |
| org/djunits/vecmat/dnxm/MatrixNxM.java | 283 |
public MatrixNxM<SIQuantity, SIUnit> multiply(final Matrix1x1<?, ?> matrix)
{
checkMultiply(matrix);
double[] result = MatrixMath.multiply(si(), matrix.si(), rows(), cols(), matrix.cols());
SIUnit siUnit = getDisplayUnit().siUnit().plus(matrix.getDisplayUnit().siUnit());
return new MatrixNxM<SIQuantity, SIUnit>(new DenseDoubleDataSi(result, rows(), matrix.cols()), siUnit);
}
/**
* Multiply this vector or matrix with a Matrix2x2, resulting in a MatrixNxM. The multiplication is a (Mx2) x (2x2) matrix
* multiplication resulting in an (Mx2) matrix.
* @param matrix the matrix to multiply with
* @return a MatrixNxM of an SIQuantity as the result of the matrix multiplication
* @throws IllegalArgumentException when the number of columns of this matrix does not equal the number of rows of the
* matrix or vector to multiply with
*/
public MatrixNxM<SIQuantity, SIUnit> multiply(final Matrix2x2<?, ?> matrix) | |
| File | Line |
|---|---|
| org/djunits/vecmat/storage/DenseDoubleDataSi.java | 119 |
| org/djunits/vecmat/storage/DenseFloatDataSi.java | 143 |
}
/**
* Check whether the row and column are within bounds.
* @param row the row number
* @param col the column number
* @throws IndexOutOfBoundsException when row > rows() or col > cols() or row < 0 or col < 0
*/
private void checkRowCol(final int row, final int col) throws IndexOutOfBoundsException
{
Throw.when(row < 0 || row >= this.rows, IndexOutOfBoundsException.class, "row %d not in range 0..%d", row, this.rows);
Throw.when(col < 0 || col >= this.cols, IndexOutOfBoundsException.class, "column %d not in range 0..%d", col,
this.cols);
}
@Override
public double get(final int row, final int col)
{
checkRowCol(row, col);
return this.data[row * this.cols + col];
}
@Override | |
| File | Line |
|---|---|
| org/djunits/quantity/Acceleration.java | 248 |
| org/djunits/quantity/EquivalentDose.java | 168 |
public static final Acceleration.Unit Gal = new Acceleration.Unit("Gal", "gal", 0.01, UnitSystem.CGS);
/**
* Create a new Acceleration unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public Acceleration ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/ElectricalInductance.java | 160 |
| org/djunits/quantity/LuminousIntensity.java | 169 |
public static final ElectricalInductance.Unit SI = H.generateSiPrefixes(false, false);
/**
* Create a new ElectricalInductance unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public ElectricalInductance ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/Energy.java | 348 |
| org/djunits/quantity/Power.java | 291 |
public static final Energy.Unit erg = J.deriveUnit("erg", "erg", 1.0E-7, UnitSystem.CGS);
/**
* Create a new Energy unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public Energy ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/Force.java | 261 |
| org/djunits/quantity/Pressure.java | 236 |
public static final Force.Unit sn = SI.deriveUnit("sn", "sthene", 1000.0, UnitSystem.MTS);
/**
* Create a new Force unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public Force ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/Length.java | 366 |
| org/djunits/quantity/Volume.java | 330 |
new Length.Unit("A", "\u00C5", "Angstrom", new LinearScale(1.0E-10), UnitSystem.OTHER);
/**
* Create a new length unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public Length ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/AbsorbedDose.java | 174 |
| org/djunits/quantity/Acceleration.java | 248 |
| org/djunits/quantity/Energy.java | 348 |
| org/djunits/quantity/EquivalentDose.java | 168 |
| org/djunits/quantity/MagneticFlux.java | 231 |
| org/djunits/quantity/MagneticFluxDensity.java | 181 |
| org/djunits/quantity/Power.java | 291 |
public static final AbsorbedDose.Unit rad = new AbsorbedDose.Unit("rad", "rad", 1.0E-2, UnitSystem.CGS);
/**
* Create a new AbsorbedDose unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public AbsorbedDose ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/Angle.java | 263 |
| org/djunits/quantity/Duration.java | 313 |
| org/djunits/quantity/Frequency.java | 240 |
| org/djunits/quantity/Illuminance.java | 184 |
| org/djunits/quantity/Length.java | 366 |
| org/djunits/quantity/Mass.java | 289 |
| org/djunits/quantity/RadioActivity.java | 186 |
| org/djunits/quantity/Speed.java | 332 |
| org/djunits/quantity/Volume.java | 330 |
grad.deriveUnit("cds", "c\"", "centesimal arcsecond", 1.0 / 10000.0, UnitSystem.OTHER);
/**
* Create a new Angle unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
/** {@inheritDoc} */
@Override
public Angle ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/AngularAcceleration.java | 214 |
| org/djunits/quantity/Duration.java | 313 |
| org/djunits/quantity/Frequency.java | 240 |
| org/djunits/quantity/Illuminance.java | 184 |
| org/djunits/quantity/Length.java | 366 |
| org/djunits/quantity/Mass.java | 289 |
| org/djunits/quantity/RadioActivity.java | 186 |
| org/djunits/quantity/Speed.java | 332 |
| org/djunits/quantity/Volume.java | 330 |
"centesimal arcsecond per second squared", 1.0 / 10000.0, UnitSystem.OTHER);
/**
* Create a new AngularAcceleration unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
/** {@inheritDoc} */
@Override
public AngularAcceleration ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/AngularVelocity.java | 184 |
| org/djunits/quantity/Duration.java | 313 |
| org/djunits/quantity/Frequency.java | 240 |
| org/djunits/quantity/Illuminance.java | 184 |
| org/djunits/quantity/Length.java | 366 |
| org/djunits/quantity/Mass.java | 289 |
| org/djunits/quantity/RadioActivity.java | 186 |
| org/djunits/quantity/Speed.java | 332 |
| org/djunits/quantity/Volume.java | 330 |
grad_s.deriveUnit("cds/s", "c\"/s", "centesimal arcsecond per second", 1.0 / 10000.0, UnitSystem.OTHER);
/**
* Create a new AngularVelocity unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
/** {@inheritDoc} */
@Override
public AngularVelocity ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/Area.java | 322 |
| org/djunits/quantity/FlowMass.java | 233 |
| org/djunits/quantity/LinearObjectDensity.java | 240 |
| org/djunits/quantity/Torque.java | 251 |
new Area.Unit("ac", "acre", Length.Unit.CONST_MI * Length.Unit.CONST_MI / 640.0, UnitSystem.IMPERIAL);
/**
* Create a new Area unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public Area ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/Density.java | 184 |
| org/djunits/quantity/SolidAngle.java | 173 |
kg_m3.deriveUnit("g/cm3", "gram per cubic centimeter", 1.0E3, UnitSystem.SI_DERIVED);
/**
* Create a new Density unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public Density ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/quantity/ElectricCharge.java | 244 |
| org/djunits/quantity/ElectricCurrent.java | 228 |
| org/djunits/quantity/ElectricPotential.java | 211 |
| org/djunits/quantity/ElectricalResistance.java | 221 |
public static final ElectricCharge.Unit emu = abC.deriveUnit("emu", "electromagnetic unit", 1.0, UnitSystem.CGS_EMU);
/**
* Create a new ElectricCharge unit.
* @param id the id or main abbreviation of the unit
* @param name the full name of the unit
* @param scaleFactorToBaseUnit the scale factor of the unit to convert it TO the base (SI) unit
* @param unitSystem the unit system such as SI or IMPERIAL
*/
public Unit(final String id, final String name, final double scaleFactorToBaseUnit, final UnitSystem unitSystem)
{
super(id, name, new LinearScale(scaleFactorToBaseUnit), unitSystem);
}
/**
* Return a derived unit for this unit, with textual abbreviation(s) and a display abbreviation.
* @param textualAbbreviation the textual abbreviation of the unit, which doubles as the id
* @param displayAbbreviation the display abbreviation of the unit
* @param name the full name of the unit
* @param scale the scale to use to convert between this unit and the standard (e.g., SI, BASE) unit
* @param unitSystem unit system, e.g. SI or Imperial
*/
public Unit(final String textualAbbreviation, final String displayAbbreviation, final String name, final Scale scale,
final UnitSystem unitSystem)
{
super(textualAbbreviation, displayAbbreviation, name, scale, unitSystem);
}
@Override
public SIUnit siUnit()
{
return SI_UNIT;
}
@Override
public Unit getBaseUnit()
{
return SI;
}
@Override
public ElectricCharge ofSi(final double si) | |
| File | Line |
|---|---|
| org/djunits/vecmat/dnxm/MatrixNxM.java | 335 |
| org/djunits/vecmat/dnxm/MatrixNxM.java | 367 |
public VectorN.Col<SIQuantity, SIUnit> multiply(final Vector2.Col<?, ?> vector)
{
checkMultiply(vector);
double[] result = MatrixMath.multiply(si(), vector.si(), rows(), cols(), vector.cols());
SIUnit siUnit = getDisplayUnit().siUnit().plus(vector.getDisplayUnit().siUnit());
return new VectorN.Col<SIQuantity, SIUnit>(new DenseDoubleDataSi(result, rows(), vector.cols()), siUnit);
}
/**
* Multiply this vector or matrix with a Vector3.Col, resulting in a Vector3.Col. The multiplication is a (Mx3) x (3x1)
* matrix multiplication resulting in an (Mx1) column vector.
* @param vector the vector to multiply with
* @return a VectorN.Col of an SIQuantity as the result of the matrix multiplication
* @throws IllegalArgumentException when the number of columns of this matrix does not equal the number of rows of the
* vector to multiply with
*/
public VectorN.Col<SIQuantity, SIUnit> multiply(final Vector3.Col<?, ?> vector) | |
