From b6040640af9502c2a592cc44638e9a8a9d80f900 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Fri, 4 Nov 2011 09:54:30 +0000 Subject: [PATCH] Unnecessary casts git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1197468 13f79535-47bb-0310-9956-ffa450edef68 --- .../math/geometry/euclidean/oned/IntervalsSet.java | 2 +- .../geometry/euclidean/threed/OutlineExtractor.java | 4 ++-- .../math/geometry/euclidean/threed/Plane.java | 2 +- .../math/geometry/euclidean/threed/SubPlane.java | 4 ++-- .../math/geometry/euclidean/twod/SubLine.java | 4 ++-- .../math/geometry/partitioning/AbstractRegion.java | 2 +- .../commons/math/linear/ArrayRealVectorTest.java | 12 ++++++------ .../math/random/EmpiricalDistributionTest.java | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/commons/math/geometry/euclidean/oned/IntervalsSet.java b/src/main/java/org/apache/commons/math/geometry/euclidean/oned/IntervalsSet.java index 45149e218..191af4890 100644 --- a/src/main/java/org/apache/commons/math/geometry/euclidean/oned/IntervalsSet.java +++ b/src/main/java/org/apache/commons/math/geometry/euclidean/oned/IntervalsSet.java @@ -234,7 +234,7 @@ public class IntervalsSet extends AbstractRegion { if ((checkPoint(low, loc) == Location.INSIDE) && (checkPoint(high, loc) == Location.INSIDE)) { // merge the last interval added and the first one of the high sub-tree - x = ((Interval) list.remove(list.size() - 1)).getLower(); + x = list.remove(list.size() - 1).getLower(); } recurseList(high, list, x, upper); diff --git a/src/main/java/org/apache/commons/math/geometry/euclidean/threed/OutlineExtractor.java b/src/main/java/org/apache/commons/math/geometry/euclidean/threed/OutlineExtractor.java index 060ea35f7..3eb4be0d7 100644 --- a/src/main/java/org/apache/commons/math/geometry/euclidean/threed/OutlineExtractor.java +++ b/src/main/java/org/apache/commons/math/geometry/euclidean/threed/OutlineExtractor.java @@ -199,13 +199,13 @@ public class OutlineExtractor { for (Vector2D[] loop : vertices) { final boolean closed = loop[0] != null; int previous = closed ? (loop.length - 1) : 1; - Vector3D previous3D = (Vector3D) plane.toSpace(loop[previous]); + Vector3D previous3D = plane.toSpace(loop[previous]); int current = (previous + 1) % loop.length; Vector2D pPoint = new Vector2D(previous3D.dotProduct(u), previous3D.dotProduct(v)); while (current < loop.length) { - final Vector3D current3D = (Vector3D) plane.toSpace(loop[current]); + final Vector3D current3D = plane.toSpace(loop[current]); final Vector2D cPoint = new Vector2D(current3D.dotProduct(u), current3D.dotProduct(v)); final org.apache.commons.math.geometry.euclidean.twod.Line line = diff --git a/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Plane.java b/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Plane.java index 619b4a938..cb5eadb8d 100644 --- a/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Plane.java +++ b/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Plane.java @@ -308,7 +308,7 @@ public class Plane implements Hyperplane, Embedding { final Plane otherPlane = (Plane) hyperplane; final Plane thisPlane = (Plane) getHyperplane(); - final Line inter = (Line) otherPlane.intersection(thisPlane); + final Line inter = otherPlane.intersection(thisPlane); if (inter == null) { // the hyperplanes are parallel, @@ -98,7 +98,7 @@ public class SubPlane extends AbstractSubHyperplane { final Plane otherPlane = (Plane) hyperplane; final Plane thisPlane = (Plane) getHyperplane(); - final Line inter = (Line) otherPlane.intersection(thisPlane); + final Line inter = otherPlane.intersection(thisPlane); if (inter == null) { // the hyperplanes are parallel diff --git a/src/main/java/org/apache/commons/math/geometry/euclidean/twod/SubLine.java b/src/main/java/org/apache/commons/math/geometry/euclidean/twod/SubLine.java index 3e3f67010..97e2ff0e9 100644 --- a/src/main/java/org/apache/commons/math/geometry/euclidean/twod/SubLine.java +++ b/src/main/java/org/apache/commons/math/geometry/euclidean/twod/SubLine.java @@ -164,7 +164,7 @@ public class SubLine extends AbstractSubHyperplane { // the lines do intersect final boolean direct = FastMath.sin(thisLine.getAngle() - otherLine.getAngle()) < 0; - final Vector1D x = (Vector1D) thisLine.toSubSpace(crossing); + final Vector1D x = thisLine.toSubSpace(crossing); return getRemainingRegion().side(new OrientedPoint(x, direct)); } @@ -187,7 +187,7 @@ public class SubLine extends AbstractSubHyperplane { // the lines do intersect final boolean direct = FastMath.sin(thisLine.getAngle() - otherLine.getAngle()) < 0; - final Vector1D x = (Vector1D) thisLine.toSubSpace(crossing); + final Vector1D x = thisLine.toSubSpace(crossing); final SubHyperplane subPlus = new OrientedPoint(x, !direct).wholeHyperplane(); final SubHyperplane subMinus = new OrientedPoint(x, direct).wholeHyperplane(); diff --git a/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java b/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java index 7cf7b5cf6..2fa1cc112 100644 --- a/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java +++ b/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java @@ -605,7 +605,7 @@ public abstract class AbstractRegion implement * transform to the instance */ public AbstractRegion applyTransform(final Transform transform) { - return (AbstractRegion) buildNew(recurseTransform(getTree(false), transform)); + return buildNew(recurseTransform(getTree(false), transform)); } /** Recursively transform an inside/outside BSP-tree. diff --git a/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java b/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java index 6deac6e7a..c4bf3cf77 100644 --- a/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java +++ b/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java @@ -956,7 +956,7 @@ public class ArrayRealVectorTest { Assert.assertEquals("compare values ", v1.subtract(v2).getNorm(),dist_2, normTolerance); //octave = sqrt(sumsq(v1-v2)) - double dist_3 = v1.getDistance((RealVector) v2); + double dist_3 = v1.getDistance(v2); Assert.assertEquals("compare values ", v1.subtract(v2).getNorm(),dist_3, normTolerance); //octave = ??? @@ -966,7 +966,7 @@ public class ArrayRealVectorTest { double d_getL1Distance_2 = v1.getL1Distance(v2_t); Assert.assertEquals("compare values ", 9d, d_getL1Distance_2, normTolerance); - double d_getL1Distance_3 = v1.getL1Distance((RealVector) v2); + double d_getL1Distance_3 = v1.getL1Distance(v2); Assert.assertEquals("compare values ", 9d, d_getL1Distance_3, normTolerance); //octave = ??? @@ -976,7 +976,7 @@ public class ArrayRealVectorTest { double d_getLInfDistance_2 = v1. getLInfDistance(v2_t); Assert.assertEquals("compare values ", 3d, d_getLInfDistance_2, normTolerance); - double d_getLInfDistance_3 = v1. getLInfDistance((RealVector) v2); + double d_getLInfDistance_3 = v1. getLInfDistance(v2); Assert.assertEquals("compare values ", 3d, d_getLInfDistance_3, normTolerance); //octave = v1 + v2 @@ -1007,7 +1007,7 @@ public class ArrayRealVectorTest { double[] result_ebeMultiply_2 = {4d, 10d, 18d}; assertClose("compare vect" ,v_ebeMultiply_2.toArray(),result_ebeMultiply_2,normTolerance); - RealVector v_ebeMultiply_3 = v1.ebeMultiply((RealVector) v2); + RealVector v_ebeMultiply_3 = v1.ebeMultiply(v2); double[] result_ebeMultiply_3 = {4d, 10d, 18d}; assertClose("compare vect" ,v_ebeMultiply_3.toArray(),result_ebeMultiply_3,normTolerance); @@ -1020,7 +1020,7 @@ public class ArrayRealVectorTest { double[] result_ebeDivide_2 = {0.25d, 0.4d, 0.5d}; assertClose("compare vect" ,v_ebeDivide_2.toArray(),result_ebeDivide_2,normTolerance); - RealVector v_ebeDivide_3 = v1.ebeDivide((RealVector) v2); + RealVector v_ebeDivide_3 = v1.ebeDivide(v2); double[] result_ebeDivide_3 = {0.25d, 0.4d, 0.5d}; assertClose("compare vect" ,v_ebeDivide_3.toArray(),result_ebeDivide_3,normTolerance); @@ -1038,7 +1038,7 @@ public class ArrayRealVectorTest { RealMatrix m_outerProduct_2 = v1.outerProduct(v2_t); Assert.assertEquals("compare val ",4d, m_outerProduct_2.getEntry(0,0), normTolerance); - RealMatrix m_outerProduct_3 = v1.outerProduct((RealVector) v2); + RealMatrix m_outerProduct_3 = v1.outerProduct(v2); Assert.assertEquals("compare val ",4d, m_outerProduct_3.getEntry(0,0), normTolerance); RealVector v_unitVector = v1.unitVector(); diff --git a/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java b/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java index 9b322b12e..a326b0b4b 100644 --- a/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java +++ b/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java @@ -105,7 +105,7 @@ public final class EmpiricalDistributionTest { Assert.assertEquals(empiricalDistribution2.getSampleStats().getStandardDeviation(), 1.0173699343977738,10E-7); - double[] bounds = ((EmpiricalDistributionImpl) empiricalDistribution2).getGeneratorUpperBounds(); + double[] bounds = empiricalDistribution2.getGeneratorUpperBounds(); Assert.assertEquals(bounds.length, 100); Assert.assertEquals(bounds[99], 1.0, 10e-12);