CPD Results
The following document contains the results of PMD's CPD 7.7.0.
Duplications
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 337 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 337 |
DoubleVectorData.instantiate(getDiagonalSI(), getDisplayUnit().getStandardUnit().getScale(), getStorageType());
return instantiateVector(dvd, getDisplayUnit());
}
@SuppressWarnings("unchecked")
@Override
public S[] getRowScalars(final int row) throws IndexOutOfBoundsException
{
checkRowIndex(row);
S[] array = (S[]) Array.newInstance(getScalarClass(), cols());
for (int col = 0; col < cols(); col++)
{
array[col] = get(row, col);
}
return array;
}
@SuppressWarnings("unchecked")
@Override
public S[] getColumnScalars(final int col) throws IndexOutOfBoundsException
{
checkColumnIndex(col);
S[] array = (S[]) Array.newInstance(getScalarClass(), rows());
for (int row = 0; row < rows(); row++)
{
array[row] = get(row, col);
}
return array;
}
@SuppressWarnings("unchecked")
@Override
public S[] getDiagonalScalars() throws ValueRuntimeException
{
checkSquare();
S[] array = (S[]) Array.newInstance(getScalarClass(), rows());
for (int row = 0; row < rows(); row++)
{
array[row] = get(row, row);
}
return array;
}
@SuppressWarnings("unchecked")
@Override
public M toSparse()
{
M result;
if (getStorageType().equals(StorageType.SPARSE))
{
result = (M) this;
result.setDisplayUnit(getDisplayUnit());
}
else
{
result = instantiateMatrix(this.data.toSparse(), getDisplayUnit());
}
result.setDisplayUnit(getDisplayUnit());
return result;
}
@SuppressWarnings("unchecked")
@Override
public M toDense()
{
M result;
if (getStorageType().equals(StorageType.DENSE))
{
result = (M) this;
result.setDisplayUnit(getDisplayUnit());
}
else
{
result = instantiateMatrix(this.data.toDense(), getDisplayUnit());
}
return result;
}
/**
* Execute a function on a cell by cell basis. Note: May be expensive when used on sparse data.
* @param doubleFunction the function to apply
* @return this updated matrix
*/
@SuppressWarnings("unchecked")
public final M assign(final DoubleFunction doubleFunction) | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/scalar/base/DoubleScalar.java | 211 |
| org/djunits/value/vfloat/scalar/base/FloatScalar.java | 211 |
double d = ValueUtil.expressAsUnit(getSI(), displayUnit);
buf.append(Format.format(d));
if (withUnit)
{
buf.append(" "); // Insert one space as prescribed by SI writing conventions
buf.append(displayUnit.getLocalizedDisplayAbbreviation());
}
return buf.toString();
}
/**
* Format this DoubleScalar in SI unit using prefixes when possible. If the value is too small or too large, e-notation and
* the plain SI unit are used.
* @return formatted value of this DoubleScalar
*/
public String toStringSIPrefixed()
{
return toStringSIPrefixed(-30, 32);
}
/**
* Format this DoubleScalar in SI unit using prefixes when possible and within the specified size range. If the value is too
* small or too large, e-notation and the plain SI unit are used.
* @param smallestPower the smallest exponent value that will be written using an SI prefix
* @param biggestPower the largest exponent value that will be written using an SI prefix
* @return formatted value of this DoubleScalar
*/
public String toStringSIPrefixed(final int smallestPower, final int biggestPower)
{
// Override this method for weights, nonlinear units and DimensionLess.
if (!Double.isFinite(this.si))
{
return toString(getDisplayUnit().getStandardUnit());
}
// PK: I can't think of an easier way to figure out what the exponent will be; rounding of the mantissa to the available
// width makes this hard; This feels like an expensive way.
String check = String.format(this.si >= 0 ? "%10.8E" : "%10.7E", this.si);
int exponent = Integer.parseInt(check.substring(check.indexOf("E") + 1));
if (exponent < -30 || exponent < smallestPower || exponent > 30 + 2 || exponent > biggestPower)
{
// Out of SI prefix range; do not scale.
return String.format(this.si >= 0 ? "%10.4E" : "%10.3E", this.si) + " "
+ getDisplayUnit().getStandardUnit().getId();
}
Integer roundedExponent = (int) Math.ceil((exponent - 2.0) / 3) * 3;
// System.out.print(String.format("exponent=%d; roundedExponent=%d ", exponent, roundedExponent));
String key =
SIPrefixes.FACTORS.get(roundedExponent).getDefaultTextualPrefix() + getDisplayUnit().getStandardUnit().getId();
U displayUnit = getDisplayUnit().getQuantity().getUnitByAbbreviation(key);
return toString(displayUnit);
}
@Override
public String toTextualString()
{
return toTextualString(getDisplayUnit());
}
@Override
public String toTextualString(final U displayUnit)
{ | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 500 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 501 |
double d = ValueUtil.expressAsUnit(getSI(row, col), displayUnit);
buf.append(" " + Format.format(d));
}
catch (IndexOutOfBoundsException ve)
{
buf.append(" " + "********************".substring(0, Format.DEFAULTSIZE));
}
}
}
buf.append("\n");
if (withUnit)
{
buf.append(displayUnit.getLocalizedDisplayAbbreviation());
}
return buf.toString();
}
/**
* Check that provided row and column indices are valid.
* @param row the row value to check
* @param col the column value to check
* @throws IndexOutOfBoundsException when row or column is invalid
*/
protected final void checkIndex(final int row, final int col) throws IndexOutOfBoundsException
{
if (row < 0 || row >= rows() || col < 0 || col >= cols())
{
throw new IndexOutOfBoundsException("index out of range (valid range is 0.." + (rows() - 1) + ", 0.." + (cols() - 1)
+ ", got " + row + ", " + col + ")");
}
}
/**
* Check that provided row index is valid.
* @param row the row value to check
* @throws IndexOutOfBoundsException when row is invalid
*/
protected final void checkRowIndex(final int row) throws IndexOutOfBoundsException
{
if (row < 0 || row >= rows())
{
throw new IndexOutOfBoundsException(
"row index out of range (valid range is 0.." + (rows() - 1) + ", got " + row + ")");
}
}
/**
* Check that provided column index is valid.
* @param col the column value to check
* @throws IndexOutOfBoundsException when row is invalid
*/
protected final void checkColumnIndex(final int col) throws IndexOutOfBoundsException
{
if (col < 0 || col >= cols())
{
throw new IndexOutOfBoundsException(
"column index out of range (valid range is 0.." + (cols() - 1) + ", got " + col + ")");
}
}
/**
* Check that the matrix is square.
* @throws ValueRuntimeException when matrix is not square
*/
protected final void checkSquare() throws ValueRuntimeException
{
Throw.when(rows() != cols(), ValueRuntimeException.class, "Matrix is not square, rows=%d, cols=%d", rows(), cols());
}
/**
* Compute the determinant of the matrix, based on the SI values in the matrix.
* @return the determinant of the matrix
* @throws ValueRuntimeException when matrix is neither sparse, nor dense, or not square
*/
public final double determinantSI() throws ValueRuntimeException | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/scalar/base/DoubleScalar.java | 76 |
| org/djunits/value/vfloat/scalar/base/FloatScalar.java | 76 |
return ValueUtil.expressAsUnit(getSI(), targetUnit);
}
@Override
public final boolean lt(final S o)
{
return this.getSI() < o.getSI();
}
@Override
public final boolean le(final S o)
{
return this.getSI() <= o.getSI();
}
@Override
public final boolean gt(final S o)
{
return this.getSI() > o.getSI();
}
@Override
public final boolean ge(final S o)
{
return this.getSI() >= o.getSI();
}
@Override
public final boolean eq(final S o)
{
return this.getSI() == o.getSI();
}
@Override
public final boolean ne(final S o)
{
return this.getSI() != o.getSI();
}
@Override
public final boolean lt0()
{
return this.getSI() < 0.0;
}
@Override
public final boolean le0()
{
return this.getSI() <= 0.0;
}
@Override
public final boolean gt0()
{
return this.getSI() > 0.0;
}
@Override
public final boolean ge0()
{
return this.getSI() >= 0.0;
}
@Override
public final boolean eq0()
{
return this.getSI() == 0.0;
}
@Override
public final boolean ne0()
{
return this.getSI() != 0.0;
}
@Override
public final int compareTo(final S o)
{
return Double.compare(this.getSI(), o.getSI()); | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/base/DoubleVector.java | 216 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 214 |
setSI(index, ValueUtil.expressAsSIUnit(valueInUnit, valueUnit));
}
/**
* Set the scalar value at the specified position.
* @param index the index of the value to set
* @param value the value to set
* @throws IndexOutOfBoundsException when index out of range (index < 0 or index >= size())
*/
public void set(final int index, final S value) throws IndexOutOfBoundsException
{
setSI(index, value.si);
}
@SuppressWarnings("unchecked")
@Override
public S[] getScalars()
{
S[] array = (S[]) Array.newInstance(getScalarClass(), size());
for (int i = 0; i < size(); i++)
{
array[i] = get(i);
}
return array;
}
@SuppressWarnings("unchecked")
@Override
public V toSparse()
{
V result;
if (getStorageType().equals(StorageType.SPARSE))
{
result = (V) this;
result.setDisplayUnit(getDisplayUnit());
}
else
{
result = instantiateVector(getData().toSparse(), getDisplayUnit());
}
result.setDisplayUnit(getDisplayUnit());
return result;
}
@SuppressWarnings("unchecked")
@Override
public V toDense()
{
V result;
if (getStorageType().equals(StorageType.DENSE))
{
result = (V) this;
result.setDisplayUnit(getDisplayUnit());
}
else
{
result = instantiateVector(getData().toDense(), getDisplayUnit());
}
return result;
}
/**
* Execute a function on a cell by cell basis. Note: May be expensive when used on sparse data.
* @param doubleFunction the function to apply
* @return this updated vector
*/
@SuppressWarnings("unchecked")
public final V assign(final DoubleFunction doubleFunction) | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/base/DoubleVector.java | 416 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 407 |
DoubleVector<?, ?, ?> other = (DoubleVector<?, ?, ?>) obj;
if (!getDisplayUnit().getStandardUnit().equals(other.getDisplayUnit().getStandardUnit()))
return false;
if (this.data == null)
{
if (other.data != null)
return false;
}
else if (!this.data.equals(other.data))
return false;
return true;
}
/* ============================================================================================ */
/* =============================== ITERATOR METHODS AND CLASS ================================= */
/* ============================================================================================ */
@Override
public Iterator<S> iterator()
{
return new Itr();
}
/**
* The iterator class is loosely based in AbstractList.Itr. It does not throw a ConcurrentModificationException, because the
* size of the vector does not change. Normal (non-mutable) vectors cannot change their size, nor their content. The only
* thing for the MutableVector that can change is its content, not its length.
*/
protected class Itr implements Iterator<S>, Serializable
{
/** ... */
private static final long serialVersionUID = 20191018L;
/** index of next element to return. */
private int cursor = 0;
@Override
public boolean hasNext()
{
return this.cursor != size();
}
@Override
public S next()
{
if (this.cursor >= size())
{
throw new NoSuchElementException();
}
try
{
int i = this.cursor;
S next = get(i);
this.cursor = i + 1;
return next;
}
catch (IndexOutOfBoundsException exception)
{
throw new RuntimeException(exception);
}
}
@Override
public void remove()
{
throw new RuntimeException("Remove function cannot be applied on fixed-size DJUNITS Vector");
}
@Override
public String toString()
{
return "Itr [cursor=" + this.cursor + "]";
}
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 272 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 272 |
values[i][j] = ValueUtil.expressAsUnit(values[i][j], targetUnit);
}
}
return values;
}
@Override
public int rows()
{
return this.data.rows();
}
@Override
public int cols()
{
return this.data.cols();
}
@SuppressWarnings("unchecked")
@Override
public S[][] getScalars()
{
S[][] array = (S[][]) Array.newInstance(getScalarClass(), rows(), cols());
for (int i = 0; i < rows(); i++)
{
S[] row = (S[]) Array.newInstance(getScalarClass(), cols());
array[i] = row;
for (int j = 0; j < cols(); j++)
{
row[j] = get(i, j);
}
}
return array;
}
@Override
public S get(final int row, final int column) throws IndexOutOfBoundsException
{
checkIndex(row, column);
return instantiateScalarSI(getSI(row, column), getDisplayUnit());
}
@Override
public V getRow(final int row) throws IndexOutOfBoundsException
{
checkRowIndex(row); | |
| File | Line |
|---|---|
| org/djunits/unit/Unit.java | 200 |
| org/djunits/unit/Unit.java | 355 |
String cloneDefaultTextualAbbreviation = siPrefix.getDefaultTextualPrefix() + clone.getDefaultTextualAbbreviation();
// Make a builder and set values
Builder<U> builder = makeBuilder();
builder.setId(cloneId);
builder.setName(cloneName);
builder.setQuantity(this.quantity);
builder.setSiPrefixes(SIPrefixes.NONE, 1.0);
builder.setDefaultDisplayAbbreviation(cloneDefaultAbbreviation);
builder.setDefaultTextualAbbreviation(cloneDefaultTextualAbbreviation);
builder.setAdditionalAbbreviations(cloneAbbreviations.toArray(new String[cloneAbbreviations.size()]));
if (getScale() instanceof OffsetLinearScale)
{
builder.setScale(new OffsetLinearScale(
(siPrefixPower == 1.0 ? siPrefix.getFactor() : Math.pow(siPrefix.getFactor(), siPrefixPower))
* ((LinearScale) getScale()).getConversionFactorToStandardUnit(),
0.0));
}
else
{
builder.setScale(new LinearScale(
(siPrefixPower == 1.0 ? siPrefix.getFactor() : Math.pow(siPrefix.getFactor(), siPrefixPower))
* ((LinearScale) getScale()).getConversionFactorToStandardUnit()));
}
builder.setUnitSystem(this.unitSystem); // SI_BASE stays SI_BASE with prefix
builder.setGenerated(automaticallyGenerated);
return clone.build(builder);
}
catch (CloneNotSupportedException exception)
{
throw new UnitRuntimeException(exception);
}
}
/**
* Create a scaled version of this unit with the same unit system but another SI prefix and scale. This method is used for a
* unit that is explicitly scaled with an SI prefix.
* @param siPrefix the prefix for which to scale the unit
* @param siPrefixPower the power factor of the SI prefixes, e.g. 2.0 for square meters and 3.0 for cubic meters.
* @return a scaled instance of this unit
* @throws UnitRuntimeException when cloning fails
*/
public U deriveSI(final SIPrefix siPrefix, final double siPrefixPower) | |
| File | Line |
|---|---|
| org/djunits/unit/Unit.java | 200 |
| org/djunits/unit/Unit.java | 288 |
| org/djunits/unit/Unit.java | 355 |
String cloneDefaultTextualAbbreviation = siPrefix.getDefaultTextualPrefix() + clone.getDefaultTextualAbbreviation();
// Make a builder and set values
Builder<U> builder = makeBuilder();
builder.setId(cloneId);
builder.setName(cloneName);
builder.setQuantity(this.quantity);
builder.setSiPrefixes(SIPrefixes.NONE, 1.0);
builder.setDefaultDisplayAbbreviation(cloneDefaultAbbreviation);
builder.setDefaultTextualAbbreviation(cloneDefaultTextualAbbreviation);
builder.setAdditionalAbbreviations(cloneAbbreviations.toArray(new String[cloneAbbreviations.size()]));
if (getScale() instanceof OffsetLinearScale)
{
builder.setScale(new OffsetLinearScale(
(siPrefixPower == 1.0 ? siPrefix.getFactor() : Math.pow(siPrefix.getFactor(), siPrefixPower))
* ((LinearScale) getScale()).getConversionFactorToStandardUnit(),
0.0));
}
else
{
builder.setScale(new LinearScale(
(siPrefixPower == 1.0 ? siPrefix.getFactor() : Math.pow(siPrefix.getFactor(), siPrefixPower))
* ((LinearScale) getScale()).getConversionFactorToStandardUnit()));
}
builder.setUnitSystem(this.unitSystem); // SI_BASE stays SI_BASE with prefix
builder.setGenerated(automaticallyGenerated);
return clone.build(builder);
}
catch (CloneNotSupportedException exception)
{
throw new UnitRuntimeException(exception);
}
}
/**
* Create a scaled version of this unit with the same unit system but another SI prefix and scale. This method is used for a
* unit that is explicitly scaled with an SI prefix.
* @param siPrefix the prefix for which to scale the unit
* @param siPrefixPower the power factor of the SI prefixes, e.g. 2.0 for square meters and 3.0 for cubic meters.
* @return a scaled instance of this unit
* @throws UnitRuntimeException when cloning fails
*/
public U deriveSI(final SIPrefix siPrefix, final double siPrefixPower) | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/scalar/base/DoubleScalarRel.java | 51 |
| org/djunits/value/vfloat/scalar/base/FloatScalarRel.java | 51 |
public abstract R instantiateRel(double value, U unit);
@Override
public final R plus(final R increment)
{
if (getDisplayUnit().isBaseSIUnit())
{
return instantiateRel(this.getSI() + increment.getSI(), getDisplayUnit().getStandardUnit());
}
return getDisplayUnit().equals(increment.getDisplayUnit())
? instantiateRel(getInUnit() + increment.getInUnit(), getDisplayUnit())
: instantiateRel(this.getSI() + increment.getSI(), getDisplayUnit().getStandardUnit());
}
@Override
public final R minus(final R decrement)
{
if (getDisplayUnit().isBaseSIUnit())
{
return instantiateRel(this.getSI() - decrement.getSI(), getDisplayUnit().getStandardUnit());
}
return getDisplayUnit().equals(decrement.getDisplayUnit())
? instantiateRel(getInUnit() - decrement.getInUnit(), getDisplayUnit())
: instantiateRel(this.getSI() - decrement.getSI(), getDisplayUnit().getStandardUnit());
}
/**
* Multiply this scalar by another scalar and create a new scalar.
* @param otherScalar the value by which this scalar is multiplied
* @return a new scalar instance with correct SI dimensions
*/
public SIScalar times(final DoubleScalarRel<?, ?> otherScalar) | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 455 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 456 |
return assign(DoubleMathFunctions.RINT);
}
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
String ab = this instanceof Absolute ? "Abs " : "Rel ";
String ds = this.data.isDense() ? "Dense " : this.data.isSparse() ? "Sparse " : "?????? ";
if (isMutable())
{
buf.append("Mutable " + ab + ds);
}
else
{
buf.append("Immutable " + ab + ds);
}
}
for (int row = 0; row < rows(); row++)
{
buf.append("\r\n\t");
for (int col = 0; col < cols(); col++)
{
try
{ | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/base/DoubleVector.java | 324 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 315 |
return assign(DoubleMathFunctions.RINT);
}
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
String ar = this instanceof Absolute ? "Abs " : "Rel ";
String ds = getData().isDense() ? "Dense " : getData().isSparse() ? "Sparse " : "?????? ";
if (isMutable())
{
buf.append("Mutable " + ar + ds);
}
else
{
buf.append("Immutable " + ar + ds);
}
}
buf.append("[");
for (int i = 0; i < size(); i++)
{
try
{ | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/scalar/Mass.java | 218 |
| org/djunits/value/vfloat/scalar/FloatMass.java | 229 |
if (!Double.isFinite(this.si))
{
return toString(getDisplayUnit().getStandardUnit());
}
// PK: I can't think of an easier way to figure out what the exponent will be; rounding of the mantissa to the available
// width makes this hard; This feels like an expensive way.
String check = String.format(this.si >= 0 ? "%10.8E" : "%10.7E", this.si);
int exponent = Integer.parseInt(check.substring(check.indexOf("E") + 1));
if (exponent < -27 || exponent < smallestPower || exponent > 21 + 2 || exponent > biggestPower)
{
// Out of SI prefix range; do not scale.
return String.format(this.si >= 0 ? "%10.4E" : "%10.3E", this.si) + " "
+ getDisplayUnit().getStandardUnit().getId();
}
Integer roundedExponent = (int) Math.ceil((exponent - 2.0) / 3) * 3 + 3;
// System.out.print(String.format("exponent=%d; roundedExponent=%d ", exponent, roundedExponent));
String key = SIPrefixes.FACTORS.get(roundedExponent).getDefaultTextualPrefix() + "g";
MassUnit displayUnit = getDisplayUnit().getQuantity().getUnitByAbbreviation(key);
return toString(displayUnit);
}
/**
* Calculate the division of Mass and Mass, which results in a Dimensionless scalar.
* @param v scalar
* @return scalar as a division of Mass and Mass
*/
public final Dimensionless divide(final Mass v) | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 602 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 603 |
matAij[r] = new double[matAij.length];
int c = 0;
for (int j = 0; j < mat.length; j++)
{
if (j != col)
{
matAij[r][c++] = mat[row][j];
}
}
r++;
}
det += sgn * aij * det(matAij);
}
return det;
}
@Override
@SuppressWarnings("checkstyle:designforextension")
public int hashCode()
{
final int prime = 31;
int result = getDisplayUnit().getStandardUnit().hashCode();
result = prime * result + ((this.data == null) ? 0 : this.data.hashCode());
return result;
}
@Override
@SuppressWarnings({"checkstyle:designforextension", "checkstyle:needbraces"})
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/value/vdouble/vector/base/DoubleVector.java | 389 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 380 |
protected final void checkSize(final DoubleVector<?, ?, ?> other) throws ValueRuntimeException
{
Throw.whenNull(other, "Other vector is null");
Throw.when(size() != other.size(), ValueRuntimeException.class, "The vectors have different sizes: %d != %d", size(),
other.size());
}
@Override
@SuppressWarnings("checkstyle:designforextension")
public int hashCode()
{
final int prime = 31;
int result = getDisplayUnit().getStandardUnit().hashCode();
result = prime * result + ((this.data == null) ? 0 : this.data.hashCode());
return result;
}
@Override
@SuppressWarnings({"checkstyle:designforextension", "checkstyle:needbraces"})
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/value/vdouble/scalar/Energy.java | 221 |
| org/djunits/value/vdouble/scalar/Torque.java | 219 |
public final Dimensionless divide(final Energy v)
{
return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
}
/**
* 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, LengthUnit.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, ForceUnit.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 times(final LinearDensity v)
{
return new Force(this.si * v.si, ForceUnit.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, PowerUnit.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, DurationUnit.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/value/vfloat/scalar/FloatEnergy.java | 232 |
| org/djunits/value/vfloat/scalar/FloatTorque.java | 230 |
public final FloatDimensionless divide(final FloatEnergy v)
{
return new FloatDimensionless(this.si / v.si, DimensionlessUnit.SI);
}
/**
* Calculate the division of FloatEnergy and FloatForce, which results in a FloatLength scalar.
* @param v scalar
* @return scalar as a division of FloatEnergy and FloatForce
*/
public final FloatLength divide(final FloatForce v)
{
return new FloatLength(this.si / v.si, LengthUnit.SI);
}
/**
* Calculate the division of FloatEnergy and FloatLength, which results in a FloatForce scalar.
* @param v scalar
* @return scalar as a division of FloatEnergy and FloatLength
*/
public final FloatForce divide(final FloatLength v)
{
return new FloatForce(this.si / v.si, ForceUnit.SI);
}
/**
* Calculate the multiplication of FloatEnergy and FloatLinearDensity, which results in a FloatForce scalar.
* @param v scalar
* @return scalar as a multiplication of FloatEnergy and FloatLinearDensity
*/
public final FloatForce times(final FloatLinearDensity v)
{
return new FloatForce(this.si * v.si, ForceUnit.SI);
}
/**
* Calculate the division of FloatEnergy and FloatDuration, which results in a FloatPower scalar.
* @param v scalar
* @return scalar as a division of FloatEnergy and FloatDuration
*/
public final FloatPower divide(final FloatDuration v)
{
return new FloatPower(this.si / v.si, PowerUnit.SI);
}
/**
* Calculate the division of FloatEnergy and FloatPower, which results in a FloatDuration scalar.
* @param v scalar
* @return scalar as a division of FloatEnergy and FloatPower
*/
public final FloatDuration divide(final FloatPower v)
{
return new FloatDuration(this.si / v.si, DurationUnit.SI);
}
/**
* Calculate the division of FloatEnergy and FloatVolume, which results in a FloatPressure scalar.
* @param v scalar
* @return scalar as a division of FloatEnergy and FloatVolume
*/
public final FloatPressure divide(final FloatVolume v) | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/base/DoubleVectorAbs.java | 46 |
| org/djunits/value/vfloat/vector/base/FloatVectorAbs.java | 46 |
protected DoubleVectorAbs(final DoubleVectorData data, final AU unit)
{
super(data.copy(), unit);
}
@Override
public AV plus(final RV increment) throws ValueRuntimeException
{
return instantiateVector(this.getData().plus(increment.getData()), getDisplayUnit());
}
@Override
public AV minus(final RV decrement) throws ValueRuntimeException
{
return instantiateVector(this.getData().minus(decrement.getData()), getDisplayUnit());
}
@Override
public RV minus(final AV decrement) throws ValueRuntimeException
{
return instantiateVectorRel(this.getData().minus(decrement.getData()), decrement.getDisplayUnit().getRelativeUnit());
}
/**
* Decrement all values of this vector by the decrement. This only works if this vector is mutable.
* @param decrement the scalar by which to decrement all values
* @return this modified vector
* @throws ValueRuntimeException in case this vector is immutable
*/
@SuppressWarnings("unchecked")
public AV decrementBy(final R decrement)
{
checkCopyOnWrite();
assign(DoubleMathFunctions.DEC(decrement.si)); | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/data/DoubleMatrixData.java | 278 |
| org/djunits/value/vfloat/matrix/data/FloatMatrixData.java | 286 |
protected static <U extends Unit<U>, S extends DoubleScalar<U, S>> S[][] checkRectangularAndNonNull(final S[][] values)
throws ValueRuntimeException
{
Throw.when(null == values, NullPointerException.class, "Cannot create a matrix from a null Scalar[][]");
for (int row = 0; row < values.length; row++)
{
Throw.when(null == values[row], ValueRuntimeException.class,
"Cannot create a matrix from Scalar[][] containing null row(s)");
Throw.when(values[row].length != values[0].length, ValueRuntimeException.class,
"Cannot create a matrix from a jagged Scalar[][]");
for (int col = 0; col < values[row].length; col++)
{
Throw.whenNull(values[row][col], "Cannot create a matrix from Scalar[][] containing null(s)");
}
}
return values;
}
/**
* Check the sizes of this data object and the other data object.
* @param other the other data object
* @throws ValueRuntimeException if matrices have different lengths
*/
protected void checkSizes(final DoubleMatrixData other) throws ValueRuntimeException | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrixRel.java | 39 |
| org/djunits/value/vfloat/matrix/base/FloatMatrixRel.java | 39 |
protected DoubleMatrixRel(final DoubleMatrixData data, final U unit)
{
super(data.copy(), unit);
}
/**
* Compute the sum of all SI values of this matrix.
* @return the sum of all SI values of this matrix with the same display unit as this matrix
*/
public final S zSum()
{
return instantiateScalarSI(this.data.zSum(), getDisplayUnit());
}
@Override
public final RM plus(final RM rel) throws ValueRuntimeException
{
return instantiateMatrix(this.getData().plus(rel.getData()), getDisplayUnit());
}
@Override
public final RM minus(final RM rel) throws ValueRuntimeException
{
return instantiateMatrix(this.getData().minus(rel.getData()), getDisplayUnit());
}
/**
* Increment all values of this matrix by the increment. This only works if this matrix is mutable.
* @param increment the scalar by which to increment all values
* @return this modified matrix
* @throws ValueRuntimeException in case this matrix is immutable
*/
@SuppressWarnings("unchecked")
public RM incrementBy(final S increment)
{
checkCopyOnWrite();
assign(DoubleMathFunctions.INC(increment.si)); | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/base/DoubleVectorRel.java | 35 |
| org/djunits/value/vfloat/vector/base/FloatVectorRel.java | 35 |
protected DoubleVectorRel(final DoubleVectorData data, final U unit)
{
super(data.copy(), unit);
}
/**
* Compute the sum of all SI values of this vector.
* @return the sum of all SI values of this vector with the same display unit as this vector
*/
public final S zSum()
{
return instantiateScalarSI(getData().zSum(), getDisplayUnit());
}
@Override
public final RV plus(final RV rel) throws ValueRuntimeException
{
return instantiateVector(this.getData().plus(rel.getData()), getDisplayUnit());
}
@Override
public final RV minus(final RV rel) throws ValueRuntimeException
{
return instantiateVector(this.getData().minus(rel.getData()), getDisplayUnit());
}
/**
* Increment all values of this vector by the increment. This only works if the vector is mutable.
* @param increment the scalar by which to increment all values
* @return this modified vector
* @throws ValueRuntimeException in case this vector is immutable
*/
@SuppressWarnings("unchecked")
public RV incrementBy(final S increment)
{
checkCopyOnWrite();
assign(DoubleMathFunctions.INC(increment.si)); | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/scalar/base/DoubleScalar.java | 172 |
| org/djunits/value/vfloat/scalar/base/FloatScalar.java | 172 |
return (float) this.getSI();
}
@Override
public double doubleValue()
{
return this.getSI();
}
/**********************************************************************************/
/********************************* GENERIC METHODS ********************************/
/**********************************************************************************/
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
buf.append(this instanceof Absolute ? "Abs " : "Rel ");
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrixAbs.java | 53 |
| org/djunits/value/vfloat/matrix/base/FloatMatrixAbs.java | 53 |
protected DoubleMatrixAbs(final DoubleMatrixData data, final AU unit)
{
super(data.copy(), unit);
}
@Override
public AM plus(final RM increment) throws ValueRuntimeException
{
return instantiateMatrix(this.getData().plus(increment.getData()), getDisplayUnit());
}
@Override
public AM minus(final RM decrement) throws ValueRuntimeException
{
return instantiateMatrix(this.getData().minus(decrement.getData()), getDisplayUnit());
}
@Override
public RM minus(final AM decrement) throws ValueRuntimeException
{
return instantiateMatrixRel(this.getData().minus(decrement.getData()), decrement.getDisplayUnit().getRelativeUnit());
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/scalar/base/DoubleScalarAbs.java | 61 |
| org/djunits/value/vfloat/scalar/base/FloatScalarAbs.java | 61 |
public abstract A instantiateAbs(double value, AU unit);
@Override
public final A plus(final R increment)
{
AU targetUnit = getDisplayUnit();
return instantiateAbs(getInUnit() + increment.getInUnit(targetUnit.getRelativeUnit()), targetUnit);
}
@Override
public final A minus(final R decrement)
{
AU targetUnit = getDisplayUnit();
return instantiateAbs(getInUnit() - decrement.getInUnit(targetUnit.getRelativeUnit()), targetUnit);
}
@Override
public final R minus(final A decrement)
{
RU targetUnit = getDisplayUnit().getRelativeUnit();
return instantiateRel(getInUnit() - decrement.getInUnit(getDisplayUnit()), targetUnit);
}
/**********************************************************************************/
/********************************** MATH METHODS **********************************/
/**********************************************************************************/
@Override | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrixAbs.java | 32 |
| org/djunits/value/vdouble/matrix/base/DoubleMatrixRelWithAbs.java | 30 |
public abstract class DoubleMatrixAbs<
AU extends AbsoluteLinearUnit<AU, RU>,
A extends DoubleScalarAbs<AU, A, RU, R>,
AV extends DoubleVectorAbs<AU, A, AV, RU, R, RV>,
AM extends DoubleMatrixAbs<AU, A, AV, AM, RU, R, RV, RM>,
RU extends Unit<RU>,
R extends DoubleScalarRelWithAbs<AU, A, RU, R>,
RV extends DoubleVectorRelWithAbs<AU, A, AV, RU, R, RV>,
RM extends DoubleMatrixRelWithAbs<AU, A, AV, AM, RU, R, RV, RM>>
extends DoubleMatrix<AU, A, AV, AM> | |
| File | Line |
|---|---|
| org/djunits/value/vfloat/matrix/base/FloatMatrixAbs.java | 32 |
| org/djunits/value/vfloat/matrix/base/FloatMatrixRelWithAbs.java | 30 |
public abstract class FloatMatrixAbs<
AU extends AbsoluteLinearUnit<AU, RU>,
A extends FloatScalarAbs<AU, A, RU, R>,
AV extends FloatVectorAbs<AU, A, AV, RU, R, RV>,
AM extends FloatMatrixAbs<AU, A, AV, AM, RU, R, RV, RM>,
RU extends Unit<RU>,
R extends FloatScalarRelWithAbs<AU, A, RU, R>,
RV extends FloatVectorRelWithAbs<AU, A, AV, RU, R, RV>,
RM extends FloatMatrixRelWithAbs<AU, A, AV, AM, RU, R, RV, RM>>
extends FloatMatrix<AU, A, AV, AM> | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/data/DoubleMatrixDataSparse.java | 290 |
| org/djunits/value/vdouble/matrix/data/DoubleMatrixDataSparse.java | 339 |
otherIndex++;
}
if (value != 0d)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > rows() * cols())
{
currentSize = rows() * cols();
}
long[] newNewIndices = new long[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
double[] newNewValues = new double[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vfloat/matrix/data/FloatMatrixDataSparse.java | 281 |
| org/djunits/value/vfloat/matrix/data/FloatMatrixDataSparse.java | 330 |
otherIndex++;
}
if (value != 0f)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > rows() * cols())
{
currentSize = rows() * cols();
}
long[] newNewIndices = new long[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
float[] newNewValues = new float[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/data/DoubleVectorDataSparse.java | 306 |
| org/djunits/value/vfloat/vector/data/FloatVectorDataSparse.java | 307 |
double[] vectorSINew = new double[this.vectorSI.length - 1];
System.arraycopy(this.indices, 0, indicesNew, 0, internalIndex);
System.arraycopy(this.vectorSI, 0, vectorSINew, 0, internalIndex);
System.arraycopy(this.indices, internalIndex + 1, indicesNew, internalIndex,
this.indices.length - internalIndex - 1);
System.arraycopy(this.vectorSI, internalIndex + 1, vectorSINew, internalIndex,
this.indices.length - internalIndex - 1);
this.indices = indicesNew;
this.vectorSI = vectorSINew;
}
else
{
this.vectorSI[internalIndex] = valueSI;
}
return;
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/data/DoubleMatrixDataSparse.java | 425 |
| org/djunits/value/vfloat/matrix/data/FloatMatrixDataSparse.java | 416 |
double[] matrixSINew = new double[this.matrixSI.length + 1];
System.arraycopy(this.indices, 0, indicesNew, 0, internalIndex);
System.arraycopy(this.matrixSI, 0, matrixSINew, 0, internalIndex);
System.arraycopy(this.indices, internalIndex, indicesNew, internalIndex + 1, this.indices.length - internalIndex);
System.arraycopy(this.matrixSI, internalIndex, matrixSINew, internalIndex + 1, this.indices.length - internalIndex);
indicesNew[internalIndex] = index;
matrixSINew[internalIndex] = valueSI;
this.indices = indicesNew;
this.matrixSI = matrixSINew;
}
@Override
public final double[][] getDenseMatrixSI() | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/data/DoubleVectorDataSparse.java | 326 |
| org/djunits/value/vfloat/vector/data/FloatVectorDataSparse.java | 330 |
double[] vectorSINew = new double[this.vectorSI.length + 1];
System.arraycopy(this.indices, 0, indicesNew, 0, internalIndex);
System.arraycopy(this.vectorSI, 0, vectorSINew, 0, internalIndex);
// System.out.println("arraycopy1 current size is " + this.indices.length + " srcPos=" + internalIndex +
// ", new size is "
// + indicesNew.length + " dstPos=" + (internalIndex + 1) + " length=" + (this.indices.length - internalIndex));
System.arraycopy(this.indices, internalIndex, indicesNew, internalIndex + 1, this.indices.length - internalIndex);
System.arraycopy(this.vectorSI, internalIndex, vectorSINew, internalIndex + 1, this.indices.length - internalIndex);
// System.arraycopy(this.indices, internalIndex, indicesNew, internalIndex - 1, this.indices.length - internalIndex);
// System.arraycopy(this.vectorSI, internalIndex, vectorSINew, internalIndex - 1, this.indices.length - internalIndex);
indicesNew[internalIndex] = index;
vectorSINew[internalIndex] = valueSI;
this.indices = indicesNew;
this.vectorSI = vectorSINew;
}
@Override
public final double[] getDenseVectorSI() | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/data/DoubleMatrixDataSparse.java | 189 |
| org/djunits/value/vdouble/matrix/data/DoubleMatrixDataSparse.java | 292 |
| org/djunits/value/vdouble/matrix/data/DoubleMatrixDataSparse.java | 341 |
if (value != 0d)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > rows() * cols())
{
currentSize = rows() * cols();
}
long[] newNewIndices = new long[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
double[] newNewValues = new double[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vfloat/matrix/data/FloatMatrixDataSparse.java | 189 |
| org/djunits/value/vfloat/matrix/data/FloatMatrixDataSparse.java | 283 |
| org/djunits/value/vfloat/matrix/data/FloatMatrixDataSparse.java | 332 |
if (value != 0f)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > rows() * cols())
{
currentSize = rows() * cols();
}
long[] newNewIndices = new long[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
float[] newNewValues = new float[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 453 |
| org/djunits/value/vdouble/vector/base/DoubleVector.java | 322 |
public final M rint()
{
return assign(DoubleMathFunctions.RINT);
}
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
String ab = this instanceof Absolute ? "Abs " : "Rel "; | |
| File | Line |
|---|---|
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 454 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 313 |
public final M rint()
{
return assign(FloatMathFunctions.RINT);
}
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
String ab = this instanceof Absolute ? "Abs " : "Rel "; | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 616 |
| org/djunits/value/vdouble/vector/base/DoubleVector.java | 394 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 617 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 385 |
}
@Override
@SuppressWarnings("checkstyle:designforextension")
public int hashCode()
{
final int prime = 31;
int result = getDisplayUnit().getStandardUnit().hashCode();
result = prime * result + ((this.data == null) ? 0 : this.data.hashCode());
return result;
}
@Override
@SuppressWarnings({"checkstyle:designforextension", "checkstyle:needbraces"})
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/value/vdouble/vector/data/DoubleVectorDataSparse.java | 177 |
| org/djunits/value/vdouble/vector/data/DoubleVectorDataSparse.java | 226 |
otherIndex++;
}
if (value != 0d)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > size())
{
currentSize = size();
}
int[] newNewIndices = new int[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
double[] newNewValues = new double[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vfloat/vector/data/FloatVectorDataSparse.java | 178 |
| org/djunits/value/vfloat/vector/data/FloatVectorDataSparse.java | 227 |
otherIndex++;
}
if (value != 0f)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > size())
{
currentSize = size();
}
int[] newNewIndices = new int[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
float[] newNewValues = new float[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/data/DoubleVectorDataSparse.java | 76 |
| org/djunits/value/vdouble/vector/data/DoubleVectorDataSparse.java | 179 |
| org/djunits/value/vdouble/vector/data/DoubleVectorDataSparse.java | 228 |
if (value != 0d)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > size())
{
currentSize = size();
}
int[] newNewIndices = new int[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
double[] newNewValues = new double[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vfloat/vector/data/FloatVectorDataSparse.java | 77 |
| org/djunits/value/vfloat/vector/data/FloatVectorDataSparse.java | 180 |
| org/djunits/value/vfloat/vector/data/FloatVectorDataSparse.java | 229 |
if (value != 0f)
{
if (nonZeroValues >= currentSize)
{
// increase size of arrays
currentSize *= 2;
if (currentSize > size())
{
currentSize = size();
}
int[] newNewIndices = new int[currentSize];
System.arraycopy(newIndices, 0, newNewIndices, 0, newIndices.length);
newIndices = newNewIndices;
float[] newNewValues = new float[currentSize];
System.arraycopy(newValues, 0, newNewValues, 0, newValues.length);
newValues = newNewValues;
}
newIndices[nonZeroValues] = index;
newValues[nonZeroValues] = value;
nonZeroValues++;
}
} | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 455 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 315 |
return assign(DoubleMathFunctions.RINT);
}
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
String ab = this instanceof Absolute ? "Abs " : "Rel "; | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/vector/base/DoubleVector.java | 324 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 456 |
return assign(DoubleMathFunctions.RINT);
}
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{
String ar = this instanceof Absolute ? "Abs " : "Rel "; | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/base/DoubleMatrix.java | 455 |
| org/djunits/value/vdouble/scalar/base/DoubleScalar.java | 178 |
| org/djunits/value/vdouble/vector/base/DoubleVector.java | 324 |
| org/djunits/value/vfloat/matrix/base/FloatMatrix.java | 456 |
| org/djunits/value/vfloat/scalar/base/FloatScalar.java | 178 |
| org/djunits/value/vfloat/vector/base/FloatVector.java | 315 |
return assign(DoubleMathFunctions.RINT);
}
@Override
public String toString()
{
return toString(getDisplayUnit(), false, true);
}
@Override
public String toString(final U displayUnit)
{
return toString(displayUnit, false, true);
}
@Override
public String toString(final boolean verbose, final boolean withUnit)
{
return toString(getDisplayUnit(), verbose, withUnit);
}
@Override
public String toString(final U displayUnit, final boolean verbose, final boolean withUnit)
{
StringBuffer buf = new StringBuffer();
if (verbose)
{ | |
| File | Line |
|---|---|
| org/djunits/value/vdouble/matrix/data/DoubleMatrixData.java | 467 |
| org/djunits/value/vfloat/matrix/data/FloatMatrixData.java | 474 |
protected boolean compareDenseMatrixWithSparseMatrix(final DoubleMatrixDataDense dm, final DoubleMatrixDataSparse sm)
{
for (int row = 0; row < dm.rows; row++)
{
for (int col = 0; col < dm.cols; col++)
{
if (dm.getSI(row, col) != sm.getSI(row, col))
{
return false;
}
}
}
return true;
}
@Override
@SuppressWarnings("checkstyle:needbraces")
public boolean equals(final Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof DoubleMatrixData)) | |
