Remove redundant type arguments.
This commit is contained in:
parent
598edc1273
commit
8b5f4535ec
|
@ -126,7 +126,7 @@ public class DSCompiler {
|
|||
|
||||
/** Array of all compilers created so far. */
|
||||
private static AtomicReference<DSCompiler[][]> compilers =
|
||||
new AtomicReference<DSCompiler[][]>(null);
|
||||
new AtomicReference<>(null);
|
||||
|
||||
/** Number of free parameters. */
|
||||
private final int parameters;
|
||||
|
@ -358,14 +358,14 @@ public class DSCompiler {
|
|||
|
||||
for (int i = 0; i < dSize; ++i) {
|
||||
final int[][] dRow = derivativeCompiler.multIndirection[i];
|
||||
List<int[]> row = new ArrayList<int[]>(dRow.length * 2);
|
||||
List<int[]> row = new ArrayList<>(dRow.length * 2);
|
||||
for (int j = 0; j < dRow.length; ++j) {
|
||||
row.add(new int[] { dRow[j][0], lowerIndirection[dRow[j][1]], vSize + dRow[j][2] });
|
||||
row.add(new int[] { dRow[j][0], vSize + dRow[j][1], lowerIndirection[dRow[j][2]] });
|
||||
}
|
||||
|
||||
// combine terms with similar derivation orders
|
||||
final List<int[]> combined = new ArrayList<int[]>(row.size());
|
||||
final List<int[]> combined = new ArrayList<>(row.size());
|
||||
for (int j = 0; j < row.size(); ++j) {
|
||||
final int[] termJ = row.get(j);
|
||||
if (termJ[0] > 0) {
|
||||
|
@ -428,7 +428,7 @@ public class DSCompiler {
|
|||
// with respect to the parameter this compiler handles and the
|
||||
// underlying one did not handle
|
||||
for (int i = 0; i < dSize; ++i) {
|
||||
List<int[]> row = new ArrayList<int[]>();
|
||||
List<int[]> row = new ArrayList<>();
|
||||
for (int[] term : derivativeCompiler.compIndirection[i]) {
|
||||
|
||||
// handle term p * f_k(g(x)) * g_l1(x) * g_l2(x) * ... * g_lp(x)
|
||||
|
@ -475,7 +475,7 @@ public class DSCompiler {
|
|||
}
|
||||
|
||||
// combine terms with similar derivation orders
|
||||
final List<int[]> combined = new ArrayList<int[]>(row.size());
|
||||
final List<int[]> combined = new ArrayList<>(row.size());
|
||||
for (int j = 0; j < row.size(); ++j) {
|
||||
final int[] termJ = row.get(j);
|
||||
if (termJ[0] > 0) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
*/
|
||||
private SparseGradient(final double value, final Map<Integer, Double> derivatives) {
|
||||
this.value = value;
|
||||
this.derivatives = new HashMap<Integer, Double>();
|
||||
this.derivatives = new HashMap<>();
|
||||
if (derivatives != null) {
|
||||
this.derivatives.putAll(derivatives);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
private SparseGradient(final double value, final double scale,
|
||||
final Map<Integer, Double> derivatives) {
|
||||
this.value = value;
|
||||
this.derivatives = new HashMap<Integer, Double>();
|
||||
this.derivatives = new HashMap<>();
|
||||
if (derivatives != null) {
|
||||
for (final Map.Entry<Integer, Double> entry : derivatives.entrySet()) {
|
||||
this.derivatives.put(entry.getKey(), scale * entry.getValue());
|
||||
|
|
|
@ -37,10 +37,10 @@ import org.apache.commons.math4.util.Pair;
|
|||
public abstract class BaseRuleFactory<T extends Number> {
|
||||
/** List of points and weights, indexed by the order of the rule. */
|
||||
private final Map<Integer, Pair<T[], T[]>> pointsAndWeights
|
||||
= new TreeMap<Integer, Pair<T[], T[]>>();
|
||||
= new TreeMap<>();
|
||||
/** Cache for double-precision rules. */
|
||||
private final Map<Integer, Pair<double[], double[]>> pointsAndWeightsDouble
|
||||
= new TreeMap<Integer, Pair<double[], double[]>>();
|
||||
= new TreeMap<>();
|
||||
|
||||
/**
|
||||
* Gets a copy of the quadrature rule with the given number of integration
|
||||
|
@ -75,7 +75,7 @@ public abstract class BaseRuleFactory<T extends Number> {
|
|||
}
|
||||
|
||||
// Return a copy.
|
||||
return new Pair<double[], double[]>(cached.getFirst().clone(),
|
||||
return new Pair<>(cached.getFirst().clone(),
|
||||
cached.getSecond().clone());
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,6 @@ public abstract class BaseRuleFactory<T extends Number> {
|
|||
wD[i] = wT[i].doubleValue();
|
||||
}
|
||||
|
||||
return new Pair<double[], double[]>(pD, wD);
|
||||
return new Pair<>(pD, wD);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,6 +162,6 @@ public class GaussIntegratorFactory {
|
|||
weights[i] *= scale;
|
||||
}
|
||||
|
||||
return new Pair<double[], double[]>(points, weights);
|
||||
return new Pair<>(points, weights);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class HermiteRuleFactory extends BaseRuleFactory<Double> {
|
|||
|
||||
if (numberOfPoints == 1) {
|
||||
// Break recursion.
|
||||
return new Pair<Double[], Double[]>(new Double[] { 0d },
|
||||
return new Pair<>(new Double[] { 0d },
|
||||
new Double[] { SQRT_PI });
|
||||
}
|
||||
|
||||
|
@ -172,6 +172,6 @@ public class HermiteRuleFactory extends BaseRuleFactory<Double> {
|
|||
weights[iMax] = w;
|
||||
}
|
||||
|
||||
return new Pair<Double[], Double[]>(points, weights);
|
||||
return new Pair<>(points, weights);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class LegendreHighPrecisionRuleFactory extends BaseRuleFactory<BigDecimal
|
|||
|
||||
if (numberOfPoints == 1) {
|
||||
// Break recursion.
|
||||
return new Pair<BigDecimal[], BigDecimal[]>(new BigDecimal[] { BigDecimal.ZERO },
|
||||
return new Pair<>(new BigDecimal[] { BigDecimal.ZERO },
|
||||
new BigDecimal[] { two });
|
||||
}
|
||||
|
||||
|
@ -210,6 +210,6 @@ public class LegendreHighPrecisionRuleFactory extends BaseRuleFactory<BigDecimal
|
|||
weights[iMax] = tmp2;
|
||||
}
|
||||
|
||||
return new Pair<BigDecimal[], BigDecimal[]>(points, weights);
|
||||
return new Pair<>(points, weights);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class LegendreRuleFactory extends BaseRuleFactory<Double> {
|
|||
|
||||
if (numberOfPoints == 1) {
|
||||
// Break recursion.
|
||||
return new Pair<Double[], Double[]>(new Double[] { 0d },
|
||||
return new Pair<>(new Double[] { 0d },
|
||||
new Double[] { 2d });
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,6 @@ public class LegendreRuleFactory extends BaseRuleFactory<Double> {
|
|||
weights[iMax] = w;
|
||||
}
|
||||
|
||||
return new Pair<Double[], Double[]>(points, weights);
|
||||
return new Pair<>(points, weights);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ public class FieldHermiteInterpolator<T extends FieldElement<T>> {
|
|||
/** Create an empty interpolator.
|
||||
*/
|
||||
public FieldHermiteInterpolator() {
|
||||
this.abscissae = new ArrayList<T>();
|
||||
this.topDiagonal = new ArrayList<T[]>();
|
||||
this.bottomDiagonal = new ArrayList<T[]>();
|
||||
this.abscissae = new ArrayList<>();
|
||||
this.topDiagonal = new ArrayList<>();
|
||||
this.bottomDiagonal = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** Add a sample point.
|
||||
|
|
|
@ -59,9 +59,9 @@ public class HermiteInterpolator implements UnivariateDifferentiableVectorFuncti
|
|||
/** Create an empty interpolator.
|
||||
*/
|
||||
public HermiteInterpolator() {
|
||||
this.abscissae = new ArrayList<Double>();
|
||||
this.topDiagonal = new ArrayList<double[]>();
|
||||
this.bottomDiagonal = new ArrayList<double[]>();
|
||||
this.abscissae = new ArrayList<>();
|
||||
this.topDiagonal = new ArrayList<>();
|
||||
this.bottomDiagonal = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** Add a sample point.
|
||||
|
|
|
@ -93,8 +93,8 @@ public class InterpolatingMicrosphere {
|
|||
this.maxDarkFraction = maxDarkFraction;
|
||||
this.darkThreshold = darkThreshold;
|
||||
this.background = background;
|
||||
microsphere = new ArrayList<Facet>(size);
|
||||
microsphereData = new ArrayList<FacetData>(size);
|
||||
microsphere = new ArrayList<>(size);
|
||||
microsphereData = new ArrayList<>(size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ public class InterpolatingMicrosphere {
|
|||
microsphere = other.microsphere;
|
||||
|
||||
// Field must be copied.
|
||||
microsphereData = new ArrayList<FacetData>(size);
|
||||
microsphereData = new ArrayList<>(size);
|
||||
for (FacetData fd : other.microsphereData) {
|
||||
microsphereData.add(new FacetData(fd.illumination(), fd.sample()));
|
||||
}
|
||||
|
|
|
@ -51,34 +51,34 @@ public class PolynomialsUtils {
|
|||
|
||||
// initialize recurrence for Chebyshev polynomials
|
||||
// T0(X) = 1, T1(X) = 0 + 1 * X
|
||||
CHEBYSHEV_COEFFICIENTS = new ArrayList<BigFraction>();
|
||||
CHEBYSHEV_COEFFICIENTS = new ArrayList<>();
|
||||
CHEBYSHEV_COEFFICIENTS.add(BigFraction.ONE);
|
||||
CHEBYSHEV_COEFFICIENTS.add(BigFraction.ZERO);
|
||||
CHEBYSHEV_COEFFICIENTS.add(BigFraction.ONE);
|
||||
|
||||
// initialize recurrence for Hermite polynomials
|
||||
// H0(X) = 1, H1(X) = 0 + 2 * X
|
||||
HERMITE_COEFFICIENTS = new ArrayList<BigFraction>();
|
||||
HERMITE_COEFFICIENTS = new ArrayList<>();
|
||||
HERMITE_COEFFICIENTS.add(BigFraction.ONE);
|
||||
HERMITE_COEFFICIENTS.add(BigFraction.ZERO);
|
||||
HERMITE_COEFFICIENTS.add(BigFraction.TWO);
|
||||
|
||||
// initialize recurrence for Laguerre polynomials
|
||||
// L0(X) = 1, L1(X) = 1 - 1 * X
|
||||
LAGUERRE_COEFFICIENTS = new ArrayList<BigFraction>();
|
||||
LAGUERRE_COEFFICIENTS = new ArrayList<>();
|
||||
LAGUERRE_COEFFICIENTS.add(BigFraction.ONE);
|
||||
LAGUERRE_COEFFICIENTS.add(BigFraction.ONE);
|
||||
LAGUERRE_COEFFICIENTS.add(BigFraction.MINUS_ONE);
|
||||
|
||||
// initialize recurrence for Legendre polynomials
|
||||
// P0(X) = 1, P1(X) = 0 + 1 * X
|
||||
LEGENDRE_COEFFICIENTS = new ArrayList<BigFraction>();
|
||||
LEGENDRE_COEFFICIENTS = new ArrayList<>();
|
||||
LEGENDRE_COEFFICIENTS.add(BigFraction.ONE);
|
||||
LEGENDRE_COEFFICIENTS.add(BigFraction.ZERO);
|
||||
LEGENDRE_COEFFICIENTS.add(BigFraction.ONE);
|
||||
|
||||
// initialize map for Jacobi polynomials
|
||||
JACOBI_COEFFICIENTS = new HashMap<JacobiKey, List<BigFraction>>();
|
||||
JACOBI_COEFFICIENTS = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ public class PolynomialsUtils {
|
|||
if (!JACOBI_COEFFICIENTS.containsKey(key)) {
|
||||
|
||||
// allocate a new list for v, w
|
||||
final List<BigFraction> list = new ArrayList<BigFraction>();
|
||||
final List<BigFraction> list = new ArrayList<>();
|
||||
JACOBI_COEFFICIENTS.put(key, list);
|
||||
|
||||
// Pv,w,0(x) = 1;
|
||||
|
|
|
@ -1209,7 +1209,7 @@ public class Complex implements FieldElement<Complex>, Serializable {
|
|||
n);
|
||||
}
|
||||
|
||||
final List<Complex> result = new ArrayList<Complex>();
|
||||
final List<Complex> result = new ArrayList<>();
|
||||
|
||||
if (isNaN) {
|
||||
result.add(NaN);
|
||||
|
|
|
@ -117,7 +117,7 @@ public class EnumeratedDistribution<T> implements Serializable {
|
|||
throws NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException {
|
||||
random = rng;
|
||||
|
||||
singletons = new ArrayList<T>(pmf.size());
|
||||
singletons = new ArrayList<>(pmf.size());
|
||||
final double[] probs = new double[pmf.size()];
|
||||
|
||||
for (int i = 0; i < pmf.size(); i++) {
|
||||
|
@ -191,10 +191,10 @@ public class EnumeratedDistribution<T> implements Serializable {
|
|||
* @return the probability mass function.
|
||||
*/
|
||||
public List<Pair<T, Double>> getPmf() {
|
||||
final List<Pair<T, Double>> samples = new ArrayList<Pair<T, Double>>(probabilities.length);
|
||||
final List<Pair<T, Double>> samples = new ArrayList<>(probabilities.length);
|
||||
|
||||
for (int i = 0; i < probabilities.length; i++) {
|
||||
samples.add(new Pair<T, Double>(singletons.get(i), probabilities[i]));
|
||||
samples.add(new Pair<>(singletons.get(i), probabilities[i]));
|
||||
}
|
||||
|
||||
return samples;
|
||||
|
|
|
@ -97,7 +97,7 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
|||
throws DimensionMismatchException, NotPositiveException, MathArithmeticException,
|
||||
NotFiniteNumberException, NotANumberException {
|
||||
super(rng);
|
||||
innerDistribution = new EnumeratedDistribution<Integer>(
|
||||
innerDistribution = new EnumeratedDistribution<>(
|
||||
rng, createDistribution(singletons, probabilities));
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
|||
*/
|
||||
public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] data) {
|
||||
super(rng);
|
||||
final Map<Integer, Integer> dataMap = new HashMap<Integer, Integer>();
|
||||
final Map<Integer, Integer> dataMap = new HashMap<>();
|
||||
for (int value : data) {
|
||||
Integer count = dataMap.get(value);
|
||||
if (count == null) {
|
||||
|
@ -129,7 +129,7 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
|||
probabilities[index] = entry.getValue().intValue() / denom;
|
||||
index++;
|
||||
}
|
||||
innerDistribution = new EnumeratedDistribution<Integer>(rng, createDistribution(values, probabilities));
|
||||
innerDistribution = new EnumeratedDistribution<>(rng, createDistribution(values, probabilities));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,10 +156,10 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
|||
throw new DimensionMismatchException(probabilities.length, singletons.length);
|
||||
}
|
||||
|
||||
final List<Pair<Integer, Double>> samples = new ArrayList<Pair<Integer, Double>>(singletons.length);
|
||||
final List<Pair<Integer, Double>> samples = new ArrayList<>(singletons.length);
|
||||
|
||||
for (int i = 0; i < singletons.length; i++) {
|
||||
samples.add(new Pair<Integer, Double>(singletons[i], probabilities[i]));
|
||||
samples.add(new Pair<>(singletons[i], probabilities[i]));
|
||||
}
|
||||
return samples;
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution {
|
|||
NotFiniteNumberException, NotANumberException {
|
||||
super(rng);
|
||||
|
||||
innerDistribution = new EnumeratedDistribution<Double>(
|
||||
innerDistribution = new EnumeratedDistribution<>(
|
||||
rng, createDistribution(singletons, probabilities));
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution {
|
|||
*/
|
||||
public EnumeratedRealDistribution(final RandomGenerator rng, final double[] data) {
|
||||
super(rng);
|
||||
final Map<Double, Integer> dataMap = new HashMap<Double, Integer>();
|
||||
final Map<Double, Integer> dataMap = new HashMap<>();
|
||||
for (double value : data) {
|
||||
Integer count = dataMap.get(value);
|
||||
if (count == null) {
|
||||
|
@ -131,7 +131,7 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution {
|
|||
probabilities[index] = entry.getValue().intValue() / denom;
|
||||
index++;
|
||||
}
|
||||
innerDistribution = new EnumeratedDistribution<Double>(rng, createDistribution(values, probabilities));
|
||||
innerDistribution = new EnumeratedDistribution<>(rng, createDistribution(values, probabilities));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,10 +157,10 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution {
|
|||
throw new DimensionMismatchException(probabilities.length, singletons.length);
|
||||
}
|
||||
|
||||
final List<Pair<Double, Double>> samples = new ArrayList<Pair<Double, Double>>(singletons.length);
|
||||
final List<Pair<Double, Double>> samples = new ArrayList<>(singletons.length);
|
||||
|
||||
for (int i = 0; i < singletons.length; i++) {
|
||||
samples.add(new Pair<Double, Double>(singletons[i], probabilities[i]));
|
||||
samples.add(new Pair<>(singletons[i], probabilities[i]));
|
||||
}
|
||||
return samples;
|
||||
|
||||
|
|
|
@ -99,13 +99,13 @@ public class MixtureMultivariateNormalDistribution
|
|||
double[][] means,
|
||||
double[][][] covariances) {
|
||||
final List<Pair<Double, MultivariateNormalDistribution>> mvns
|
||||
= new ArrayList<Pair<Double, MultivariateNormalDistribution>>(weights.length);
|
||||
= new ArrayList<>(weights.length);
|
||||
|
||||
for (int i = 0; i < weights.length; i++) {
|
||||
final MultivariateNormalDistribution dist
|
||||
= new MultivariateNormalDistribution(means[i], covariances[i]);
|
||||
|
||||
mvns.add(new Pair<Double, MultivariateNormalDistribution>(weights[i], dist));
|
||||
mvns.add(new Pair<>(weights[i], dist));
|
||||
}
|
||||
|
||||
return mvns;
|
||||
|
|
|
@ -93,7 +93,7 @@ public class MixtureMultivariateRealDistribution<T extends MultivariateRealDistr
|
|||
}
|
||||
|
||||
// Store each distribution and its normalized weight.
|
||||
distribution = new ArrayList<T>();
|
||||
distribution = new ArrayList<>();
|
||||
weight = new double[numComp];
|
||||
for (int i = 0; i < numComp; i++) {
|
||||
final Pair<Double, T> comp = components.get(i);
|
||||
|
@ -161,10 +161,10 @@ public class MixtureMultivariateRealDistribution<T extends MultivariateRealDistr
|
|||
* @return the component distributions and associated weights.
|
||||
*/
|
||||
public List<Pair<Double, T>> getComponents() {
|
||||
final List<Pair<Double, T>> list = new ArrayList<Pair<Double, T>>(weight.length);
|
||||
final List<Pair<Double, T>> list = new ArrayList<>(weight.length);
|
||||
|
||||
for (int i = 0; i < weight.length; i++) {
|
||||
list.add(new Pair<Double, T>(weight[i], distribution.get(i)));
|
||||
list.add(new Pair<>(weight[i], distribution.get(i)));
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
|
@ -328,7 +328,7 @@ public class MultivariateNormalMixtureExpectationMaximization {
|
|||
|
||||
// components of mixture model to be created
|
||||
final List<Pair<Double, MultivariateNormalDistribution>> components =
|
||||
new ArrayList<Pair<Double, MultivariateNormalDistribution>>(numComponents);
|
||||
new ArrayList<>(numComponents);
|
||||
|
||||
// create a component based on data in each bin
|
||||
for (int binIndex = 0; binIndex < numComponents; binIndex++) {
|
||||
|
@ -364,7 +364,7 @@ public class MultivariateNormalMixtureExpectationMaximization {
|
|||
final MultivariateNormalDistribution mvn
|
||||
= new MultivariateNormalDistribution(columnMeans, covMat);
|
||||
|
||||
components.add(new Pair<Double, MultivariateNormalDistribution>(weight, mvn));
|
||||
components.add(new Pair<>(weight, mvn));
|
||||
}
|
||||
|
||||
return new MixtureMultivariateNormalDistribution(components);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ArgUtils {
|
|||
* {@code array}.
|
||||
*/
|
||||
public static Object[] flatten(Object[] array) {
|
||||
final List<Object> list = new ArrayList<Object>();
|
||||
final List<Object> list = new ArrayList<>();
|
||||
if (array != null) {
|
||||
for (Object o : array) {
|
||||
if (o instanceof Object[]) {
|
||||
|
|
|
@ -62,9 +62,9 @@ public class ExceptionContext implements Serializable {
|
|||
*/
|
||||
public ExceptionContext(final Throwable throwable) {
|
||||
this.throwable = throwable;
|
||||
msgPatterns = new ArrayList<Localizable>();
|
||||
msgArguments = new ArrayList<Object[]>();
|
||||
context = new HashMap<String, Object>();
|
||||
msgPatterns = new ArrayList<>();
|
||||
msgArguments = new ArrayList<>();
|
||||
context = new HashMap<>();
|
||||
}
|
||||
|
||||
/** Get a reference to the exception to which the context relates.
|
||||
|
@ -256,8 +256,8 @@ public class ExceptionContext implements Serializable {
|
|||
ClassNotFoundException {
|
||||
// Step 1.
|
||||
final int len = in.readInt();
|
||||
msgPatterns = new ArrayList<Localizable>(len);
|
||||
msgArguments = new ArrayList<Object[]>(len);
|
||||
msgPatterns = new ArrayList<>(len);
|
||||
msgArguments = new ArrayList<>(len);
|
||||
// Step 2.
|
||||
for (int i = 0; i < len; i++) {
|
||||
// Step 3.
|
||||
|
@ -311,7 +311,7 @@ public class ExceptionContext implements Serializable {
|
|||
ClassNotFoundException {
|
||||
// Step 1.
|
||||
final int len = in.readInt();
|
||||
context = new HashMap<String, Object>();
|
||||
context = new HashMap<>();
|
||||
for (int i = 0; i < len; i++) {
|
||||
// Step 2.
|
||||
final String key = (String) in.readObject();
|
||||
|
|
|
@ -248,7 +248,7 @@ public class GaussianCurveFitter extends AbstractCurveFitter {
|
|||
* @return the input observations, sorted.
|
||||
*/
|
||||
private List<WeightedObservedPoint> sortObservations(Collection<WeightedObservedPoint> unsorted) {
|
||||
final List<WeightedObservedPoint> observations = new ArrayList<WeightedObservedPoint>(unsorted);
|
||||
final List<WeightedObservedPoint> observations = new ArrayList<>(unsorted);
|
||||
|
||||
final Comparator<WeightedObservedPoint> cmp = new Comparator<WeightedObservedPoint>() {
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -292,7 +292,7 @@ public class HarmonicCurveFitter extends AbstractCurveFitter {
|
|||
* @return the input observations, sorted.
|
||||
*/
|
||||
private List<WeightedObservedPoint> sortObservations(Collection<WeightedObservedPoint> unsorted) {
|
||||
final List<WeightedObservedPoint> observations = new ArrayList<WeightedObservedPoint>(unsorted);
|
||||
final List<WeightedObservedPoint> observations = new ArrayList<>(unsorted);
|
||||
|
||||
// Since the samples are almost always already sorted, this
|
||||
// method is implemented as an insertion sort that reorders the
|
||||
|
|
|
@ -32,7 +32,7 @@ public class WeightedObservedPoints implements Serializable {
|
|||
|
||||
/** Observed points. */
|
||||
private final List<WeightedObservedPoint> observations
|
||||
= new ArrayList<WeightedObservedPoint>();
|
||||
= new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Adds a point to the sample.
|
||||
|
@ -100,7 +100,7 @@ public class WeightedObservedPoints implements Serializable {
|
|||
// The copy is necessary to ensure thread-safety because of the
|
||||
// "clear" method (which otherwise would be able to empty the
|
||||
// list of points while it is being used by another thread).
|
||||
return new ArrayList<WeightedObservedPoint>(observations);
|
||||
return new ArrayList<>(observations);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -294,7 +294,7 @@ public class GaussNewtonOptimizer implements LeastSquaresOptimizer {
|
|||
normal.setEntry(i, j, normal.getEntry(j, i));
|
||||
}
|
||||
}
|
||||
return new Pair<RealMatrix, RealVector>(normal, jTr);
|
||||
return new Pair<>(normal, jTr);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ public class LeastSquaresFactory {
|
|||
final double[] p = point.toArray();
|
||||
|
||||
// Evaluate.
|
||||
return new Pair<RealVector, RealMatrix>(computeValue(p),
|
||||
return new Pair<>(computeValue(p),
|
||||
computeJacobian(p));
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public abstract class AbstractListChromosome<T> extends Chromosome {
|
|||
public AbstractListChromosome(final List<T> representation, final boolean copyList) {
|
||||
checkValidity(representation);
|
||||
this.representation =
|
||||
Collections.unmodifiableList(copyList ? new ArrayList<T>(representation) : representation);
|
||||
Collections.unmodifiableList(copyList ? new ArrayList<>(representation) : representation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,7 @@ public abstract class BinaryChromosome extends AbstractListChromosome<Integer> {
|
|||
*/
|
||||
public static List<Integer> randomBinaryRepresentation(int length) {
|
||||
// random binary list
|
||||
List<Integer> rList= new ArrayList<Integer> (length);
|
||||
List<Integer> rList= new ArrayList<> (length);
|
||||
for (int j=0; j<length; j++) {
|
||||
rList.add(GeneticAlgorithm.getRandomGenerator().nextInt(2));
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class BinaryMutation implements MutationPolicy {
|
|||
}
|
||||
|
||||
BinaryChromosome origChrom = (BinaryChromosome) original;
|
||||
List<Integer> newRepr = new ArrayList<Integer>(origChrom.getRepresentation());
|
||||
List<Integer> newRepr = new ArrayList<>(origChrom.getRepresentation());
|
||||
|
||||
// randomly select a gene
|
||||
int geneIndex = GeneticAlgorithm.getRandomGenerator().nextInt(origChrom.getLength());
|
||||
|
|
|
@ -129,13 +129,13 @@ public class CycleCrossover<T> implements CrossoverPolicy {
|
|||
final List<T> parent1Rep = first.getRepresentation();
|
||||
final List<T> parent2Rep = second.getRepresentation();
|
||||
// and of the children: do a crossover copy to simplify the later processing
|
||||
final List<T> child1Rep = new ArrayList<T>(second.getRepresentation());
|
||||
final List<T> child2Rep = new ArrayList<T>(first.getRepresentation());
|
||||
final List<T> child1Rep = new ArrayList<>(second.getRepresentation());
|
||||
final List<T> child2Rep = new ArrayList<>(first.getRepresentation());
|
||||
|
||||
// the set of all visited indices so far
|
||||
final Set<Integer> visitedIndices = new HashSet<Integer>(length);
|
||||
final Set<Integer> visitedIndices = new HashSet<>(length);
|
||||
// the indices of the current cycle
|
||||
final List<Integer> indices = new ArrayList<Integer>(length);
|
||||
final List<Integer> indices = new ArrayList<>(length);
|
||||
|
||||
// determine the starting index
|
||||
int idx = randomStart ? GeneticAlgorithm.getRandomGenerator().nextInt(length) : 0;
|
||||
|
|
|
@ -76,7 +76,7 @@ public abstract class ListPopulation implements Population {
|
|||
chromosomes.size(), populationLimit, false);
|
||||
}
|
||||
this.populationLimit = populationLimit;
|
||||
this.chromosomes = new ArrayList<Chromosome>(populationLimit);
|
||||
this.chromosomes = new ArrayList<>(populationLimit);
|
||||
this.chromosomes.addAll(chromosomes);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,8 +139,8 @@ public class NPointCrossover<T> implements CrossoverPolicy {
|
|||
final List<T> parent1Rep = first.getRepresentation();
|
||||
final List<T> parent2Rep = second.getRepresentation();
|
||||
// and of the children
|
||||
final List<T> child1Rep = new ArrayList<T>(length);
|
||||
final List<T> child2Rep = new ArrayList<T>(length);
|
||||
final List<T> child1Rep = new ArrayList<>(length);
|
||||
final List<T> child2Rep = new ArrayList<>(length);
|
||||
|
||||
final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ public class OnePointCrossover<T> implements CrossoverPolicy {
|
|||
final List<T> parent1Rep = first.getRepresentation();
|
||||
final List<T> parent2Rep = second.getRepresentation();
|
||||
// and of the children
|
||||
final List<T> child1Rep = new ArrayList<T>(length);
|
||||
final List<T> child2Rep = new ArrayList<T>(length);
|
||||
final List<T> child1Rep = new ArrayList<>(length);
|
||||
final List<T> child2Rep = new ArrayList<>(length);
|
||||
|
||||
// select a crossover point at random (0 and length makes no sense)
|
||||
final int crossoverIndex = 1 + (GeneticAlgorithm.getRandomGenerator().nextInt(length-2));
|
||||
|
|
|
@ -97,11 +97,11 @@ public class OrderedCrossover<T> implements CrossoverPolicy {
|
|||
final List<T> parent1Rep = first.getRepresentation();
|
||||
final List<T> parent2Rep = second.getRepresentation();
|
||||
// and of the children
|
||||
final List<T> child1 = new ArrayList<T>(length);
|
||||
final List<T> child2 = new ArrayList<T>(length);
|
||||
final List<T> child1 = new ArrayList<>(length);
|
||||
final List<T> child2 = new ArrayList<>(length);
|
||||
// sets of already inserted items for quick access
|
||||
final Set<T> child1Set = new HashSet<T>(length);
|
||||
final Set<T> child2Set = new HashSet<T>(length);
|
||||
final Set<T> child1Set = new HashSet<>(length);
|
||||
final Set<T> child2Set = new HashSet<>(length);
|
||||
|
||||
final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
|
||||
// choose random points, making sure that lb < ub.
|
||||
|
|
|
@ -72,7 +72,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
public RandomKey(final List<Double> representation) throws InvalidRepresentationException {
|
||||
super(representation);
|
||||
// store the sorted representation
|
||||
List<Double> sortedRepr = new ArrayList<Double> (getRepresentation());
|
||||
List<Double> sortedRepr = new ArrayList<> (getRepresentation());
|
||||
Collections.sort(sortedRepr);
|
||||
sortedRepresentation = Collections.unmodifiableList(sortedRepr);
|
||||
// store the permutation of [0,1,...,n-1] list for toString() and isSame() methods
|
||||
|
@ -126,10 +126,10 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
}
|
||||
|
||||
// do not modify the original representation
|
||||
List<Double> reprCopy = new ArrayList<Double> (representation);
|
||||
List<Double> reprCopy = new ArrayList<> (representation);
|
||||
|
||||
// now find the indices in the original repr and use them for permuting
|
||||
List<S> res = new ArrayList<S> (l);
|
||||
List<S> res = new ArrayList<> (l);
|
||||
for (int i=0; i<l; i++) {
|
||||
int index = reprCopy.indexOf(sortedRepr.get(i));
|
||||
res.add(sequence.get(index));
|
||||
|
@ -195,7 +195,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
* @return representation of a random permutation
|
||||
*/
|
||||
public static final List<Double> randomPermutation(final int l) {
|
||||
List<Double> repr = new ArrayList<Double>(l);
|
||||
List<Double> repr = new ArrayList<>(l);
|
||||
for (int i=0; i<l; i++) {
|
||||
repr.add(GeneticAlgorithm.getRandomGenerator().nextDouble());
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
* @return representation of an identity permutation
|
||||
*/
|
||||
public static final List<Double> identityPermutation(final int l) {
|
||||
List<Double> repr = new ArrayList<Double>(l);
|
||||
List<Double> repr = new ArrayList<>(l);
|
||||
for (int i=0; i<l; i++) {
|
||||
repr.add((double)i/l);
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
*/
|
||||
public static <S> List<Double> comparatorPermutation(final List<S> data,
|
||||
final Comparator<S> comparator) {
|
||||
List<S> sortedData = new ArrayList<S>(data);
|
||||
List<S> sortedData = new ArrayList<>(data);
|
||||
Collections.sort(sortedData, comparator);
|
||||
|
||||
return inducedPermutation(data, sortedData);
|
||||
|
@ -264,7 +264,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
}
|
||||
int l = originalData.size();
|
||||
|
||||
List<S> origDataCopy = new ArrayList<S> (originalData);
|
||||
List<S> origDataCopy = new ArrayList<> (originalData);
|
||||
|
||||
Double[] res = new Double[l];
|
||||
for (int i=0; i<l; i++) {
|
||||
|
@ -291,7 +291,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
|
|||
* @return list of integers from 0 to l-1
|
||||
*/
|
||||
private static List<Integer> baseSequence(final int l) {
|
||||
List<Integer> baseSequence = new ArrayList<Integer> (l);
|
||||
List<Integer> baseSequence = new ArrayList<> (l);
|
||||
for (int i=0; i<l; i++) {
|
||||
baseSequence.add(i);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class RandomKeyMutation implements MutationPolicy {
|
|||
List<Double> repr = originalRk.getRepresentation();
|
||||
int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size());
|
||||
|
||||
List<Double> newRepr = new ArrayList<Double> (repr);
|
||||
List<Double> newRepr = new ArrayList<> (repr);
|
||||
newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble());
|
||||
|
||||
return originalRk.newFixedLengthChromosome(newRepr);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class TournamentSelection implements SelectionPolicy {
|
|||
};
|
||||
|
||||
// create a copy of the chromosome list
|
||||
List<Chromosome> chromosomes = new ArrayList<Chromosome> (population.getChromosomes());
|
||||
List<Chromosome> chromosomes = new ArrayList<> (population.getChromosomes());
|
||||
for (int i=0; i<this.arity; i++) {
|
||||
// select a random individual and add it to the tournament
|
||||
int rind = GeneticAlgorithm.getRandomGenerator().nextInt(chromosomes.size());
|
||||
|
|
|
@ -112,8 +112,8 @@ public class UniformCrossover<T> implements CrossoverPolicy {
|
|||
final List<T> parent1Rep = first.getRepresentation();
|
||||
final List<T> parent2Rep = second.getRepresentation();
|
||||
// and of the children
|
||||
final List<T> child1Rep = new ArrayList<T>(length);
|
||||
final List<T> child2Rep = new ArrayList<T>(length);
|
||||
final List<T> child1Rep = new ArrayList<>(length);
|
||||
final List<T> child2Rep = new ArrayList<>(length);
|
||||
|
||||
final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ public class WelzlEncloser<S extends Space, P extends Point<S>> implements Enclo
|
|||
private EnclosingBall<S, P> pivotingBall(final Iterable<P> points) {
|
||||
|
||||
final P first = points.iterator().next();
|
||||
final List<P> extreme = new ArrayList<P>(first.getSpace().getDimension() + 1);
|
||||
final List<P> support = new ArrayList<P>(first.getSpace().getDimension() + 1);
|
||||
final List<P> extreme = new ArrayList<>(first.getSpace().getDimension() + 1);
|
||||
final List<P> support = new ArrayList<>(first.getSpace().getDimension() + 1);
|
||||
|
||||
// start with only first point selected as a candidate support
|
||||
extreme.add(first);
|
||||
|
|
|
@ -108,12 +108,12 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
|
|||
if (Double.isInfinite(lower) && (lower < 0)) {
|
||||
if (Double.isInfinite(upper) && (upper > 0)) {
|
||||
// the tree must cover the whole real line
|
||||
return new BSPTree<Euclidean1D>(Boolean.TRUE);
|
||||
return new BSPTree<>(Boolean.TRUE);
|
||||
}
|
||||
// the tree must be open on the negative infinity side
|
||||
final SubHyperplane<Euclidean1D> upperCut =
|
||||
new OrientedPoint(new Vector1D(upper), true, tolerance).wholeHyperplane();
|
||||
return new BSPTree<Euclidean1D>(upperCut,
|
||||
return new BSPTree<>(upperCut,
|
||||
new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
new BSPTree<Euclidean1D>(Boolean.TRUE),
|
||||
null);
|
||||
|
@ -122,7 +122,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
|
|||
new OrientedPoint(new Vector1D(lower), false, tolerance).wholeHyperplane();
|
||||
if (Double.isInfinite(upper) && (upper > 0)) {
|
||||
// the tree must be open on the positive infinity side
|
||||
return new BSPTree<Euclidean1D>(lowerCut,
|
||||
return new BSPTree<>(lowerCut,
|
||||
new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
new BSPTree<Euclidean1D>(Boolean.TRUE),
|
||||
null);
|
||||
|
@ -131,9 +131,9 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
|
|||
// the tree must be bounded on the two sides
|
||||
final SubHyperplane<Euclidean1D> upperCut =
|
||||
new OrientedPoint(new Vector1D(upper), true, tolerance).wholeHyperplane();
|
||||
return new BSPTree<Euclidean1D>(lowerCut,
|
||||
return new BSPTree<>(lowerCut,
|
||||
new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
new BSPTree<Euclidean1D>(upperCut,
|
||||
new BSPTree<>(upperCut,
|
||||
new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
new BSPTree<Euclidean1D>(Boolean.TRUE),
|
||||
null),
|
||||
|
@ -222,9 +222,9 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
|
|||
final double previousOffset = x - previous;
|
||||
final double currentOffset = a[0] - x;
|
||||
if (previousOffset < currentOffset) {
|
||||
return new BoundaryProjection<Euclidean1D>(point, finiteOrNullPoint(previous), previousOffset);
|
||||
return new BoundaryProjection<>(point, finiteOrNullPoint(previous), previousOffset);
|
||||
} else {
|
||||
return new BoundaryProjection<Euclidean1D>(point, finiteOrNullPoint(a[0]), currentOffset);
|
||||
return new BoundaryProjection<>(point, finiteOrNullPoint(a[0]), currentOffset);
|
||||
}
|
||||
} else if (x <= a[1]) {
|
||||
// the test point lies within the current interval
|
||||
|
@ -232,16 +232,16 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
|
|||
final double offset0 = a[0] - x;
|
||||
final double offset1 = x - a[1];
|
||||
if (offset0 < offset1) {
|
||||
return new BoundaryProjection<Euclidean1D>(point, finiteOrNullPoint(a[1]), offset1);
|
||||
return new BoundaryProjection<>(point, finiteOrNullPoint(a[1]), offset1);
|
||||
} else {
|
||||
return new BoundaryProjection<Euclidean1D>(point, finiteOrNullPoint(a[0]), offset0);
|
||||
return new BoundaryProjection<>(point, finiteOrNullPoint(a[0]), offset0);
|
||||
}
|
||||
}
|
||||
previous = a[1];
|
||||
}
|
||||
|
||||
// the test point if past the last sub-interval
|
||||
return new BoundaryProjection<Euclidean1D>(point, finiteOrNullPoint(previous), x - previous);
|
||||
return new BoundaryProjection<>(point, finiteOrNullPoint(previous), x - previous);
|
||||
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
|
|||
* elements
|
||||
*/
|
||||
public List<Interval> asList() {
|
||||
final List<Interval> list = new ArrayList<Interval>();
|
||||
final List<Interval> list = new ArrayList<>();
|
||||
for (final double[] a : this) {
|
||||
list.add(new Interval(a[0], a[1]));
|
||||
}
|
||||
|
|
|
@ -61,11 +61,11 @@ public class SubOrientedPoint extends AbstractSubHyperplane<Euclidean1D, Euclide
|
|||
public SplitSubHyperplane<Euclidean1D> split(final Hyperplane<Euclidean1D> hyperplane) {
|
||||
final double global = hyperplane.getOffset(((OrientedPoint) getHyperplane()).getLocation());
|
||||
if (global < -1.0e-10) {
|
||||
return new SplitSubHyperplane<Euclidean1D>(null, this);
|
||||
return new SplitSubHyperplane<>(null, this);
|
||||
} else if (global > 1.0e-10) {
|
||||
return new SplitSubHyperplane<Euclidean1D>(this, null);
|
||||
return new SplitSubHyperplane<>(this, null);
|
||||
} else {
|
||||
return new SplitSubHyperplane<Euclidean1D>(null, null);
|
||||
return new SplitSubHyperplane<>(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -374,9 +374,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
public FieldRotation(final RotationOrder order, final RotationConvention convention,
|
||||
final T alpha1, final T alpha2, final T alpha3) {
|
||||
final T one = alpha1.getField().getOne();
|
||||
final FieldRotation<T> r1 = new FieldRotation<T>(new FieldVector3D<T>(one, order.getA1()), alpha1, convention);
|
||||
final FieldRotation<T> r2 = new FieldRotation<T>(new FieldVector3D<T>(one, order.getA2()), alpha2, convention);
|
||||
final FieldRotation<T> r3 = new FieldRotation<T>(new FieldVector3D<T>(one, order.getA3()), alpha3, convention);
|
||||
final FieldRotation<T> r1 = new FieldRotation<>(new FieldVector3D<>(one, order.getA1()), alpha1, convention);
|
||||
final FieldRotation<T> r2 = new FieldRotation<>(new FieldVector3D<>(one, order.getA2()), alpha2, convention);
|
||||
final FieldRotation<T> r3 = new FieldRotation<>(new FieldVector3D<>(one, order.getA3()), alpha3, convention);
|
||||
final FieldRotation<T> composed = r1.compose(r2.compose(r3, convention), convention);
|
||||
q0 = composed.q0;
|
||||
q1 = composed.q1;
|
||||
|
@ -453,7 +453,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
* of the instance
|
||||
*/
|
||||
public FieldRotation<T> revert() {
|
||||
return new FieldRotation<T>(q0.negate(), q1, q2, q3, false);
|
||||
return new FieldRotation<>(q0.negate(), q1, q2, q3, false);
|
||||
}
|
||||
|
||||
/** Get the scalar coordinate of the quaternion.
|
||||
|
@ -509,17 +509,17 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
final T squaredSine = q1.multiply(q1).add(q2.multiply(q2)).add(q3.multiply(q3));
|
||||
if (squaredSine.getReal() == 0) {
|
||||
final Field<T> field = squaredSine.getField();
|
||||
return new FieldVector3D<T>(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(),
|
||||
return new FieldVector3D<>(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(),
|
||||
field.getZero(),
|
||||
field.getZero());
|
||||
} else {
|
||||
final double sgn = convention == RotationConvention.VECTOR_OPERATOR ? +1 : -1;
|
||||
if (q0.getReal() < 0) {
|
||||
T inverse = squaredSine.sqrt().reciprocal().multiply(sgn);
|
||||
return new FieldVector3D<T>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse));
|
||||
return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse));
|
||||
}
|
||||
final T inverse = squaredSine.sqrt().reciprocal().negate().multiply(sgn);
|
||||
return new FieldVector3D<T>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse));
|
||||
return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
*/
|
||||
private FieldVector3D<T> vector(final double x, final double y, final double z) {
|
||||
final T zero = q0.getField().getZero();
|
||||
return new FieldVector3D<T>(zero.add(x), zero.add(y), zero.add(z));
|
||||
return new FieldVector3D<>(zero.add(x), zero.add(y), zero.add(z));
|
||||
}
|
||||
|
||||
/** Get the 3X3 matrix corresponding to the instance
|
||||
|
@ -1090,7 +1090,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
|
||||
final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z));
|
||||
|
||||
return new FieldVector3D<T>(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
return new FieldVector3D<>(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
q0.multiply(y.multiply(q0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y),
|
||||
q0.multiply(z.multiply(q0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z));
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
|
||||
final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z));
|
||||
|
||||
return new FieldVector3D<T>(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
return new FieldVector3D<>(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
q0.multiply(q0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y),
|
||||
q0.multiply(q0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z));
|
||||
|
||||
|
@ -1165,7 +1165,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
|
||||
final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3()));
|
||||
|
||||
return new FieldVector3D<T>(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x),
|
||||
return new FieldVector3D<>(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x),
|
||||
y.multiply(r.getQ0()).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(r.getQ0()).add(s.multiply(r.getQ2())).multiply(2).subtract(y),
|
||||
z.multiply(r.getQ0()).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(r.getQ0()).add(s.multiply(r.getQ3())).multiply(2).subtract(z));
|
||||
|
||||
|
@ -1184,7 +1184,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z));
|
||||
final T m0 = q0.negate();
|
||||
|
||||
return new FieldVector3D<T>(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
return new FieldVector3D<>(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
m0.multiply(y.multiply(m0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y),
|
||||
m0.multiply(z.multiply(m0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z));
|
||||
|
||||
|
@ -1203,7 +1203,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z));
|
||||
final T m0 = q0.negate();
|
||||
|
||||
return new FieldVector3D<T>(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
return new FieldVector3D<>(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x),
|
||||
m0.multiply(m0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y),
|
||||
m0.multiply(m0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z));
|
||||
|
||||
|
@ -1263,7 +1263,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3()));
|
||||
final double m0 = -r.getQ0();
|
||||
|
||||
return new FieldVector3D<T>(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x),
|
||||
return new FieldVector3D<>(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x),
|
||||
y.multiply(m0).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(m0).add(s.multiply(r.getQ2())).multiply(2).subtract(y),
|
||||
z.multiply(m0).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(m0).add(s.multiply(r.getQ3())).multiply(2).subtract(z));
|
||||
|
||||
|
@ -1317,7 +1317,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
* using vector operator convention
|
||||
*/
|
||||
private FieldRotation<T> composeInternal(final FieldRotation<T> r) {
|
||||
return new FieldRotation<T>(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))),
|
||||
return new FieldRotation<>(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))),
|
||||
r.q1.multiply(q0).add(r.q0.multiply(q1)).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))),
|
||||
r.q2.multiply(q0).add(r.q0.multiply(q2)).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))),
|
||||
r.q3.multiply(q0).add(r.q0.multiply(q3)).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))),
|
||||
|
@ -1372,7 +1372,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
* using vector operator convention
|
||||
*/
|
||||
private FieldRotation<T> composeInternal(final Rotation r) {
|
||||
return new FieldRotation<T>(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))),
|
||||
return new FieldRotation<>(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))),
|
||||
q0.multiply(r.getQ1()).add(q1.multiply(r.getQ0())).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))),
|
||||
q0.multiply(r.getQ2()).add(q2.multiply(r.getQ0())).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))),
|
||||
q0.multiply(r.getQ3()).add(q3.multiply(r.getQ0())).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))),
|
||||
|
@ -1391,7 +1391,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new rotation which is the composition of r by the instance
|
||||
*/
|
||||
public static <T extends RealFieldElement<T>> FieldRotation<T> applyTo(final Rotation r1, final FieldRotation<T> rInner) {
|
||||
return new FieldRotation<T>(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))),
|
||||
return new FieldRotation<>(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))),
|
||||
rInner.q1.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ1())).add(rInner.q2.multiply(r1.getQ3()).subtract(rInner.q3.multiply(r1.getQ2()))),
|
||||
rInner.q2.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ1()).subtract(rInner.q1.multiply(r1.getQ3()))),
|
||||
rInner.q3.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ3())).add(rInner.q1.multiply(r1.getQ2()).subtract(rInner.q2.multiply(r1.getQ1()))),
|
||||
|
@ -1450,7 +1450,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
* of the instance using vector operator convention
|
||||
*/
|
||||
private FieldRotation<T> composeInverseInternal(FieldRotation<T> r) {
|
||||
return new FieldRotation<T>(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(),
|
||||
return new FieldRotation<>(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(),
|
||||
r.q0.multiply(q1).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))).subtract(r.q1.multiply(q0)),
|
||||
r.q0.multiply(q2).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))).subtract(r.q2.multiply(q0)),
|
||||
r.q0.multiply(q3).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))).subtract(r.q3.multiply(q0)),
|
||||
|
@ -1509,7 +1509,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
* of the instance using vector operator convention
|
||||
*/
|
||||
private FieldRotation<T> composeInverseInternal(Rotation r) {
|
||||
return new FieldRotation<T>(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(),
|
||||
return new FieldRotation<>(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(),
|
||||
q1.multiply(r.getQ0()).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))).subtract(q0.multiply(r.getQ1())),
|
||||
q2.multiply(r.getQ0()).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))).subtract(q0.multiply(r.getQ2())),
|
||||
q3.multiply(r.getQ0()).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))).subtract(q0.multiply(r.getQ3())),
|
||||
|
@ -1530,7 +1530,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
|
|||
* of the instance
|
||||
*/
|
||||
public static <T extends RealFieldElement<T>> FieldRotation<T> applyInverseTo(final Rotation rOuter, final FieldRotation<T> rInner) {
|
||||
return new FieldRotation<T>(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(),
|
||||
return new FieldRotation<>(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(),
|
||||
rInner.q0.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ3()).subtract(rInner.q3.multiply(rOuter.getQ2()))).subtract(rInner.q1.multiply(rOuter.getQ0())),
|
||||
rInner.q0.multiply(rOuter.getQ2()).add(rInner.q3.multiply(rOuter.getQ1()).subtract(rInner.q1.multiply(rOuter.getQ3()))).subtract(rInner.q2.multiply(rOuter.getQ0())),
|
||||
rInner.q0.multiply(rOuter.getQ3()).add(rInner.q1.multiply(rOuter.getQ2()).subtract(rInner.q2.multiply(rOuter.getQ1()))).subtract(rInner.q3.multiply(rOuter.getQ0())),
|
||||
|
|
|
@ -408,7 +408,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> add(final FieldVector3D<T> v) {
|
||||
return new FieldVector3D<T>(x.add(v.x), y.add(v.y), z.add(v.z));
|
||||
return new FieldVector3D<>(x.add(v.x), y.add(v.y), z.add(v.z));
|
||||
}
|
||||
|
||||
/** Add a vector to the instance.
|
||||
|
@ -416,7 +416,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> add(final Vector3D v) {
|
||||
return new FieldVector3D<T>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ()));
|
||||
return new FieldVector3D<>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ()));
|
||||
}
|
||||
|
||||
/** Add a scaled vector to the instance.
|
||||
|
@ -425,7 +425,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> add(final T factor, final FieldVector3D<T> v) {
|
||||
return new FieldVector3D<T>(x.getField().getOne(), this, factor, v);
|
||||
return new FieldVector3D<>(x.getField().getOne(), this, factor, v);
|
||||
}
|
||||
|
||||
/** Add a scaled vector to the instance.
|
||||
|
@ -434,7 +434,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> add(final T factor, final Vector3D v) {
|
||||
return new FieldVector3D<T>(x.add(factor.multiply(v.getX())),
|
||||
return new FieldVector3D<>(x.add(factor.multiply(v.getX())),
|
||||
y.add(factor.multiply(v.getY())),
|
||||
z.add(factor.multiply(v.getZ())));
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> add(final double factor, final FieldVector3D<T> v) {
|
||||
return new FieldVector3D<T>(1.0, this, factor, v);
|
||||
return new FieldVector3D<>(1.0, this, factor, v);
|
||||
}
|
||||
|
||||
/** Add a scaled vector to the instance.
|
||||
|
@ -454,7 +454,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> add(final double factor, final Vector3D v) {
|
||||
return new FieldVector3D<T>(x.add(factor * v.getX()),
|
||||
return new FieldVector3D<>(x.add(factor * v.getX()),
|
||||
y.add(factor * v.getY()),
|
||||
z.add(factor * v.getZ()));
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> subtract(final FieldVector3D<T> v) {
|
||||
return new FieldVector3D<T>(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z));
|
||||
return new FieldVector3D<>(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z));
|
||||
}
|
||||
|
||||
/** Subtract a vector from the instance.
|
||||
|
@ -472,7 +472,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> subtract(final Vector3D v) {
|
||||
return new FieldVector3D<T>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ()));
|
||||
return new FieldVector3D<>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ()));
|
||||
}
|
||||
|
||||
/** Subtract a scaled vector from the instance.
|
||||
|
@ -481,7 +481,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> subtract(final T factor, final FieldVector3D<T> v) {
|
||||
return new FieldVector3D<T>(x.getField().getOne(), this, factor.negate(), v);
|
||||
return new FieldVector3D<>(x.getField().getOne(), this, factor.negate(), v);
|
||||
}
|
||||
|
||||
/** Subtract a scaled vector from the instance.
|
||||
|
@ -490,7 +490,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> subtract(final T factor, final Vector3D v) {
|
||||
return new FieldVector3D<T>(x.subtract(factor.multiply(v.getX())),
|
||||
return new FieldVector3D<>(x.subtract(factor.multiply(v.getX())),
|
||||
y.subtract(factor.multiply(v.getY())),
|
||||
z.subtract(factor.multiply(v.getZ())));
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> subtract(final double factor, final FieldVector3D<T> v) {
|
||||
return new FieldVector3D<T>(1.0, this, -factor, v);
|
||||
return new FieldVector3D<>(1.0, this, -factor, v);
|
||||
}
|
||||
|
||||
/** Subtract a scaled vector from the instance.
|
||||
|
@ -510,7 +510,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> subtract(final double factor, final Vector3D v) {
|
||||
return new FieldVector3D<T>(x.subtract(factor * v.getX()),
|
||||
return new FieldVector3D<>(x.subtract(factor * v.getX()),
|
||||
y.subtract(factor * v.getY()),
|
||||
z.subtract(factor * v.getZ()));
|
||||
}
|
||||
|
@ -551,13 +551,13 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
|
||||
if (FastMath.abs(x.getReal()) <= threshold) {
|
||||
final T inverse = y.multiply(y).add(z.multiply(z)).sqrt().reciprocal();
|
||||
return new FieldVector3D<T>(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate());
|
||||
return new FieldVector3D<>(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate());
|
||||
} else if (FastMath.abs(y.getReal()) <= threshold) {
|
||||
final T inverse = x.multiply(x).add(z.multiply(z)).sqrt().reciprocal();
|
||||
return new FieldVector3D<T>(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x));
|
||||
return new FieldVector3D<>(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x));
|
||||
} else {
|
||||
final T inverse = x.multiply(x).add(y.multiply(y)).sqrt().reciprocal();
|
||||
return new FieldVector3D<T>(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero());
|
||||
return new FieldVector3D<>(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector which is opposite to the instance
|
||||
*/
|
||||
public FieldVector3D<T> negate() {
|
||||
return new FieldVector3D<T>(x.negate(), y.negate(), z.negate());
|
||||
return new FieldVector3D<>(x.negate(), y.negate(), z.negate());
|
||||
}
|
||||
|
||||
/** Multiply the instance by a scalar.
|
||||
|
@ -663,7 +663,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> scalarMultiply(final T a) {
|
||||
return new FieldVector3D<T>(x.multiply(a), y.multiply(a), z.multiply(a));
|
||||
return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a));
|
||||
}
|
||||
|
||||
/** Multiply the instance by a scalar.
|
||||
|
@ -671,7 +671,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return a new vector
|
||||
*/
|
||||
public FieldVector3D<T> scalarMultiply(final double a) {
|
||||
return new FieldVector3D<T>(x.multiply(a), y.multiply(a), z.multiply(a));
|
||||
return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -779,7 +779,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return the cross product this ^ v as a new Vector3D
|
||||
*/
|
||||
public FieldVector3D<T> crossProduct(final FieldVector3D<T> v) {
|
||||
return new FieldVector3D<T>(x.linearCombination(y, v.z, z.negate(), v.y),
|
||||
return new FieldVector3D<>(x.linearCombination(y, v.z, z.negate(), v.y),
|
||||
y.linearCombination(z, v.x, x.negate(), v.z),
|
||||
z.linearCombination(x, v.y, y.negate(), v.x));
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
* @return the cross product this ^ v as a new Vector3D
|
||||
*/
|
||||
public FieldVector3D<T> crossProduct(final Vector3D v) {
|
||||
return new FieldVector3D<T>(x.linearCombination(v.getZ(), y, -v.getY(), z),
|
||||
return new FieldVector3D<>(x.linearCombination(v.getZ(), y, -v.getY(), z),
|
||||
y.linearCombination(v.getX(), z, -v.getZ(), x),
|
||||
z.linearCombination(v.getY(), x, -v.getX(), y));
|
||||
}
|
||||
|
@ -993,7 +993,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
|
|||
*/
|
||||
public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final Vector3D v1,
|
||||
final FieldVector3D<T> v2) {
|
||||
return new FieldVector3D<T>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y),
|
||||
return new FieldVector3D<>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y),
|
||||
v2.y.linearCombination(v1.getZ(), v2.x, -v1.getX(), v2.z),
|
||||
v2.z.linearCombination(v1.getX(), v2.y, -v1.getY(), v2.x));
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ public class OutlineExtractor {
|
|||
}
|
||||
|
||||
// compute the projection of the facet in the outline plane
|
||||
final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<SubHyperplane<Euclidean2D>>();
|
||||
final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>();
|
||||
for (Vector2D[] loop : vertices) {
|
||||
final boolean closed = loop[0] != null;
|
||||
int previous = closed ? (loop.length - 1) : 1;
|
||||
|
|
|
@ -162,7 +162,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
final double tolerance) {
|
||||
if ((xMin >= xMax - tolerance) || (yMin >= yMax - tolerance) || (zMin >= zMax - tolerance)) {
|
||||
// too thin box, build an empty polygons set
|
||||
return new BSPTree<Euclidean3D>(Boolean.FALSE);
|
||||
return new BSPTree<>(Boolean.FALSE);
|
||||
}
|
||||
final Plane pxMin = new Plane(new Vector3D(xMin, 0, 0), Vector3D.MINUS_I, tolerance);
|
||||
final Plane pxMax = new Plane(new Vector3D(xMax, 0, 0), Vector3D.PLUS_I, tolerance);
|
||||
|
@ -226,7 +226,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
}
|
||||
}
|
||||
|
||||
final List<SubHyperplane<Euclidean3D>> boundary = new ArrayList<SubHyperplane<Euclidean3D>>();
|
||||
final List<SubHyperplane<Euclidean3D>> boundary = new ArrayList<>();
|
||||
|
||||
for (final int[] facet : facets) {
|
||||
|
||||
|
|
|
@ -37,15 +37,15 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector
|
|||
public EnclosingBall<Euclidean3D, Vector3D> ballOnSupport(final List<Vector3D> support) {
|
||||
|
||||
if (support.size() < 1) {
|
||||
return new EnclosingBall<Euclidean3D, Vector3D>(Vector3D.ZERO, Double.NEGATIVE_INFINITY);
|
||||
return new EnclosingBall<>(Vector3D.ZERO, Double.NEGATIVE_INFINITY);
|
||||
} else {
|
||||
final Vector3D vA = support.get(0);
|
||||
if (support.size() < 2) {
|
||||
return new EnclosingBall<Euclidean3D, Vector3D>(vA, 0, vA);
|
||||
return new EnclosingBall<>(vA, 0, vA);
|
||||
} else {
|
||||
final Vector3D vB = support.get(1);
|
||||
if (support.size() < 3) {
|
||||
return new EnclosingBall<Euclidean3D, Vector3D>(new Vector3D(0.5, vA, 0.5, vB),
|
||||
return new EnclosingBall<>(new Vector3D(0.5, vA, 0.5, vB),
|
||||
0.5 * vA.distance(vB),
|
||||
vA, vB);
|
||||
} else {
|
||||
|
@ -61,7 +61,7 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector
|
|||
p.toSubSpace(vC)));
|
||||
|
||||
// convert back to 3D
|
||||
return new EnclosingBall<Euclidean3D, Vector3D>(p.toSpace(disk.getCenter()),
|
||||
return new EnclosingBall<>(p.toSpace(disk.getCenter()),
|
||||
disk.getRadius(), vA, vB, vC);
|
||||
|
||||
} else {
|
||||
|
@ -118,7 +118,7 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector
|
|||
final BigFraction dy = c3[0].subtract(centerY);
|
||||
final BigFraction dz = c4[0].subtract(centerZ);
|
||||
final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz));
|
||||
return new EnclosingBall<Euclidean3D, Vector3D>(new Vector3D(centerX.doubleValue(),
|
||||
return new EnclosingBall<>(new Vector3D(centerX.doubleValue(),
|
||||
centerY.doubleValue(),
|
||||
centerZ.doubleValue()),
|
||||
FastMath.sqrt(r2.doubleValue()),
|
||||
|
|
|
@ -85,7 +85,7 @@ public class SubLine {
|
|||
public List<Segment> getSegments() {
|
||||
|
||||
final List<Interval> list = remainingRegion.asList();
|
||||
final List<Segment> segments = new ArrayList<Segment>(list.size());
|
||||
final List<Segment> segments = new ArrayList<>(list.size());
|
||||
|
||||
for (final Interval interval : list) {
|
||||
final Vector3D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf()));
|
||||
|
|
|
@ -67,11 +67,11 @@ public class SubPlane extends AbstractSubHyperplane<Euclidean3D, Euclidean2D> {
|
|||
// the hyperplanes are parallel
|
||||
final double global = otherPlane.getOffset(thisPlane);
|
||||
if (global < -tolerance) {
|
||||
return new SplitSubHyperplane<Euclidean3D>(null, this);
|
||||
return new SplitSubHyperplane<>(null, this);
|
||||
} else if (global > tolerance) {
|
||||
return new SplitSubHyperplane<Euclidean3D>(this, null);
|
||||
return new SplitSubHyperplane<>(this, null);
|
||||
} else {
|
||||
return new SplitSubHyperplane<Euclidean3D>(null, null);
|
||||
return new SplitSubHyperplane<>(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,15 +92,15 @@ public class SubPlane extends AbstractSubHyperplane<Euclidean3D, Euclidean2D> {
|
|||
final BSPTree<Euclidean2D> splitTree = getRemainingRegion().getTree(false).split(l2DMinus);
|
||||
final BSPTree<Euclidean2D> plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ?
|
||||
new BSPTree<Euclidean2D>(Boolean.FALSE) :
|
||||
new BSPTree<Euclidean2D>(l2DPlus, new BSPTree<Euclidean2D>(Boolean.FALSE),
|
||||
new BSPTree<>(l2DPlus, new BSPTree<Euclidean2D>(Boolean.FALSE),
|
||||
splitTree.getPlus(), null);
|
||||
|
||||
final BSPTree<Euclidean2D> minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ?
|
||||
new BSPTree<Euclidean2D>(Boolean.FALSE) :
|
||||
new BSPTree<Euclidean2D>(l2DMinus, new BSPTree<Euclidean2D>(Boolean.FALSE),
|
||||
new BSPTree<>(l2DMinus, new BSPTree<Euclidean2D>(Boolean.FALSE),
|
||||
splitTree.getMinus(), null);
|
||||
|
||||
return new SplitSubHyperplane<Euclidean3D>(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)),
|
||||
return new SplitSubHyperplane<>(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)),
|
||||
new SubPlane(thisPlane.copySelf(), new PolygonsSet(minusTree, tolerance)));
|
||||
|
||||
}
|
||||
|
|
|
@ -33,15 +33,15 @@ public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Vector2D
|
|||
public EnclosingBall<Euclidean2D, Vector2D> ballOnSupport(final List<Vector2D> support) {
|
||||
|
||||
if (support.size() < 1) {
|
||||
return new EnclosingBall<Euclidean2D, Vector2D>(Vector2D.ZERO, Double.NEGATIVE_INFINITY);
|
||||
return new EnclosingBall<>(Vector2D.ZERO, Double.NEGATIVE_INFINITY);
|
||||
} else {
|
||||
final Vector2D vA = support.get(0);
|
||||
if (support.size() < 2) {
|
||||
return new EnclosingBall<Euclidean2D, Vector2D>(vA, 0, vA);
|
||||
return new EnclosingBall<>(vA, 0, vA);
|
||||
} else {
|
||||
final Vector2D vB = support.get(1);
|
||||
if (support.size() < 3) {
|
||||
return new EnclosingBall<Euclidean2D, Vector2D>(new Vector2D(0.5, vA, 0.5, vB),
|
||||
return new EnclosingBall<>(new Vector2D(0.5, vA, 0.5, vB),
|
||||
0.5 * vA.distance(vB),
|
||||
vA, vB);
|
||||
} else {
|
||||
|
@ -86,7 +86,7 @@ public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Vector2D
|
|||
final BigFraction dx = c2[0].subtract(centerX);
|
||||
final BigFraction dy = c3[0].subtract(centerY);
|
||||
final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy));
|
||||
return new EnclosingBall<Euclidean2D, Vector2D>(new Vector2D(centerX.doubleValue(),
|
||||
return new EnclosingBall<>(new Vector2D(centerX.doubleValue(),
|
||||
centerY.doubleValue()),
|
||||
FastMath.sqrt(r2.doubleValue()),
|
||||
vA, vB, vC);
|
||||
|
|
|
@ -71,7 +71,7 @@ class NestedLoops {
|
|||
* @since 3.3
|
||||
*/
|
||||
NestedLoops(final double tolerance) {
|
||||
this.surrounded = new ArrayList<NestedLoops>();
|
||||
this.surrounded = new ArrayList<>();
|
||||
this.tolerance = tolerance;
|
||||
}
|
||||
|
||||
|
@ -90,11 +90,11 @@ class NestedLoops {
|
|||
}
|
||||
|
||||
this.loop = loop;
|
||||
this.surrounded = new ArrayList<NestedLoops>();
|
||||
this.surrounded = new ArrayList<>();
|
||||
this.tolerance = tolerance;
|
||||
|
||||
// build the polygon defined by the loop
|
||||
final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<SubHyperplane<Euclidean2D>>();
|
||||
final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>();
|
||||
Vector2D current = loop[loop.length - 1];
|
||||
for (int i = 0; i < loop.length; ++i) {
|
||||
final Vector2D previous = current;
|
||||
|
@ -152,7 +152,7 @@ class NestedLoops {
|
|||
}
|
||||
|
||||
// we should be separate from the remaining children
|
||||
RegionFactory<Euclidean2D> factory = new RegionFactory<Euclidean2D>();
|
||||
RegionFactory<Euclidean2D> factory = new RegionFactory<>();
|
||||
for (final NestedLoops child : surrounded) {
|
||||
if (!factory.intersection(node.polygon, child.polygon).isEmpty()) {
|
||||
throw new MathIllegalArgumentException(LocalizedFormats.CROSSING_BOUNDARY_LOOPS);
|
||||
|
|
|
@ -199,7 +199,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
final int n = vertices.length;
|
||||
if (n == 0) {
|
||||
// the tree represents the whole space
|
||||
return new BSPTree<Euclidean2D>(Boolean.TRUE);
|
||||
return new BSPTree<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
// build the vertices
|
||||
|
@ -209,7 +209,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
}
|
||||
|
||||
// build the edges
|
||||
List<Edge> edges = new ArrayList<Edge>(n);
|
||||
List<Edge> edges = new ArrayList<>(n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
||||
// get the endpoints of the edge
|
||||
|
@ -238,7 +238,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
}
|
||||
|
||||
// build the tree top-down
|
||||
final BSPTree<Euclidean2D> tree = new BSPTree<Euclidean2D>();
|
||||
final BSPTree<Euclidean2D> tree = new BSPTree<>();
|
||||
insertEdges(hyperplaneThickness, tree, edges);
|
||||
|
||||
return tree;
|
||||
|
@ -287,8 +287,8 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
|
||||
// we have split the node by inserting an edge as a cut sub-hyperplane
|
||||
// distribute the remaining edges in the two sub-trees
|
||||
final List<Edge> plusList = new ArrayList<Edge>();
|
||||
final List<Edge> minusList = new ArrayList<Edge>();
|
||||
final List<Edge> plusList = new ArrayList<>();
|
||||
final List<Edge> minusList = new ArrayList<>();
|
||||
for (final Edge edge : edges) {
|
||||
if (edge != inserted) {
|
||||
final double startOffset = inserted.getLine().getOffset((Point<Euclidean2D>) edge.getStart().getLocation());
|
||||
|
@ -365,7 +365,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
this.location = location;
|
||||
this.incoming = null;
|
||||
this.outgoing = null;
|
||||
this.lines = new ArrayList<Line>();
|
||||
this.lines = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** Get Vertex location.
|
||||
|
@ -640,7 +640,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
}
|
||||
|
||||
// create the segment loops
|
||||
final ArrayList<List<Segment>> loops = new ArrayList<List<Segment>>();
|
||||
final ArrayList<List<Segment>> loops = new ArrayList<>();
|
||||
for (ConnectableSegment s = getUnprocessed(segments); s != null; s = getUnprocessed(segments)) {
|
||||
final List<Segment> loop = followLoop(s);
|
||||
if (loop != null) {
|
||||
|
@ -824,7 +824,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
*/
|
||||
private List<Segment> followLoop(final ConnectableSegment defining) {
|
||||
|
||||
final List<Segment> loop = new ArrayList<Segment>();
|
||||
final List<Segment> loop = new ArrayList<>();
|
||||
loop.add(defining);
|
||||
defining.setProcessed(true);
|
||||
|
||||
|
@ -998,7 +998,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
*/
|
||||
SegmentsBuilder(final double tolerance) {
|
||||
this.tolerance = tolerance;
|
||||
this.segments = new ArrayList<ConnectableSegment>();
|
||||
this.segments = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -83,7 +83,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
|
||||
final Line line = (Line) getHyperplane();
|
||||
final List<Interval> list = ((IntervalsSet) getRemainingRegion()).asList();
|
||||
final List<Segment> segments = new ArrayList<Segment>(list.size());
|
||||
final List<Segment> segments = new ArrayList<>(list.size());
|
||||
|
||||
for (final Interval interval : list) {
|
||||
final Vector2D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf()));
|
||||
|
@ -168,11 +168,11 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
// the lines are parallel
|
||||
final double global = otherLine.getOffset(thisLine);
|
||||
if (global < -tolerance) {
|
||||
return new SplitSubHyperplane<Euclidean2D>(null, this);
|
||||
return new SplitSubHyperplane<>(null, this);
|
||||
} else if (global > tolerance) {
|
||||
return new SplitSubHyperplane<Euclidean2D>(this, null);
|
||||
return new SplitSubHyperplane<>(this, null);
|
||||
} else {
|
||||
return new SplitSubHyperplane<Euclidean2D>(null, null);
|
||||
return new SplitSubHyperplane<>(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,13 +187,13 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
final BSPTree<Euclidean1D> splitTree = getRemainingRegion().getTree(false).split(subMinus);
|
||||
final BSPTree<Euclidean1D> plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ?
|
||||
new BSPTree<Euclidean1D>(Boolean.FALSE) :
|
||||
new BSPTree<Euclidean1D>(subPlus, new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
new BSPTree<>(subPlus, new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
splitTree.getPlus(), null);
|
||||
final BSPTree<Euclidean1D> minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ?
|
||||
new BSPTree<Euclidean1D>(Boolean.FALSE) :
|
||||
new BSPTree<Euclidean1D>(subMinus, new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
new BSPTree<>(subMinus, new BSPTree<Euclidean1D>(Boolean.FALSE),
|
||||
splitTree.getMinus(), null);
|
||||
return new SplitSubHyperplane<Euclidean2D>(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)),
|
||||
return new SplitSubHyperplane<>(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)),
|
||||
new SubLine(thisLine.copySelf(), new IntervalsSet(minusTree, tolerance)));
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public final class AklToussaintHeuristic {
|
|||
return points;
|
||||
}
|
||||
|
||||
final List<Vector2D> reducedPoints = new ArrayList<Vector2D>(quadrilateral);
|
||||
final List<Vector2D> reducedPoints = new ArrayList<>(quadrilateral);
|
||||
for (final Vector2D p : points) {
|
||||
// check all points if they are within the quadrilateral
|
||||
// in which case they can not be part of the convex hull
|
||||
|
@ -103,7 +103,7 @@ public final class AklToussaintHeuristic {
|
|||
* @return the quadrilateral
|
||||
*/
|
||||
private static List<Vector2D> buildQuadrilateral(final Vector2D... points) {
|
||||
List<Vector2D> quadrilateral = new ArrayList<Vector2D>();
|
||||
List<Vector2D> quadrilateral = new ArrayList<>();
|
||||
for (Vector2D p : points) {
|
||||
if (!quadrilateral.contains(p)) {
|
||||
quadrilateral.add(p);
|
||||
|
|
|
@ -163,7 +163,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Vector2D>, Serializ
|
|||
if (vertices.length < 3) {
|
||||
throw new InsufficientDataException();
|
||||
}
|
||||
final RegionFactory<Euclidean2D> factory = new RegionFactory<Euclidean2D>();
|
||||
final RegionFactory<Euclidean2D> factory = new RegionFactory<>();
|
||||
final Segment[] segments = retrieveLineSegments();
|
||||
final Line[] lineArray = new Line[segments.length];
|
||||
for (int i = 0; i < segments.length; i++) {
|
||||
|
|
|
@ -77,7 +77,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
|
|||
@Override
|
||||
public Collection<Vector2D> findHullVertices(final Collection<Vector2D> points) {
|
||||
|
||||
final List<Vector2D> pointsSortedByXAxis = new ArrayList<Vector2D>(points);
|
||||
final List<Vector2D> pointsSortedByXAxis = new ArrayList<>(points);
|
||||
|
||||
// sort the points in increasing order on the x-axis
|
||||
Collections.sort(pointsSortedByXAxis, new Comparator<Vector2D>() {
|
||||
|
@ -97,13 +97,13 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
|
|||
});
|
||||
|
||||
// build lower hull
|
||||
final List<Vector2D> lowerHull = new ArrayList<Vector2D>();
|
||||
final List<Vector2D> lowerHull = new ArrayList<>();
|
||||
for (Vector2D p : pointsSortedByXAxis) {
|
||||
updateHull(p, lowerHull);
|
||||
}
|
||||
|
||||
// build upper hull
|
||||
final List<Vector2D> upperHull = new ArrayList<Vector2D>();
|
||||
final List<Vector2D> upperHull = new ArrayList<>();
|
||||
for (int idx = pointsSortedByXAxis.size() - 1; idx >= 0; idx--) {
|
||||
final Vector2D p = pointsSortedByXAxis.get(idx);
|
||||
updateHull(p, upperHull);
|
||||
|
@ -111,7 +111,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
|
|||
|
||||
// concatenate the lower and upper hulls
|
||||
// the last point of each list is omitted as it is repeated at the beginning of the other list
|
||||
final List<Vector2D> hullVertices = new ArrayList<Vector2D>(lowerHull.size() + upperHull.size() - 2);
|
||||
final List<Vector2D> hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2);
|
||||
for (int idx = 0; idx < lowerHull.size() - 1; idx++) {
|
||||
hullVertices.add(lowerHull.get(idx));
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
* @param tolerance tolerance below which points are considered identical.
|
||||
*/
|
||||
protected AbstractRegion(final double tolerance) {
|
||||
this.tree = new BSPTree<S>(Boolean.TRUE);
|
||||
this.tree = new BSPTree<>(Boolean.TRUE);
|
||||
this.tolerance = tolerance;
|
||||
}
|
||||
|
||||
|
@ -102,14 +102,14 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
if (boundary.size() == 0) {
|
||||
|
||||
// the tree represents the whole space
|
||||
tree = new BSPTree<S>(Boolean.TRUE);
|
||||
tree = new BSPTree<>(Boolean.TRUE);
|
||||
|
||||
} else {
|
||||
|
||||
// sort the boundary elements in decreasing size order
|
||||
// (we don't want equal size elements to be removed, so
|
||||
// we use a trick to fool the TreeSet)
|
||||
final TreeSet<SubHyperplane<S>> ordered = new TreeSet<SubHyperplane<S>>(new Comparator<SubHyperplane<S>>() {
|
||||
final TreeSet<SubHyperplane<S>> ordered = new TreeSet<>(new Comparator<SubHyperplane<S>>() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int compare(final SubHyperplane<S> o1, final SubHyperplane<S> o2) {
|
||||
|
@ -121,7 +121,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
ordered.addAll(boundary);
|
||||
|
||||
// build the tree top-down
|
||||
tree = new BSPTree<S>();
|
||||
tree = new BSPTree<>();
|
||||
insertCuts(tree, ordered);
|
||||
|
||||
// set up the inside/outside flags
|
||||
|
@ -161,7 +161,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
public AbstractRegion(final Hyperplane<S>[] hyperplanes, final double tolerance) {
|
||||
this.tolerance = tolerance;
|
||||
if ((hyperplanes == null) || (hyperplanes.length == 0)) {
|
||||
tree = new BSPTree<S>(Boolean.FALSE);
|
||||
tree = new BSPTree<>(Boolean.FALSE);
|
||||
} else {
|
||||
|
||||
// use the first hyperplane to build the right class
|
||||
|
@ -218,8 +218,8 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
}
|
||||
|
||||
// distribute the remaining edges in the two sub-trees
|
||||
final ArrayList<SubHyperplane<S>> plusList = new ArrayList<SubHyperplane<S>>();
|
||||
final ArrayList<SubHyperplane<S>> minusList = new ArrayList<SubHyperplane<S>>();
|
||||
final ArrayList<SubHyperplane<S>> plusList = new ArrayList<>();
|
||||
final ArrayList<SubHyperplane<S>> minusList = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
final SubHyperplane<S> other = iterator.next();
|
||||
final SubHyperplane.SplitSubHyperplane<S> split = other.split(inserted);
|
||||
|
@ -310,7 +310,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
*/
|
||||
@Override
|
||||
public BoundaryProjection<S> projectToBoundary(final Point<S> point) {
|
||||
final BoundaryProjector<S, T> projector = new BoundaryProjector<S, T>(point);
|
||||
final BoundaryProjector<S, T> projector = new BoundaryProjector<>(point);
|
||||
getTree(true).visit(projector);
|
||||
return projector.getProjection();
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getBoundarySize() {
|
||||
final BoundarySizeVisitor<S> visitor = new BoundarySizeVisitor<S>();
|
||||
final BoundarySizeVisitor<S> visitor = new BoundarySizeVisitor<>();
|
||||
getTree(true).visit(visitor);
|
||||
return visitor.getSize();
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
public AbstractRegion<S, T> applyTransform(final Transform<S, T> transform) {
|
||||
|
||||
// transform the tree, except for boundary attribute splitters
|
||||
final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<BSPTree<S>, BSPTree<S>>();
|
||||
final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<>();
|
||||
final BSPTree<S> transformedTree = recurseTransform(getTree(false), transform, map);
|
||||
|
||||
// set up the boundary attributes splitters
|
||||
|
@ -519,7 +519,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
|
||||
final BSPTree<S> transformedNode;
|
||||
if (node.getCut() == null) {
|
||||
transformedNode = new BSPTree<S>(node.getAttribute());
|
||||
transformedNode = new BSPTree<>(node.getAttribute());
|
||||
} else {
|
||||
|
||||
final SubHyperplane<S> sub = node.getCut();
|
||||
|
@ -531,10 +531,10 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
final SubHyperplane<S> tPI = (attribute.getPlusInside() == null) ?
|
||||
null : ((AbstractSubHyperplane<S, T>) attribute.getPlusInside()).applyTransform(transform);
|
||||
// we start with an empty list of splitters, it will be filled in out of recursion
|
||||
attribute = new BoundaryAttribute<S>(tPO, tPI, new NodesSet<S>());
|
||||
attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet<S>());
|
||||
}
|
||||
|
||||
transformedNode = new BSPTree<S>(tSub,
|
||||
transformedNode = new BSPTree<>(tSub,
|
||||
recurseTransform(node.getPlus(), transform, map),
|
||||
recurseTransform(node.getMinus(), transform, map),
|
||||
attribute);
|
||||
|
|
|
@ -116,7 +116,7 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space>
|
|||
final Hyperplane<S> tHyperplane = transform.apply(hyperplane);
|
||||
|
||||
// transform the tree, except for boundary attribute splitters
|
||||
final Map<BSPTree<T>, BSPTree<T>> map = new HashMap<BSPTree<T>, BSPTree<T>>();
|
||||
final Map<BSPTree<T>, BSPTree<T>> map = new HashMap<>();
|
||||
final BSPTree<T> tTree =
|
||||
recurseTransform(remainingRegion.getTree(false), tHyperplane, transform, map);
|
||||
|
||||
|
@ -153,7 +153,7 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space>
|
|||
|
||||
final BSPTree<T> transformedNode;
|
||||
if (node.getCut() == null) {
|
||||
transformedNode = new BSPTree<T>(node.getAttribute());
|
||||
transformedNode = new BSPTree<>(node.getAttribute());
|
||||
} else {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -164,10 +164,10 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space>
|
|||
final SubHyperplane<T> tPI = (attribute.getPlusInside() == null) ?
|
||||
null : transform.apply(attribute.getPlusInside(), hyperplane, transformed);
|
||||
// we start with an empty list of splitters, it will be filled in out of recursion
|
||||
attribute = new BoundaryAttribute<T>(tPO, tPI, new NodesSet<T>());
|
||||
attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet<T>());
|
||||
}
|
||||
|
||||
transformedNode = new BSPTree<T>(transform.apply(node.getCut(), hyperplane, transformed),
|
||||
transformedNode = new BSPTree<>(transform.apply(node.getCut(), hyperplane, transformed),
|
||||
recurseTransform(node.getPlus(), transformed, transform, map),
|
||||
recurseTransform(node.getMinus(), transformed, transform, map),
|
||||
attribute);
|
||||
|
|
|
@ -163,9 +163,9 @@ public class BSPTree<S extends Space> {
|
|||
}
|
||||
|
||||
cut = chopped;
|
||||
plus = new BSPTree<S>();
|
||||
plus = new BSPTree<>();
|
||||
plus.parent = this;
|
||||
minus = new BSPTree<S>();
|
||||
minus = new BSPTree<>();
|
||||
minus.parent = this;
|
||||
return true;
|
||||
|
||||
|
@ -181,10 +181,10 @@ public class BSPTree<S extends Space> {
|
|||
public BSPTree<S> copySelf() {
|
||||
|
||||
if (cut == null) {
|
||||
return new BSPTree<S>(attribute);
|
||||
return new BSPTree<>(attribute);
|
||||
}
|
||||
|
||||
return new BSPTree<S>(cut.copySelf(), plus.copySelf(), minus.copySelf(),
|
||||
return new BSPTree<>(cut.copySelf(), plus.copySelf(), minus.copySelf(),
|
||||
attribute);
|
||||
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ public class BSPTree<S extends Space> {
|
|||
* than maxOffset from the point)
|
||||
*/
|
||||
public List<BSPTree<S>> getCloseCuts(final Point<S> point, final double maxOffset) {
|
||||
final List<BSPTree<S>> close = new ArrayList<BSPTree<S>>();
|
||||
final List<BSPTree<S>> close = new ArrayList<>();
|
||||
recurseCloseCuts(point, maxOffset, close);
|
||||
return close;
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ public class BSPTree<S extends Space> {
|
|||
public BSPTree<S> split(final SubHyperplane<S> sub) {
|
||||
|
||||
if (cut == null) {
|
||||
return new BSPTree<S>(sub, copySelf(), new BSPTree<S>(attribute), null);
|
||||
return new BSPTree<>(sub, copySelf(), new BSPTree<S>(attribute), null);
|
||||
}
|
||||
|
||||
final Hyperplane<S> cHyperplane = cut.getHyperplane();
|
||||
|
@ -566,12 +566,12 @@ public class BSPTree<S extends Space> {
|
|||
final BSPTree<S> split = plus.split(sub);
|
||||
if (cut.split(sHyperplane).getSide() == Side.PLUS) {
|
||||
split.plus =
|
||||
new BSPTree<S>(cut.copySelf(), split.plus, minus.copySelf(), attribute);
|
||||
new BSPTree<>(cut.copySelf(), split.plus, minus.copySelf(), attribute);
|
||||
split.plus.condense();
|
||||
split.plus.parent = split;
|
||||
} else {
|
||||
split.minus =
|
||||
new BSPTree<S>(cut.copySelf(), split.minus, minus.copySelf(), attribute);
|
||||
new BSPTree<>(cut.copySelf(), split.minus, minus.copySelf(), attribute);
|
||||
split.minus.condense();
|
||||
split.minus.parent = split;
|
||||
}
|
||||
|
@ -582,12 +582,12 @@ public class BSPTree<S extends Space> {
|
|||
final BSPTree<S> split = minus.split(sub);
|
||||
if (cut.split(sHyperplane).getSide() == Side.PLUS) {
|
||||
split.plus =
|
||||
new BSPTree<S>(cut.copySelf(), plus.copySelf(), split.plus, attribute);
|
||||
new BSPTree<>(cut.copySelf(), plus.copySelf(), split.plus, attribute);
|
||||
split.plus.condense();
|
||||
split.plus.parent = split;
|
||||
} else {
|
||||
split.minus =
|
||||
new BSPTree<S>(cut.copySelf(), plus.copySelf(), split.minus, attribute);
|
||||
new BSPTree<>(cut.copySelf(), plus.copySelf(), split.minus, attribute);
|
||||
split.minus.condense();
|
||||
split.minus.parent = split;
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ public class BSPTree<S extends Space> {
|
|||
{
|
||||
final SubHyperplane.SplitSubHyperplane<S> cutParts = cut.split(sHyperplane);
|
||||
final BSPTree<S> split =
|
||||
new BSPTree<S>(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()),
|
||||
new BSPTree<>(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()),
|
||||
null);
|
||||
split.plus.cut = cutParts.getPlus();
|
||||
split.minus.cut = cutParts.getMinus();
|
||||
|
@ -612,8 +612,8 @@ public class BSPTree<S extends Space> {
|
|||
}
|
||||
default :
|
||||
return cHyperplane.sameOrientationAs(sHyperplane) ?
|
||||
new BSPTree<S>(sub, plus.copySelf(), minus.copySelf(), attribute) :
|
||||
new BSPTree<S>(sub, minus.copySelf(), plus.copySelf(), attribute);
|
||||
new BSPTree<>(sub, plus.copySelf(), minus.copySelf(), attribute) :
|
||||
new BSPTree<>(sub, minus.copySelf(), plus.copySelf(), attribute);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -710,16 +710,16 @@ public class BSPTree<S extends Space> {
|
|||
final Object internalAttributes) {
|
||||
|
||||
// build the current cell leaf
|
||||
BSPTree<S> tree = new BSPTree<S>(cellAttribute);
|
||||
BSPTree<S> tree = new BSPTree<>(cellAttribute);
|
||||
|
||||
// build the pruned tree bottom-up
|
||||
for (BSPTree<S> current = this; current.parent != null; current = current.parent) {
|
||||
final SubHyperplane<S> parentCut = current.parent.cut.copySelf();
|
||||
final BSPTree<S> sibling = new BSPTree<S>(otherLeafsAttributes);
|
||||
final BSPTree<S> sibling = new BSPTree<>(otherLeafsAttributes);
|
||||
if (current == current.parent.plus) {
|
||||
tree = new BSPTree<S>(parentCut, tree, sibling, internalAttributes);
|
||||
tree = new BSPTree<>(parentCut, tree, sibling, internalAttributes);
|
||||
} else {
|
||||
tree = new BSPTree<S>(parentCut, sibling, tree, internalAttributes);
|
||||
tree = new BSPTree<>(parentCut, sibling, tree, internalAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,18 +44,18 @@ class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> {
|
|||
|
||||
// characterize the cut sub-hyperplane,
|
||||
// first with respect to the plus sub-tree
|
||||
final Characterization<S> plusChar = new Characterization<S>(node.getPlus(), node.getCut().copySelf());
|
||||
final Characterization<S> plusChar = new Characterization<>(node.getPlus(), node.getCut().copySelf());
|
||||
|
||||
if (plusChar.touchOutside()) {
|
||||
// plusChar.outsideTouching() corresponds to a subset of the cut sub-hyperplane
|
||||
// known to have outside cells on its plus side, we want to check if parts
|
||||
// of this subset do have inside cells on their minus side
|
||||
final Characterization<S> minusChar = new Characterization<S>(node.getMinus(), plusChar.outsideTouching());
|
||||
final Characterization<S> minusChar = new Characterization<>(node.getMinus(), plusChar.outsideTouching());
|
||||
if (minusChar.touchInside()) {
|
||||
// this part belongs to the boundary,
|
||||
// it has the outside on its plus side and the inside on its minus side
|
||||
plusOutside = minusChar.insideTouching();
|
||||
splitters = new NodesSet<S>();
|
||||
splitters = new NodesSet<>();
|
||||
splitters.addAll(minusChar.getInsideSplitters());
|
||||
splitters.addAll(plusChar.getOutsideSplitters());
|
||||
}
|
||||
|
@ -65,13 +65,13 @@ class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> {
|
|||
// plusChar.insideTouching() corresponds to a subset of the cut sub-hyperplane
|
||||
// known to have inside cells on its plus side, we want to check if parts
|
||||
// of this subset do have outside cells on their minus side
|
||||
final Characterization<S> minusChar = new Characterization<S>(node.getMinus(), plusChar.insideTouching());
|
||||
final Characterization<S> minusChar = new Characterization<>(node.getMinus(), plusChar.insideTouching());
|
||||
if (minusChar.touchOutside()) {
|
||||
// this part belongs to the boundary,
|
||||
// it has the inside on its plus side and the outside on its minus side
|
||||
plusInside = minusChar.outsideTouching();
|
||||
if (splitters == null) {
|
||||
splitters = new NodesSet<S>();
|
||||
splitters = new NodesSet<>();
|
||||
}
|
||||
splitters.addAll(minusChar.getOutsideSplitters());
|
||||
splitters.addAll(plusChar.getInsideSplitters());
|
||||
|
@ -86,7 +86,7 @@ class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> {
|
|||
}
|
||||
|
||||
// set the boundary attribute at non-leaf nodes
|
||||
node.setAttribute(new BoundaryAttribute<S>(plusOutside, plusInside, splitters));
|
||||
node.setAttribute(new BoundaryAttribute<>(plusOutside, plusInside, splitters));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ class BoundaryProjector<S extends Space, T extends Space> implements BSPTreeVisi
|
|||
// fix offset sign
|
||||
offset = FastMath.copySign(offset, (Boolean) leaf.getAttribute() ? -1 : +1);
|
||||
|
||||
return new BoundaryProjection<S>(original, projected, offset);
|
||||
return new BoundaryProjection<>(original, projected, offset);
|
||||
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class BoundaryProjector<S extends Space, T extends Space> implements BSPTreeVisi
|
|||
*/
|
||||
private List<Region<T>> boundaryRegions(final BSPTree<S> node) {
|
||||
|
||||
final List<Region<T>> regions = new ArrayList<Region<T>>(2);
|
||||
final List<Region<T>> regions = new ArrayList<>(2);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final BoundaryAttribute<S> ba = (BoundaryAttribute<S>) node.getAttribute();
|
||||
|
|
|
@ -56,8 +56,8 @@ class Characterization<S extends Space> {
|
|||
Characterization(final BSPTree<S> node, final SubHyperplane<S> sub) {
|
||||
outsideTouching = null;
|
||||
insideTouching = null;
|
||||
outsideSplitters = new NodesSet<S>();
|
||||
insideSplitters = new NodesSet<S>();
|
||||
outsideSplitters = new NodesSet<>();
|
||||
insideSplitters = new NodesSet<>();
|
||||
characterize(node, sub, new ArrayList<BSPTree<S>>());
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class NodesSet<S extends Space> implements Iterable<BSPTree<S>> {
|
|||
/** Simple constructor.
|
||||
*/
|
||||
public NodesSet() {
|
||||
list = new ArrayList<BSPTree<S>>();
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** Add a node if not already known.
|
||||
|
|
|
@ -176,7 +176,7 @@ public class RegionFactory<S extends Space> {
|
|||
private BSPTree<S> recurseComplement(final BSPTree<S> node) {
|
||||
|
||||
// transform the tree, except for boundary attribute splitters
|
||||
final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<BSPTree<S>, BSPTree<S>>();
|
||||
final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<>();
|
||||
final BSPTree<S> transformedTree = recurseComplement(node, map);
|
||||
|
||||
// set up the boundary attributes splitters
|
||||
|
@ -208,7 +208,7 @@ public class RegionFactory<S extends Space> {
|
|||
|
||||
final BSPTree<S> transformedNode;
|
||||
if (node.getCut() == null) {
|
||||
transformedNode = new BSPTree<S>(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE);
|
||||
transformedNode = new BSPTree<>(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE);
|
||||
} else {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -219,10 +219,10 @@ public class RegionFactory<S extends Space> {
|
|||
final SubHyperplane<S> plusInside =
|
||||
(attribute.getPlusOutside() == null) ? null : attribute.getPlusOutside().copySelf();
|
||||
// we start with an empty list of splitters, it will be filled in out of recursion
|
||||
attribute = new BoundaryAttribute<S>(plusOutside, plusInside, new NodesSet<S>());
|
||||
attribute = new BoundaryAttribute<>(plusOutside, plusInside, new NodesSet<S>());
|
||||
}
|
||||
|
||||
transformedNode = new BSPTree<S>(node.getCut().copySelf(),
|
||||
transformedNode = new BSPTree<>(node.getCut().copySelf(),
|
||||
recurseComplement(node.getPlus(), map),
|
||||
recurseComplement(node.getMinus(), map),
|
||||
attribute);
|
||||
|
@ -330,7 +330,7 @@ public class RegionFactory<S extends Space> {
|
|||
final BSPTree<S> cell = node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null);
|
||||
final Region<S> r = region1.buildNew(cell);
|
||||
final Point<S> p = r.getBarycenter();
|
||||
return new BSPTree<S>(region1.checkPoint(p) == Location.INSIDE &&
|
||||
return new BSPTree<>(region1.checkPoint(p) == Location.INSIDE &&
|
||||
region2.checkPoint(p) == Location.OUTSIDE);
|
||||
}
|
||||
|
||||
|
@ -376,10 +376,10 @@ public class RegionFactory<S extends Space> {
|
|||
public BSPTree<S> fixNode(final BSPTree<S> node) {
|
||||
if (node.getPlus().getAttribute().equals(node.getMinus().getAttribute())) {
|
||||
// no ambiguity
|
||||
return new BSPTree<S>(node.getPlus().getAttribute());
|
||||
return new BSPTree<>(node.getPlus().getAttribute());
|
||||
} else {
|
||||
// ambiguous node
|
||||
return new BSPTree<S>(inside);
|
||||
return new BSPTree<>(inside);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
|
||||
if (Precision.equals(lower, upper, 0) || (upper - lower) >= MathUtils.TWO_PI) {
|
||||
// the tree must cover the whole circle
|
||||
return new BSPTree<Sphere1D>(Boolean.TRUE);
|
||||
return new BSPTree<>(Boolean.TRUE);
|
||||
} else if (lower > upper) {
|
||||
throw new NumberIsTooLargeException(LocalizedFormats.ENDPOINTS_NOT_AN_INTERVAL,
|
||||
lower, upper, true);
|
||||
|
@ -148,9 +148,9 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
// simple arc starting after 0 and ending before 2 \pi
|
||||
final SubHyperplane<Sphere1D> upperCut =
|
||||
new LimitAngle(new S1Point(normalizedUpper), true, tolerance).wholeHyperplane();
|
||||
return new BSPTree<Sphere1D>(lowerCut,
|
||||
return new BSPTree<>(lowerCut,
|
||||
new BSPTree<Sphere1D>(Boolean.FALSE),
|
||||
new BSPTree<Sphere1D>(upperCut,
|
||||
new BSPTree<>(upperCut,
|
||||
new BSPTree<Sphere1D>(Boolean.FALSE),
|
||||
new BSPTree<Sphere1D>(Boolean.TRUE),
|
||||
null),
|
||||
|
@ -159,8 +159,8 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
// arc wrapping around 2 \pi
|
||||
final SubHyperplane<Sphere1D> upperCut =
|
||||
new LimitAngle(new S1Point(normalizedUpper - MathUtils.TWO_PI), true, tolerance).wholeHyperplane();
|
||||
return new BSPTree<Sphere1D>(lowerCut,
|
||||
new BSPTree<Sphere1D>(upperCut,
|
||||
return new BSPTree<>(lowerCut,
|
||||
new BSPTree<>(upperCut,
|
||||
new BSPTree<Sphere1D>(Boolean.FALSE),
|
||||
new BSPTree<Sphere1D>(Boolean.TRUE),
|
||||
null),
|
||||
|
@ -504,9 +504,9 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
final double previousOffset = alpha - previous;
|
||||
final double currentOffset = a[0] - alpha;
|
||||
if (previousOffset < currentOffset) {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(previous), previousOffset);
|
||||
return new BoundaryProjection<>(point, new S1Point(previous), previousOffset);
|
||||
} else {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(a[0]), currentOffset);
|
||||
return new BoundaryProjection<>(point, new S1Point(a[0]), currentOffset);
|
||||
}
|
||||
}
|
||||
} else if (alpha <= a[1]) {
|
||||
|
@ -515,9 +515,9 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
final double offset0 = a[0] - alpha;
|
||||
final double offset1 = alpha - a[1];
|
||||
if (offset0 < offset1) {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(a[1]), offset1);
|
||||
return new BoundaryProjection<>(point, new S1Point(a[1]), offset1);
|
||||
} else {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(a[0]), offset0);
|
||||
return new BoundaryProjection<>(point, new S1Point(a[0]), offset0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
if (Double.isNaN(previous)) {
|
||||
|
||||
// there are no points at all in the arcs set
|
||||
return new BoundaryProjection<Sphere1D>(point, null, MathUtils.TWO_PI);
|
||||
return new BoundaryProjection<>(point, null, MathUtils.TWO_PI);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -538,18 +538,18 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
final double previousOffset = alpha - (previous - MathUtils.TWO_PI);
|
||||
final double currentOffset = first - alpha;
|
||||
if (previousOffset < currentOffset) {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(previous), previousOffset);
|
||||
return new BoundaryProjection<>(point, new S1Point(previous), previousOffset);
|
||||
} else {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(first), currentOffset);
|
||||
return new BoundaryProjection<>(point, new S1Point(first), currentOffset);
|
||||
}
|
||||
} else {
|
||||
// the test point is between last and 2\pi
|
||||
final double previousOffset = alpha - previous;
|
||||
final double currentOffset = first + MathUtils.TWO_PI - alpha;
|
||||
if (previousOffset < currentOffset) {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(previous), previousOffset);
|
||||
return new BoundaryProjection<>(point, new S1Point(previous), previousOffset);
|
||||
} else {
|
||||
return new BoundaryProjection<Sphere1D>(point, new S1Point(first), currentOffset);
|
||||
return new BoundaryProjection<>(point, new S1Point(first), currentOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,7 +565,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
* @return a new ordered list containing {@link Arc Arc} elements
|
||||
*/
|
||||
public List<Arc> asList() {
|
||||
final List<Arc> list = new ArrayList<Arc>();
|
||||
final List<Arc> list = new ArrayList<>();
|
||||
for (final double[] a : this) {
|
||||
list.add(new Arc(a[0], a[1], getTolerance()));
|
||||
}
|
||||
|
@ -724,8 +724,8 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
*/
|
||||
public Split split(final Arc arc) {
|
||||
|
||||
final List<Double> minus = new ArrayList<Double>();
|
||||
final List<Double> plus = new ArrayList<Double>();
|
||||
final List<Double> minus = new ArrayList<>();
|
||||
final List<Double> plus = new ArrayList<>();
|
||||
|
||||
final double reference = FastMath.PI + arc.getInf();
|
||||
final double arcLength = arc.getSup() - arc.getInf();
|
||||
|
@ -861,7 +861,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
|
|||
}
|
||||
|
||||
// build the tree by adding all angular sectors
|
||||
BSPTree<Sphere1D> tree = new BSPTree<Sphere1D>(Boolean.FALSE);
|
||||
BSPTree<Sphere1D> tree = new BSPTree<>(Boolean.FALSE);
|
||||
for (int i = 0; i < limits.size() - 1; i += 2) {
|
||||
addArcLimit(tree, limits.get(i), true);
|
||||
addArcLimit(tree, limits.get(i + 1), false);
|
||||
|
|
|
@ -59,8 +59,8 @@ public class SubLimitAngle extends AbstractSubHyperplane<Sphere1D, Sphere1D> {
|
|||
public SplitSubHyperplane<Sphere1D> split(final Hyperplane<Sphere1D> hyperplane) {
|
||||
final double global = hyperplane.getOffset(((LimitAngle) getHyperplane()).getLocation());
|
||||
return (global < -1.0e-10) ?
|
||||
new SplitSubHyperplane<Sphere1D>(null, this) :
|
||||
new SplitSubHyperplane<Sphere1D>(this, null);
|
||||
new SplitSubHyperplane<>(null, this) :
|
||||
new SplitSubHyperplane<>(this, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
|
|||
EdgesBuilder(final BSPTree<Sphere2D> root, final double tolerance) {
|
||||
this.root = root;
|
||||
this.tolerance = tolerance;
|
||||
this.edgeToNode = new IdentityHashMap<Edge, BSPTree<Sphere2D>>();
|
||||
this.nodeToEdgesList = new IdentityHashMap<BSPTree<Sphere2D>, List<Edge>>();
|
||||
this.edgeToNode = new IdentityHashMap<>();
|
||||
this.nodeToEdgesList = new IdentityHashMap<>();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -165,7 +165,7 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
|
|||
previous.setNextEdge(getFollowingEdge(previous));
|
||||
}
|
||||
|
||||
return new ArrayList<Edge>(edgeToNode.keySet());
|
||||
return new ArrayList<>(edgeToNode.keySet());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
|
|||
this.tolerance = tolerance;
|
||||
this.summedArea = 0;
|
||||
this.summedBarycenter = Vector3D.ZERO;
|
||||
this.convexCellsInsidePoints = new ArrayList<Vector3D>();
|
||||
this.convexCellsInsidePoints = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -59,7 +59,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
* @param tolerance below which points are consider to be identical
|
||||
*/
|
||||
public SphericalPolygonsSet(final Vector3D pole, final double tolerance) {
|
||||
super(new BSPTree<Sphere2D>(new Circle(pole, tolerance).wholeHyperplane(),
|
||||
super(new BSPTree<>(new Circle(pole, tolerance).wholeHyperplane(),
|
||||
new BSPTree<Sphere2D>(Boolean.FALSE),
|
||||
new BSPTree<Sphere2D>(Boolean.TRUE),
|
||||
null),
|
||||
|
@ -198,7 +198,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
final int n = vertices.length;
|
||||
if (n == 0) {
|
||||
// the tree represents the whole space
|
||||
return new BSPTree<Sphere2D>(Boolean.TRUE);
|
||||
return new BSPTree<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
// build the vertices
|
||||
|
@ -208,7 +208,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
}
|
||||
|
||||
// build the edges
|
||||
List<Edge> edges = new ArrayList<Edge>(n);
|
||||
List<Edge> edges = new ArrayList<>(n);
|
||||
Vertex end = vArray[n - 1];
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
||||
|
@ -241,7 +241,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
}
|
||||
|
||||
// build the tree top-down
|
||||
final BSPTree<Sphere2D> tree = new BSPTree<Sphere2D>();
|
||||
final BSPTree<Sphere2D> tree = new BSPTree<>();
|
||||
insertEdges(hyperplaneThickness, tree, edges);
|
||||
|
||||
return tree;
|
||||
|
@ -284,8 +284,8 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
|
||||
// we have split the node by inserting an edge as a cut sub-hyperplane
|
||||
// distribute the remaining edges in the two sub-trees
|
||||
final List<Edge> outsideList = new ArrayList<Edge>();
|
||||
final List<Edge> insideList = new ArrayList<Edge>();
|
||||
final List<Edge> outsideList = new ArrayList<>();
|
||||
final List<Edge> insideList = new ArrayList<>();
|
||||
for (final Edge edge : edges) {
|
||||
if (edge != inserted) {
|
||||
edge.split(inserted.getCircle(), outsideList, insideList);
|
||||
|
@ -384,7 +384,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
|
||||
|
||||
// convert the list of all edges into a list of start vertices
|
||||
loops = new ArrayList<Vertex>();
|
||||
loops = new ArrayList<>();
|
||||
while (!edges.isEmpty()) {
|
||||
|
||||
// this is an edge belonging to a new loop, store it
|
||||
|
@ -468,10 +468,10 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
|
||||
// handle special cases first
|
||||
if (isEmpty()) {
|
||||
return new EnclosingBall<Sphere2D, S2Point>(S2Point.PLUS_K, Double.NEGATIVE_INFINITY);
|
||||
return new EnclosingBall<>(S2Point.PLUS_K, Double.NEGATIVE_INFINITY);
|
||||
}
|
||||
if (isFull()) {
|
||||
return new EnclosingBall<Sphere2D, S2Point>(S2Point.PLUS_K, Double.POSITIVE_INFINITY);
|
||||
return new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
// as the polygons is neither empty nor full, it has some boundaries and cut hyperplanes
|
||||
|
@ -479,13 +479,13 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
if (isEmpty(root.getMinus()) && isFull(root.getPlus())) {
|
||||
// the polygon covers an hemisphere, and its boundary is one 2π long edge
|
||||
final Circle circle = (Circle) root.getCut().getHyperplane();
|
||||
return new EnclosingBall<Sphere2D, S2Point>(new S2Point(circle.getPole()).negate(),
|
||||
return new EnclosingBall<>(new S2Point(circle.getPole()).negate(),
|
||||
0.5 * FastMath.PI);
|
||||
}
|
||||
if (isFull(root.getMinus()) && isEmpty(root.getPlus())) {
|
||||
// the polygon covers an hemisphere, and its boundary is one 2π long edge
|
||||
final Circle circle = (Circle) root.getCut().getHyperplane();
|
||||
return new EnclosingBall<Sphere2D, S2Point>(new S2Point(circle.getPole()),
|
||||
return new EnclosingBall<>(new S2Point(circle.getPole()),
|
||||
0.5 * FastMath.PI);
|
||||
}
|
||||
|
||||
|
@ -505,7 +505,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
// find the smallest enclosing 3D sphere
|
||||
final SphereGenerator generator = new SphereGenerator();
|
||||
final WelzlEncloser<Euclidean3D, Vector3D> encloser =
|
||||
new WelzlEncloser<Euclidean3D, Vector3D>(getTolerance(), generator);
|
||||
new WelzlEncloser<>(getTolerance(), generator);
|
||||
EnclosingBall<Euclidean3D, Vector3D> enclosing3D = encloser.enclose(points);
|
||||
final Vector3D[] support3D = enclosing3D.getSupport();
|
||||
|
||||
|
@ -516,12 +516,12 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
// the 3D sphere is centered on the unit sphere and covers it
|
||||
// fall back to a crude approximation, based only on outside convex cells
|
||||
EnclosingBall<Sphere2D, S2Point> enclosingS2 =
|
||||
new EnclosingBall<Sphere2D, S2Point>(S2Point.PLUS_K, Double.POSITIVE_INFINITY);
|
||||
new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY);
|
||||
for (Vector3D outsidePoint : getOutsidePoints()) {
|
||||
final S2Point outsideS2 = new S2Point(outsidePoint);
|
||||
final BoundaryProjection<Sphere2D> projection = projectToBoundary(outsideS2);
|
||||
if (FastMath.PI - projection.getOffset() < enclosingS2.getRadius()) {
|
||||
enclosingS2 = new EnclosingBall<Sphere2D, S2Point>(outsideS2.negate(),
|
||||
enclosingS2 = new EnclosingBall<>(outsideS2.negate(),
|
||||
FastMath.PI - projection.getOffset(),
|
||||
(S2Point) projection.getProjected());
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
}
|
||||
|
||||
final EnclosingBall<Sphere2D, S2Point> enclosingS2 =
|
||||
new EnclosingBall<Sphere2D, S2Point>(new S2Point(enclosing3D.getCenter()),
|
||||
new EnclosingBall<>(new S2Point(enclosing3D.getCenter()),
|
||||
FastMath.acos((1 + h * h - r * r) / (2 * h)),
|
||||
support);
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ public class SubCircle extends AbstractSubHyperplane<Sphere2D, Sphere1D> {
|
|||
|
||||
if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) {
|
||||
// the two circles are aligned or opposite
|
||||
return new SplitSubHyperplane<Sphere2D>(null, null);
|
||||
return new SplitSubHyperplane<>(null, null);
|
||||
} else {
|
||||
// the two circles intersect each other
|
||||
final Arc arc = thisCircle.getInsideArc(otherCircle);
|
||||
final ArcsSet.Split split = ((ArcsSet) getRemainingRegion()).split(arc);
|
||||
final ArcsSet plus = split.getPlus();
|
||||
final ArcsSet minus = split.getMinus();
|
||||
return new SplitSubHyperplane<Sphere2D>(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus),
|
||||
return new SplitSubHyperplane<>(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus),
|
||||
minus == null ? null : new SubCircle(thisCircle.copySelf(), minus));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Vertex {
|
|||
this.location = location;
|
||||
this.incoming = null;
|
||||
this.outgoing = null;
|
||||
this.circles = new ArrayList<Circle>();
|
||||
this.circles = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** Get Vertex location.
|
||||
|
|
|
@ -270,7 +270,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
final char[] binaryRepresentation = Integer.toBinaryString(power)
|
||||
.toCharArray();
|
||||
final ArrayList<Integer> nonZeroPositions = new ArrayList<Integer>();
|
||||
final ArrayList<Integer> nonZeroPositions = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < binaryRepresentation.length; ++i) {
|
||||
if (binaryRepresentation[i] == '1') {
|
||||
|
@ -279,7 +279,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
}
|
||||
|
||||
ArrayList<FieldMatrix<T>> results = new ArrayList<FieldMatrix<T>>(
|
||||
ArrayList<FieldMatrix<T>> results = new ArrayList<>(
|
||||
binaryRepresentation.length);
|
||||
|
||||
results.add(0, this.copy());
|
||||
|
@ -537,7 +537,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
@Override
|
||||
public FieldVector<T> getRowVector(final int row)
|
||||
throws OutOfRangeException {
|
||||
return new ArrayFieldVector<T>(field, getRow(row), false);
|
||||
return new ArrayFieldVector<>(field, getRow(row), false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -560,7 +560,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
@Override
|
||||
public FieldVector<T> getColumnVector(final int column)
|
||||
throws OutOfRangeException {
|
||||
return new ArrayFieldVector<T>(field, getColumn(column), false);
|
||||
return new ArrayFieldVector<>(field, getColumn(column), false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -726,7 +726,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
public FieldVector<T> operate(final FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
return new ArrayFieldVector<T>(field, operate(((ArrayFieldVector<T>) v).getDataRef()), false);
|
||||
return new ArrayFieldVector<>(field, operate(((ArrayFieldVector<T>) v).getDataRef()), false);
|
||||
} catch (ClassCastException cce) {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -743,7 +743,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
out[row] = sum;
|
||||
}
|
||||
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -774,7 +774,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
public FieldVector<T> preMultiply(final FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
return new ArrayFieldVector<T>(field, preMultiply(((ArrayFieldVector<T>) v).getDataRef()), false);
|
||||
return new ArrayFieldVector<>(field, preMultiply(((ArrayFieldVector<T>) v).getDataRef()), false);
|
||||
} catch (ClassCastException cce) {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -791,7 +791,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
out[col] = sum;
|
||||
}
|
||||
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public abstract class AbstractRealMatrix
|
|||
*/
|
||||
|
||||
final char[] binaryRepresentation = Integer.toBinaryString(power).toCharArray();
|
||||
final ArrayList<Integer> nonZeroPositions = new ArrayList<Integer>();
|
||||
final ArrayList<Integer> nonZeroPositions = new ArrayList<>();
|
||||
int maxI = -1;
|
||||
|
||||
for (int i = 0; i < binaryRepresentation.length; ++i) {
|
||||
|
|
|
@ -208,13 +208,13 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
public FieldMatrix<T> createMatrix(final int rowDimension,
|
||||
final int columnDimension)
|
||||
throws NotStrictlyPositiveException {
|
||||
return new Array2DRowFieldMatrix<T>(getField(), rowDimension, columnDimension);
|
||||
return new Array2DRowFieldMatrix<>(getField(), rowDimension, columnDimension);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> copy() {
|
||||
return new Array2DRowFieldMatrix<T>(getField(), copyOut(), false);
|
||||
return new Array2DRowFieldMatrix<>(getField(), copyOut(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,7 +242,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
}
|
||||
|
||||
return new Array2DRowFieldMatrix<T>(getField(), outData, false);
|
||||
return new Array2DRowFieldMatrix<>(getField(), outData, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,7 +270,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
}
|
||||
|
||||
return new Array2DRowFieldMatrix<T>(getField(), outData, false);
|
||||
return new Array2DRowFieldMatrix<>(getField(), outData, false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
}
|
||||
|
||||
return new Array2DRowFieldMatrix<T>(getField(), outData, false);
|
||||
return new Array2DRowFieldMatrix<>(getField(), outData, false);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> copy() {
|
||||
return new ArrayFieldVector<T>(this, true);
|
||||
return new ArrayFieldVector<>(this, true);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -403,7 +403,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].add(v.getEntry(i));
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].add(v.data[i]);
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -436,7 +436,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].subtract(v.getEntry(i));
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].subtract(v.data[i]);
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -464,7 +464,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].add(d);
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -483,7 +483,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].subtract(d);
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -502,7 +502,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].multiply(d);
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -523,7 +523,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].divide(d);
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -549,7 +549,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
throw new MathArithmeticException(LocalizedFormats.INDEX, i);
|
||||
}
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -578,7 +578,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].multiply(v.getEntry(i));
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -596,7 +596,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] = data[i].multiply(v.data[i]);
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -615,7 +615,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
throw new MathArithmeticException(LocalizedFormats.INDEX, i);
|
||||
}
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,7 +638,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
throw new MathArithmeticException(LocalizedFormats.INDEX, i);
|
||||
}
|
||||
}
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -710,7 +710,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
} catch (ClassCastException cce) {
|
||||
final int m = data.length;
|
||||
final int n = v.getDimension();
|
||||
final FieldMatrix<T> out = new Array2DRowFieldMatrix<T>(field, m, n);
|
||||
final FieldMatrix<T> out = new Array2DRowFieldMatrix<>(field, m, n);
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
out.setEntry(i, j, data[i].multiply(v.getEntry(j)));
|
||||
|
@ -728,7 +728,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
public FieldMatrix<T> outerProduct(ArrayFieldVector<T> v) {
|
||||
final int m = data.length;
|
||||
final int n = v.data.length;
|
||||
final FieldMatrix<T> out = new Array2DRowFieldMatrix<T>(field, m, n);
|
||||
final FieldMatrix<T> out = new Array2DRowFieldMatrix<>(field, m, n);
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
out.setEntry(i, j, data[i].multiply(v.data[j]));
|
||||
|
@ -755,7 +755,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
try {
|
||||
return append((ArrayFieldVector<T>) v);
|
||||
} catch (ClassCastException cce) {
|
||||
return new ArrayFieldVector<T>(this,new ArrayFieldVector<T>(v));
|
||||
return new ArrayFieldVector<>(this,new ArrayFieldVector<>(v));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -765,7 +765,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
* @return a new vector
|
||||
*/
|
||||
public ArrayFieldVector<T> append(ArrayFieldVector<T> v) {
|
||||
return new ArrayFieldVector<T>(this, v);
|
||||
return new ArrayFieldVector<>(this, v);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -774,7 +774,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
final T[] out = MathArrays.buildArray(field, data.length + 1);
|
||||
System.arraycopy(data, 0, out, 0, data.length);
|
||||
out[data.length] = in;
|
||||
return new ArrayFieldVector<T>(field, out, false);
|
||||
return new ArrayFieldVector<>(field, out, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -784,7 +784,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
if (n < 0) {
|
||||
throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
|
||||
}
|
||||
ArrayFieldVector<T> out = new ArrayFieldVector<T>(field, n);
|
||||
ArrayFieldVector<T> out = new ArrayFieldVector<>(field, n);
|
||||
try {
|
||||
System.arraycopy(data, index, out.data, 0, n);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
|
|
|
@ -294,7 +294,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
public FieldMatrix<T> createMatrix(final int rowDimension,
|
||||
final int columnDimension)
|
||||
throws NotStrictlyPositiveException {
|
||||
return new BlockFieldMatrix<T>(getField(), rowDimension,
|
||||
return new BlockFieldMatrix<>(getField(), rowDimension,
|
||||
columnDimension);
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
public FieldMatrix<T> copy() {
|
||||
|
||||
// create an empty matrix
|
||||
BlockFieldMatrix<T> copied = new BlockFieldMatrix<T>(getField(), rows, columns);
|
||||
BlockFieldMatrix<T> copied = new BlockFieldMatrix<>(getField(), rows, columns);
|
||||
|
||||
// copy the blocks
|
||||
for (int i = 0; i < blocks.length; ++i) {
|
||||
|
@ -324,7 +324,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
// safety check
|
||||
checkAdditionCompatible(m);
|
||||
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, columns);
|
||||
|
||||
// perform addition block-wise, to ensure good cache behavior
|
||||
int blockIndex = 0;
|
||||
|
@ -370,7 +370,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
// safety check
|
||||
checkAdditionCompatible(m);
|
||||
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, columns);
|
||||
|
||||
// perform addition block-wise, to ensure good cache behavior
|
||||
for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) {
|
||||
|
@ -396,7 +396,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
// safety check
|
||||
checkSubtractionCompatible(m);
|
||||
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, columns);
|
||||
|
||||
// perform subtraction block-wise, to ensure good cache behavior
|
||||
int blockIndex = 0;
|
||||
|
@ -440,7 +440,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
// safety check
|
||||
checkSubtractionCompatible(m);
|
||||
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, columns);
|
||||
|
||||
// perform subtraction block-wise, to ensure good cache behavior
|
||||
for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) {
|
||||
|
@ -458,7 +458,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> scalarAdd(final T d) {
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, columns);
|
||||
|
||||
// perform subtraction block-wise, to ensure good cache behavior
|
||||
for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) {
|
||||
|
@ -476,7 +476,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
@Override
|
||||
public FieldMatrix<T> scalarMultiply(final T d) {
|
||||
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, columns);
|
||||
|
||||
// perform subtraction block-wise, to ensure good cache behavior
|
||||
for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) {
|
||||
|
@ -501,7 +501,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
// safety check
|
||||
checkMultiplicationCompatible(m);
|
||||
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, m.getColumnDimension());
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, m.getColumnDimension());
|
||||
final T zero = getField().getZero();
|
||||
|
||||
// perform multiplication block-wise, to ensure good cache behavior
|
||||
|
@ -564,7 +564,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
// safety check
|
||||
checkMultiplicationCompatible(m);
|
||||
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, m.columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, m.columns);
|
||||
final T zero = getField().getZero();
|
||||
|
||||
// perform multiplication block-wise, to ensure good cache behavior
|
||||
|
@ -663,7 +663,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
|
||||
// create the output matrix
|
||||
final BlockFieldMatrix<T> out =
|
||||
new BlockFieldMatrix<T>(getField(), endRow - startRow + 1, endColumn - startColumn + 1);
|
||||
new BlockFieldMatrix<>(getField(), endRow - startRow + 1, endColumn - startColumn + 1);
|
||||
|
||||
// compute blocks shifts
|
||||
final int blockStartRow = startRow / BLOCK_SIZE;
|
||||
|
@ -836,7 +836,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
public FieldMatrix<T> getRowMatrix(final int row)
|
||||
throws OutOfRangeException {
|
||||
checkRowIndex(row);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), 1, columns);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), 1, columns);
|
||||
|
||||
// perform copy block-wise, to ensure good cache behavior
|
||||
final int iBlock = row / BLOCK_SIZE;
|
||||
|
@ -922,7 +922,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
public FieldMatrix<T> getColumnMatrix(final int column)
|
||||
throws OutOfRangeException {
|
||||
checkColumnIndex(column);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), rows, 1);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), rows, 1);
|
||||
|
||||
// perform copy block-wise, to ensure good cache behavior
|
||||
final int jBlock = column / BLOCK_SIZE;
|
||||
|
@ -1017,7 +1017,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
outIndex += jWidth;
|
||||
}
|
||||
|
||||
return new ArrayFieldVector<T>(getField(), outData, false);
|
||||
return new ArrayFieldVector<>(getField(), outData, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -1051,7 +1051,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
}
|
||||
}
|
||||
|
||||
return new ArrayFieldVector<T>(getField(), outData, false);
|
||||
return new ArrayFieldVector<>(getField(), outData, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -1220,7 +1220,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
public FieldMatrix<T> transpose() {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<T>(getField(), nCols, nRows);
|
||||
final BlockFieldMatrix<T> out = new BlockFieldMatrix<>(getField(), nCols, nRows);
|
||||
|
||||
// perform transpose block-wise, to ensure good cache behavior
|
||||
int blockIndex = 0;
|
||||
|
|
|
@ -171,7 +171,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
public FieldMatrix<T> getL() {
|
||||
if ((cachedL == null) && !singular) {
|
||||
final int m = pivot.length;
|
||||
cachedL = new Array2DRowFieldMatrix<T>(field, m, m);
|
||||
cachedL = new Array2DRowFieldMatrix<>(field, m, m);
|
||||
for (int i = 0; i < m; ++i) {
|
||||
final T[] luI = lu[i];
|
||||
for (int j = 0; j < i; ++j) {
|
||||
|
@ -191,7 +191,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
public FieldMatrix<T> getU() {
|
||||
if ((cachedU == null) && !singular) {
|
||||
final int m = pivot.length;
|
||||
cachedU = new Array2DRowFieldMatrix<T>(field, m, m);
|
||||
cachedU = new Array2DRowFieldMatrix<>(field, m, m);
|
||||
for (int i = 0; i < m; ++i) {
|
||||
final T[] luI = lu[i];
|
||||
for (int j = i; j < m; ++j) {
|
||||
|
@ -214,7 +214,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
public FieldMatrix<T> getP() {
|
||||
if ((cachedP == null) && !singular) {
|
||||
final int m = pivot.length;
|
||||
cachedP = new Array2DRowFieldMatrix<T>(field, m, m);
|
||||
cachedP = new Array2DRowFieldMatrix<>(field, m, m);
|
||||
for (int i = 0; i < m; ++i) {
|
||||
cachedP.setEntry(i, pivot[i], field.getOne());
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
* @return a solver
|
||||
*/
|
||||
public FieldDecompositionSolver<T> getSolver() {
|
||||
return new Solver<T>(field, lu, pivot, singular);
|
||||
return new Solver<>(field, lu, pivot, singular);
|
||||
}
|
||||
|
||||
/** Specialized solver.
|
||||
|
@ -332,7 +332,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
return new ArrayFieldVector<T>(field, bp, false);
|
||||
return new ArrayFieldVector<>(field, bp, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
return new ArrayFieldVector<T>(bp, false);
|
||||
return new ArrayFieldVector<>(bp, false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -431,7 +431,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
return new Array2DRowFieldMatrix<T>(field, bp, false);
|
||||
return new Array2DRowFieldMatrix<>(field, bp, false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -440,7 +440,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
public FieldMatrix<T> getInverse() {
|
||||
final int m = pivot.length;
|
||||
final T one = field.getOne();
|
||||
FieldMatrix<T> identity = new Array2DRowFieldMatrix<T>(field, m, m);
|
||||
FieldMatrix<T> identity = new Array2DRowFieldMatrix<>(field, m, m);
|
||||
for (int i = 0; i < m; ++i) {
|
||||
identity.setEntry(i, i, one);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class MatrixUtils {
|
|||
final int rows,
|
||||
final int columns) {
|
||||
return (rows * columns <= 4096) ?
|
||||
new Array2DRowFieldMatrix<T>(field, rows, columns) : new BlockFieldMatrix<T>(field, rows, columns);
|
||||
new Array2DRowFieldMatrix<>(field, rows, columns) : new BlockFieldMatrix<>(field, rows, columns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,7 +161,7 @@ public class MatrixUtils {
|
|||
throw new NullArgumentException();
|
||||
}
|
||||
return (data.length * data[0].length <= 4096) ?
|
||||
new Array2DRowFieldMatrix<T>(data) : new BlockFieldMatrix<T>(data);
|
||||
new Array2DRowFieldMatrix<>(data) : new BlockFieldMatrix<>(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,7 +200,7 @@ public class MatrixUtils {
|
|||
Arrays.fill(dRow, zero);
|
||||
dRow[row] = one;
|
||||
}
|
||||
return new Array2DRowFieldMatrix<T>(field, d, false);
|
||||
return new Array2DRowFieldMatrix<>(field, d, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -272,7 +272,7 @@ public class MatrixUtils {
|
|||
if (data.length == 0) {
|
||||
throw new ZeroException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
|
||||
}
|
||||
return new ArrayFieldVector<T>(data[0].getField(), data, true);
|
||||
return new ArrayFieldVector<>(data[0].getField(), data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -315,8 +315,8 @@ public class RealMatrixFormat {
|
|||
}
|
||||
|
||||
// parse components
|
||||
List<List<Number>> matrix = new ArrayList<List<Number>>();
|
||||
List<Number> rowComponents = new ArrayList<Number>();
|
||||
List<List<Number>> matrix = new ArrayList<>();
|
||||
List<Number> rowComponents = new ArrayList<>();
|
||||
for (boolean loop = true; loop;){
|
||||
|
||||
if (!rowComponents.isEmpty()) {
|
||||
|
@ -329,7 +329,7 @@ public class RealMatrixFormat {
|
|||
CompositeFormat.parseAndIgnoreWhitespace(source, pos);
|
||||
if (CompositeFormat.parseFixedstring(source, trimmedRowSeparator, pos)) {
|
||||
matrix.add(rowComponents);
|
||||
rowComponents = new ArrayList<Number>();
|
||||
rowComponents = new ArrayList<>();
|
||||
continue;
|
||||
} else {
|
||||
loop = false;
|
||||
|
|
|
@ -247,7 +247,7 @@ public class RealVectorFormat {
|
|||
}
|
||||
|
||||
// parse components
|
||||
List<Number> components = new ArrayList<Number>();
|
||||
List<Number> components = new ArrayList<>();
|
||||
for (boolean loop = true; loop;){
|
||||
|
||||
if (!components.isEmpty()) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
super(field);
|
||||
rows = 0;
|
||||
columns= 0;
|
||||
entries = new OpenIntToFieldHashMap<T>(field);
|
||||
entries = new OpenIntToFieldHashMap<>(field);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
super(field, rowDimension, columnDimension);
|
||||
this.rows = rowDimension;
|
||||
this.columns = columnDimension;
|
||||
entries = new OpenIntToFieldHashMap<T>(field);
|
||||
entries = new OpenIntToFieldHashMap<>(field);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
super(other.getField(), other.getRowDimension(), other.getColumnDimension());
|
||||
rows = other.getRowDimension();
|
||||
columns = other.getColumnDimension();
|
||||
entries = new OpenIntToFieldHashMap<T>(other.entries);
|
||||
entries = new OpenIntToFieldHashMap<>(other.entries);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,7 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
super(other.getField(), other.getRowDimension(), other.getColumnDimension());
|
||||
rows = other.getRowDimension();
|
||||
columns = other.getColumnDimension();
|
||||
entries = new OpenIntToFieldHashMap<T>(getField());
|
||||
entries = new OpenIntToFieldHashMap<>(getField());
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < columns; j++) {
|
||||
setEntry(i, j, other.getEntry(i, j));
|
||||
|
@ -118,13 +118,13 @@ public class SparseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldM
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> copy() {
|
||||
return new SparseFieldMatrix<T>(this);
|
||||
return new SparseFieldMatrix<>(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> createMatrix(int rowDimension, int columnDimension) {
|
||||
return new SparseFieldMatrix<T>(getField(), rowDimension, columnDimension);
|
||||
return new SparseFieldMatrix<>(getField(), rowDimension, columnDimension);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
public SparseFieldVector(Field<T> field, int dimension) {
|
||||
this.field = field;
|
||||
virtualSize = dimension;
|
||||
entries = new OpenIntToFieldHashMap<T>(field);
|
||||
entries = new OpenIntToFieldHashMap<>(field);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
protected SparseFieldVector(SparseFieldVector<T> v, int resize) {
|
||||
field = v.field;
|
||||
virtualSize = v.getDimension() + resize;
|
||||
entries = new OpenIntToFieldHashMap<T>(v.entries);
|
||||
entries = new OpenIntToFieldHashMap<>(v.entries);
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
public SparseFieldVector(Field<T> field, int dimension, int expectedSize) {
|
||||
this.field = field;
|
||||
virtualSize = dimension;
|
||||
entries = new OpenIntToFieldHashMap<T>(field,expectedSize);
|
||||
entries = new OpenIntToFieldHashMap<>(field,expectedSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +118,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
MathUtils.checkNotNull(values);
|
||||
this.field = field;
|
||||
virtualSize = values.length;
|
||||
entries = new OpenIntToFieldHashMap<T>(field);
|
||||
entries = new OpenIntToFieldHashMap<>(field);
|
||||
for (int key = 0; key < values.length; key++) {
|
||||
T value = values[key];
|
||||
entries.put(key, value);
|
||||
|
@ -133,7 +133,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
public SparseFieldVector(SparseFieldVector<T> v) {
|
||||
field = v.field;
|
||||
virtualSize = v.getDimension();
|
||||
entries = new OpenIntToFieldHashMap<T>(v.getEntries());
|
||||
entries = new OpenIntToFieldHashMap<>(v.getEntries());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +179,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
* @return a new vector.
|
||||
*/
|
||||
public FieldVector<T> append(SparseFieldVector<T> v) {
|
||||
SparseFieldVector<T> res = new SparseFieldVector<T>(this, v.getDimension());
|
||||
SparseFieldVector<T> res = new SparseFieldVector<>(this, v.getDimension());
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = v.entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.advance();
|
||||
|
@ -195,7 +195,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
return append((SparseFieldVector<T>) v);
|
||||
} else {
|
||||
final int n = v.getDimension();
|
||||
FieldVector<T> res = new SparseFieldVector<T>(this, n);
|
||||
FieldVector<T> res = new SparseFieldVector<>(this, n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
res.setEntry(i + virtualSize, v.getEntry(i));
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
@Override
|
||||
public FieldVector<T> append(T d) throws NullArgumentException {
|
||||
MathUtils.checkNotNull(d);
|
||||
FieldVector<T> res = new SparseFieldVector<T>(this, 1);
|
||||
FieldVector<T> res = new SparseFieldVector<>(this, 1);
|
||||
res.setEntry(virtualSize, d);
|
||||
return res;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> copy() {
|
||||
return new SparseFieldVector<T>(this);
|
||||
return new SparseFieldVector<>(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -238,7 +238,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
public FieldVector<T> ebeDivide(FieldVector<T> v)
|
||||
throws DimensionMismatchException, MathArithmeticException {
|
||||
checkVectorDimensions(v.getDimension());
|
||||
SparseFieldVector<T> res = new SparseFieldVector<T>(this);
|
||||
SparseFieldVector<T> res = new SparseFieldVector<>(this);
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = res.entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.advance();
|
||||
|
@ -252,7 +252,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
public FieldVector<T> ebeMultiply(FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
checkVectorDimensions(v.getDimension());
|
||||
SparseFieldVector<T> res = new SparseFieldVector<T>(this);
|
||||
SparseFieldVector<T> res = new SparseFieldVector<>(this);
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = res.entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.advance();
|
||||
|
@ -289,7 +289,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
checkIndex(index);
|
||||
checkIndex(index + n - 1);
|
||||
SparseFieldVector<T> res = new SparseFieldVector<T>(field,n);
|
||||
SparseFieldVector<T> res = new SparseFieldVector<>(field,n);
|
||||
int end = index + n;
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -387,7 +387,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
*/
|
||||
public FieldMatrix<T> outerProduct(SparseFieldVector<T> v) {
|
||||
final int n = v.getDimension();
|
||||
SparseFieldMatrix<T> res = new SparseFieldMatrix<T>(field, virtualSize, n);
|
||||
SparseFieldMatrix<T> res = new SparseFieldMatrix<>(field, virtualSize, n);
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.advance();
|
||||
|
@ -407,7 +407,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
return outerProduct((SparseFieldVector<T>)v);
|
||||
} else {
|
||||
final int n = v.getDimension();
|
||||
FieldMatrix<T> res = new SparseFieldMatrix<T>(field, virtualSize, n);
|
||||
FieldMatrix<T> res = new SparseFieldMatrix<>(field, virtualSize, n);
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.advance();
|
||||
|
@ -495,7 +495,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
} else {
|
||||
final int n = v.getDimension();
|
||||
checkVectorDimensions(n);
|
||||
SparseFieldVector<T> res = new SparseFieldVector<T>(this);
|
||||
SparseFieldVector<T> res = new SparseFieldVector<>(this);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (entries.containsKey(i)) {
|
||||
res.setEntry(i, entries.get(i).subtract(v.getEntry(i)));
|
||||
|
@ -578,7 +578,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
} else {
|
||||
final int n = v.getDimension();
|
||||
checkVectorDimensions(n);
|
||||
SparseFieldVector<T> res = new SparseFieldVector<T>(field,
|
||||
SparseFieldVector<T> res = new SparseFieldVector<>(field,
|
||||
getDimension());
|
||||
for (int i = 0; i < n; i++) {
|
||||
res.setEntry(i, v.getEntry(i).add(getEntry(i)));
|
||||
|
|
|
@ -38,7 +38,7 @@ public class Cluster<T extends Clusterable> implements Serializable {
|
|||
* Build a cluster centered at a specified point.
|
||||
*/
|
||||
public Cluster() {
|
||||
points = new ArrayList<T>();
|
||||
points = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -136,8 +136,8 @@ public class DBSCANClusterer<T extends Clusterable> extends Clusterer<T> {
|
|||
// sanity checks
|
||||
MathUtils.checkNotNull(points);
|
||||
|
||||
final List<Cluster<T>> clusters = new ArrayList<Cluster<T>>();
|
||||
final Map<Clusterable, PointStatus> visited = new HashMap<Clusterable, PointStatus>();
|
||||
final List<Cluster<T>> clusters = new ArrayList<>();
|
||||
final Map<Clusterable, PointStatus> visited = new HashMap<>();
|
||||
|
||||
for (final T point : points) {
|
||||
if (visited.get(point) != null) {
|
||||
|
@ -146,7 +146,7 @@ public class DBSCANClusterer<T extends Clusterable> extends Clusterer<T> {
|
|||
final List<T> neighbors = getNeighbors(point, points);
|
||||
if (neighbors.size() >= minPts) {
|
||||
// DBSCAN does not care about center points
|
||||
final Cluster<T> cluster = new Cluster<T>();
|
||||
final Cluster<T> cluster = new Cluster<>();
|
||||
clusters.add(expandCluster(cluster, point, neighbors, points, visited));
|
||||
} else {
|
||||
visited.put(point, PointStatus.NOISE);
|
||||
|
@ -174,7 +174,7 @@ public class DBSCANClusterer<T extends Clusterable> extends Clusterer<T> {
|
|||
cluster.addPoint(point);
|
||||
visited.put(point, PointStatus.PART_OF_CLUSTER);
|
||||
|
||||
List<T> seeds = new ArrayList<T>(neighbors);
|
||||
List<T> seeds = new ArrayList<>(neighbors);
|
||||
int index = 0;
|
||||
while (index < seeds.size()) {
|
||||
final T current = seeds.get(index);
|
||||
|
@ -205,7 +205,7 @@ public class DBSCANClusterer<T extends Clusterable> extends Clusterer<T> {
|
|||
* @return the List of neighbors
|
||||
*/
|
||||
private List<T> getNeighbors(final T point, final Collection<T> points) {
|
||||
final List<T> neighbors = new ArrayList<T>();
|
||||
final List<T> neighbors = new ArrayList<>();
|
||||
for (final T neighbor : points) {
|
||||
if (point != neighbor && distance(neighbor, point) <= eps) {
|
||||
neighbors.add(neighbor);
|
||||
|
@ -222,7 +222,7 @@ public class DBSCANClusterer<T extends Clusterable> extends Clusterer<T> {
|
|||
* @return merged lists
|
||||
*/
|
||||
private List<T> merge(final List<T> one, final List<T> two) {
|
||||
final Set<T> oneSet = new HashSet<T>(one);
|
||||
final Set<T> oneSet = new HashSet<>(one);
|
||||
for (T item : two) {
|
||||
if (!oneSet.contains(item)) {
|
||||
one.add(item);
|
||||
|
|
|
@ -279,8 +279,8 @@ public class FuzzyKMeansClusterer<T extends Clusterable> extends Clusterer<T> {
|
|||
}
|
||||
|
||||
// copy the input collection to an unmodifiable list with indexed access
|
||||
points = Collections.unmodifiableList(new ArrayList<T>(dataPoints));
|
||||
clusters = new ArrayList<CentroidCluster<T>>();
|
||||
points = Collections.unmodifiableList(new ArrayList<>(dataPoints));
|
||||
clusters = new ArrayList<>();
|
||||
membershipMatrix = new double[size][k];
|
||||
final double[][] oldMatrix = new double[size][k];
|
||||
|
||||
|
@ -316,7 +316,7 @@ public class FuzzyKMeansClusterer<T extends Clusterable> extends Clusterer<T> {
|
|||
*/
|
||||
private void updateClusterCenters() {
|
||||
int j = 0;
|
||||
final List<CentroidCluster<T>> newClusters = new ArrayList<CentroidCluster<T>>(k);
|
||||
final List<CentroidCluster<T>> newClusters = new ArrayList<>(k);
|
||||
for (final CentroidCluster<T> cluster : clusters) {
|
||||
final Clusterable center = cluster.getCenter();
|
||||
int i = 0;
|
||||
|
|
|
@ -216,7 +216,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
|
|||
final int max = (maxIterations < 0) ? Integer.MAX_VALUE : maxIterations;
|
||||
for (int count = 0; count < max; count++) {
|
||||
boolean emptyCluster = false;
|
||||
List<CentroidCluster<T>> newClusters = new ArrayList<CentroidCluster<T>>();
|
||||
List<CentroidCluster<T>> newClusters = new ArrayList<>();
|
||||
for (final CentroidCluster<T> cluster : clusters) {
|
||||
final Clusterable newCenter;
|
||||
if (cluster.getPoints().isEmpty()) {
|
||||
|
@ -288,7 +288,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
|
|||
|
||||
// Convert to list for indexed access. Make it unmodifiable, since removal of items
|
||||
// would screw up the logic of this method.
|
||||
final List<T> pointList = Collections.unmodifiableList(new ArrayList<T> (points));
|
||||
final List<T> pointList = Collections.unmodifiableList(new ArrayList<> (points));
|
||||
|
||||
// The number of points in the list.
|
||||
final int numPoints = pointList.size();
|
||||
|
@ -298,7 +298,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
|
|||
final boolean[] taken = new boolean[numPoints];
|
||||
|
||||
// The resulting list of initial centers.
|
||||
final List<CentroidCluster<T>> resultSet = new ArrayList<CentroidCluster<T>>();
|
||||
final List<CentroidCluster<T>> resultSet = new ArrayList<>();
|
||||
|
||||
// Choose one center uniformly at random from among the data points.
|
||||
final int firstPointIndex = random.nextInt(numPoints);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class MapUtils {
|
|||
}
|
||||
}
|
||||
|
||||
return new Pair<Neuron, Neuron>(best[0], best[1]);
|
||||
return new Pair<>(best[0], best[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,7 +130,7 @@ public class MapUtils {
|
|||
public static Neuron[] sort(double[] features,
|
||||
Iterable<Neuron> neurons,
|
||||
DistanceMeasure distance) {
|
||||
final List<PairNeuronDouble> list = new ArrayList<PairNeuronDouble>();
|
||||
final List<PairNeuronDouble> list = new ArrayList<>();
|
||||
|
||||
for (final Neuron n : neurons) {
|
||||
final double d = distance.compute(n.getFeatures(), features);
|
||||
|
@ -196,7 +196,7 @@ public class MapUtils {
|
|||
public static int[][] computeHitHistogram(Iterable<double[]> data,
|
||||
NeuronSquareMesh2D map,
|
||||
DistanceMeasure distance) {
|
||||
final HashMap<Neuron, Integer> hit = new HashMap<Neuron, Integer>();
|
||||
final HashMap<Neuron, Integer> hit = new HashMap<>();
|
||||
final Network net = map.getNetwork();
|
||||
|
||||
for (double[] f : data) {
|
||||
|
|
|
@ -51,14 +51,14 @@ public class Network
|
|||
private static final long serialVersionUID = 20130207L;
|
||||
/** Neurons. */
|
||||
private final ConcurrentHashMap<Long, Neuron> neuronMap
|
||||
= new ConcurrentHashMap<Long, Neuron>();
|
||||
= new ConcurrentHashMap<>();
|
||||
/** Next available neuron identifier. */
|
||||
private final AtomicLong nextId;
|
||||
/** Neuron's features set size. */
|
||||
private final int featureSize;
|
||||
/** Links. */
|
||||
private final ConcurrentHashMap<Long, Set<Long>> linkMap
|
||||
= new ConcurrentHashMap<Long, Set<Long>>();
|
||||
= new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Comparator that prescribes an order of the neurons according
|
||||
|
@ -155,7 +155,7 @@ public class Network
|
|||
}
|
||||
|
||||
for (Map.Entry<Long, Set<Long>> e : linkMap.entrySet()) {
|
||||
copy.linkMap.put(e.getKey(), new HashSet<Long>(e.getValue()));
|
||||
copy.linkMap.put(e.getKey(), new HashSet<>(e.getValue()));
|
||||
}
|
||||
|
||||
return copy;
|
||||
|
@ -178,7 +178,7 @@ public class Network
|
|||
* @see NeuronIdentifierComparator
|
||||
*/
|
||||
public Collection<Neuron> getNeurons(Comparator<Neuron> comparator) {
|
||||
final List<Neuron> neurons = new ArrayList<Neuron>();
|
||||
final List<Neuron> neurons = new ArrayList<>();
|
||||
neurons.addAll(neuronMap.values());
|
||||
|
||||
Collections.sort(neurons, comparator);
|
||||
|
@ -356,7 +356,7 @@ public class Network
|
|||
*/
|
||||
public Collection<Neuron> getNeighbours(Iterable<Neuron> neurons,
|
||||
Iterable<Neuron> exclude) {
|
||||
final Set<Long> idList = new HashSet<Long>();
|
||||
final Set<Long> idList = new HashSet<>();
|
||||
|
||||
for (Neuron n : neurons) {
|
||||
idList.addAll(linkMap.get(n.getIdentifier()));
|
||||
|
@ -367,7 +367,7 @@ public class Network
|
|||
}
|
||||
}
|
||||
|
||||
final List<Neuron> neuronList = new ArrayList<Neuron>();
|
||||
final List<Neuron> neuronList = new ArrayList<>();
|
||||
for (Long id : idList) {
|
||||
neuronList.add(getNeuron(id));
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ public class Network
|
|||
}
|
||||
}
|
||||
|
||||
final List<Neuron> neuronList = new ArrayList<Neuron>();
|
||||
final List<Neuron> neuronList = new ArrayList<>();
|
||||
for (Long id : idList) {
|
||||
neuronList.add(getNeuron(id));
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class Neuron implements Serializable {
|
|||
double[] features) {
|
||||
this.identifier = identifier;
|
||||
this.size = features.length;
|
||||
this.features = new AtomicReference<double[]>(features.clone());
|
||||
this.features = new AtomicReference<>(features.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -111,10 +111,10 @@ public class KohonenUpdateAction implements UpdateAction {
|
|||
|
||||
if (currentNeighbourhood > 0) {
|
||||
// Initial set of neurons only contains the winning neuron.
|
||||
Collection<Neuron> neighbours = new HashSet<Neuron>();
|
||||
Collection<Neuron> neighbours = new HashSet<>();
|
||||
neighbours.add(best);
|
||||
// Winning neuron must be excluded from the neighbours.
|
||||
final HashSet<Neuron> exclude = new HashSet<Neuron>();
|
||||
final HashSet<Neuron> exclude = new HashSet<>();
|
||||
exclude.add(best);
|
||||
|
||||
int radius = 1;
|
||||
|
|
|
@ -423,7 +423,7 @@ public class NeuronSquareMesh2D
|
|||
*/
|
||||
private void createLinks() {
|
||||
// "linkEnd" will store the identifiers of the "neighbours".
|
||||
final List<Long> linkEnd = new ArrayList<Long>();
|
||||
final List<Long> linkEnd = new ArrayList<>();
|
||||
final int iLast = numberOfRows - 1;
|
||||
final int jLast = numberOfColumns - 1;
|
||||
for (int i = 0; i < numberOfRows; i++) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.math4.exception.MathIllegalStateException;
|
|||
*/
|
||||
public class LocationFinder {
|
||||
/** Identifier to location mapping. */
|
||||
private final Map<Long, Location> locations = new HashMap<Long, Location>();
|
||||
private final Map<Long, Location> locations = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Container holding a (row, column) pair.
|
||||
|
|
|
@ -95,10 +95,10 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
|
|||
protected AbstractFieldIntegrator(final Field<T> field, final String name) {
|
||||
this.field = field;
|
||||
this.name = name;
|
||||
stepHandlers = new ArrayList<FieldStepHandler<T>>();
|
||||
stepHandlers = new ArrayList<>();
|
||||
stepStart = null;
|
||||
stepSize = null;
|
||||
eventsStates = new ArrayList<FieldEventState<T>>();
|
||||
eventsStates = new ArrayList<>();
|
||||
statesInitialized = false;
|
||||
evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
|
|||
final int maxIterationCount) {
|
||||
addEventHandler(handler, maxCheckInterval, convergence,
|
||||
maxIterationCount,
|
||||
new FieldBracketingNthOrderBrentSolver<T>(field.getZero().add(DEFAULT_RELATIVE_ACCURACY),
|
||||
new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(DEFAULT_RELATIVE_ACCURACY),
|
||||
field.getZero().add(convergence),
|
||||
field.getZero().add(DEFAULT_FUNCTION_VALUE_ACCURACY),
|
||||
5));
|
||||
|
@ -155,14 +155,14 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
|
|||
final double convergence,
|
||||
final int maxIterationCount,
|
||||
final BracketedRealFieldUnivariateSolver<T> solver) {
|
||||
eventsStates.add(new FieldEventState<T>(handler, maxCheckInterval, field.getZero().add(convergence),
|
||||
eventsStates.add(new FieldEventState<>(handler, maxCheckInterval, field.getZero().add(convergence),
|
||||
maxIterationCount, solver));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<FieldEventHandler<T>> getEventHandlers() {
|
||||
final List<FieldEventHandler<T>> list = new ArrayList<FieldEventHandler<T>>(eventsStates.size());
|
||||
final List<FieldEventHandler<T>> list = new ArrayList<>(eventsStates.size());
|
||||
for (FieldEventState<T> state : eventsStates) {
|
||||
list.add(state.getEventHandler());
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
|
|||
|
||||
// set up derivatives of initial state
|
||||
final T[] y0Dot = computeDerivatives(t0, y0);
|
||||
final FieldODEStateAndDerivative<T> state0 = new FieldODEStateAndDerivative<T>(t0, y0, y0Dot);
|
||||
final FieldODEStateAndDerivative<T> state0 = new FieldODEStateAndDerivative<>(t0, y0, y0Dot);
|
||||
|
||||
// initialize event handlers
|
||||
for (final FieldEventState<T> state : eventsStates) {
|
||||
|
@ -307,7 +307,7 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
|
|||
|
||||
// search for next events that may occur during the step
|
||||
final int orderingSign = interpolator.isForward() ? +1 : -1;
|
||||
SortedSet<FieldEventState<T>> occurringEvents = new TreeSet<FieldEventState<T>>(new Comparator<FieldEventState<T>>() {
|
||||
SortedSet<FieldEventState<T>> occurringEvents = new TreeSet<>(new Comparator<FieldEventState<T>>() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
|
|
|
@ -82,10 +82,10 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
*/
|
||||
public AbstractIntegrator(final String name) {
|
||||
this.name = name;
|
||||
stepHandlers = new ArrayList<StepHandler>();
|
||||
stepHandlers = new ArrayList<>();
|
||||
stepStart = Double.NaN;
|
||||
stepSize = Double.NaN;
|
||||
eventsStates = new ArrayList<EventState>();
|
||||
eventsStates = new ArrayList<>();
|
||||
statesInitialized = false;
|
||||
evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<EventHandler> getEventHandlers() {
|
||||
final List<EventHandler> list = new ArrayList<EventHandler>(eventsStates.size());
|
||||
final List<EventHandler> list = new ArrayList<>(eventsStates.size());
|
||||
for (EventState state : eventsStates) {
|
||||
list.add(state.getEventHandler());
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
|
||||
// search for next events that may occur during the step
|
||||
final int orderingSign = interpolator.isForward() ? +1 : -1;
|
||||
SortedSet<EventState> occurringEvents = new TreeSet<EventState>(new Comparator<EventState>() {
|
||||
SortedSet<EventState> occurringEvents = new TreeSet<>(new Comparator<EventState>() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class AbstractParameterizable implements Parameterizable {
|
|||
* @param names names of the supported parameters
|
||||
*/
|
||||
protected AbstractParameterizable(final String ... names) {
|
||||
parametersNames = new ArrayList<String>();
|
||||
parametersNames = new ArrayList<>();
|
||||
for (final String name : names) {
|
||||
parametersNames.add(name);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public abstract class AbstractParameterizable implements Parameterizable {
|
|||
* @param names names of the supported parameters
|
||||
*/
|
||||
protected AbstractParameterizable(final Collection<String> names) {
|
||||
parametersNames = new ArrayList<String>();
|
||||
parametersNames = new ArrayList<>();
|
||||
parametersNames.addAll(names);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class ContinuousOutputFieldModel<T extends RealFieldElement<T>>
|
|||
* Build an empty continuous output model.
|
||||
*/
|
||||
public ContinuousOutputFieldModel() {
|
||||
steps = new ArrayList<FieldStepInterpolator<T>>();
|
||||
steps = new ArrayList<>();
|
||||
initialTime = null;
|
||||
finalTime = null;
|
||||
forward = true;
|
||||
|
|
|
@ -111,7 +111,7 @@ public class ContinuousOutputModel
|
|||
* Build an empty continuous output model.
|
||||
*/
|
||||
public ContinuousOutputModel() {
|
||||
steps = new ArrayList<StepInterpolator>();
|
||||
steps = new ArrayList<>();
|
||||
initialTime = Double.NaN;
|
||||
finalTime = Double.NaN;
|
||||
forward = true;
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ExpandableStatefulODE {
|
|||
this.time = Double.NaN;
|
||||
this.primaryState = new double[n];
|
||||
this.primaryStateDot = new double[n];
|
||||
this.components = new ArrayList<ExpandableStatefulODE.SecondaryComponent>();
|
||||
this.components = new ArrayList<>();
|
||||
}
|
||||
|
||||
/** Get the primary set of differential equations.
|
||||
|
@ -138,7 +138,7 @@ public class ExpandableStatefulODE {
|
|||
final int firstIndex;
|
||||
if (components.isEmpty()) {
|
||||
// lazy creation of the components list
|
||||
components = new ArrayList<ExpandableStatefulODE.SecondaryComponent>();
|
||||
components = new ArrayList<>();
|
||||
firstIndex = primary.getDimension();
|
||||
} else {
|
||||
final SecondaryComponent last = components.get(components.size() - 1);
|
||||
|
|
|
@ -130,7 +130,7 @@ public class FieldEquationsMapper<T extends RealFieldElement<T>> implements Seri
|
|||
final T[] state = extractEquationData(index, y);
|
||||
final T[] derivative = extractEquationData(index, yDot);
|
||||
if (n < 2) {
|
||||
return new FieldODEStateAndDerivative<T>(t, state, derivative);
|
||||
return new FieldODEStateAndDerivative<>(t, state, derivative);
|
||||
} else {
|
||||
final T[][] secondaryState = MathArrays.buildArray(t.getField(), n - 1, -1);
|
||||
final T[][] secondaryDerivative = MathArrays.buildArray(t.getField(), n - 1, -1);
|
||||
|
@ -138,7 +138,7 @@ public class FieldEquationsMapper<T extends RealFieldElement<T>> implements Seri
|
|||
secondaryState[index - 1] = extractEquationData(index, y);
|
||||
secondaryDerivative[index - 1] = extractEquationData(index, yDot);
|
||||
}
|
||||
return new FieldODEStateAndDerivative<T>(t, state, derivative, secondaryState, secondaryDerivative);
|
||||
return new FieldODEStateAndDerivative<>(t, state, derivative, secondaryState, secondaryDerivative);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ public class FieldExpandableODE<T extends RealFieldElement<T>> {
|
|||
*/
|
||||
public FieldExpandableODE(final FirstOrderFieldDifferentialEquations<T> primary) {
|
||||
this.primary = primary;
|
||||
this.components = new ArrayList<FieldSecondaryEquations<T>>();
|
||||
this.mapper = new FieldEquationsMapper<T>(null, primary.getDimension());
|
||||
this.components = new ArrayList<>();
|
||||
this.mapper = new FieldEquationsMapper<>(null, primary.getDimension());
|
||||
}
|
||||
|
||||
/** Get the mapper for the set of equations.
|
||||
|
@ -86,7 +86,7 @@ public class FieldExpandableODE<T extends RealFieldElement<T>> {
|
|||
public int addSecondaryEquations(final FieldSecondaryEquations<T> secondary) {
|
||||
|
||||
components.add(secondary);
|
||||
mapper = new FieldEquationsMapper<T>(mapper, secondary.getDimension());
|
||||
mapper = new FieldEquationsMapper<>(mapper, secondary.getDimension());
|
||||
|
||||
return components.size();
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ public class JacobianMatrices {
|
|||
}
|
||||
this.dirtyParameter = false;
|
||||
|
||||
this.jacobianProviders = new ArrayList<ParameterJacobianProvider>();
|
||||
this.jacobianProviders = new ArrayList<>();
|
||||
|
||||
// set the default initial state Jacobian to the identity
|
||||
// and the default initial parameters Jacobian to the null matrix
|
||||
|
|
|
@ -130,7 +130,7 @@ public abstract class MultistepFieldIntegrator<T extends RealFieldElement<T>>
|
|||
nSteps, 2, true);
|
||||
}
|
||||
|
||||
starter = new DormandPrince853FieldIntegrator<T>(field, minStep, maxStep,
|
||||
starter = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep,
|
||||
scalAbsoluteTolerance,
|
||||
scalRelativeTolerance);
|
||||
this.nSteps = nSteps;
|
||||
|
@ -170,7 +170,7 @@ public abstract class MultistepFieldIntegrator<T extends RealFieldElement<T>>
|
|||
final double[] vecAbsoluteTolerance,
|
||||
final double[] vecRelativeTolerance) {
|
||||
super(field, name, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
|
||||
starter = new DormandPrince853FieldIntegrator<T>(field, minStep, maxStep,
|
||||
starter = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep,
|
||||
vecAbsoluteTolerance,
|
||||
vecRelativeTolerance);
|
||||
this.nSteps = nSteps;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue