You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2010/08/01 17:01:30 UTC

svn commit: r981238 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math: analysis/interpolation/ optimization/general/ optimization/univariate/ util/

Author: luc
Date: Sun Aug  1 15:01:30 2010
New Revision: 981238

URL: http://svn.apache.org/viewvc?rev=981238&view=rev
Log:
fixed another bunch of checkstyle warnings

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/AbstractUnivariateRealOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BracketFinder.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java?rev=981238&r1=981237&r2=981238&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java Sun Aug  1 15:01:30 2010
@@ -148,7 +148,7 @@ public class MicrosphereInterpolatingFun
                                             int brightnessExponent,
                                             int microsphereElements,
                                             UnitSphereRandomVectorGenerator rand)
-        throws DimensionMismatchException, IllegalArgumentException {
+        throws DimensionMismatchException, NoDataException {
         if (xval.length == 0 || xval[0] == null) {
             throw new NoDataException();
         }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java?rev=981238&r1=981237&r2=981238&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java Sun Aug  1 15:01:30 2010
@@ -37,6 +37,7 @@ import org.apache.commons.math.optimizat
  * A class that implements an optimization algorithm should inherit from
  * {@link AbstractScalarOptimizer} or from
  * {@link AbstractScalarDifferentiableOptimizer}.
+ * @param <T> the type of the objective function to be optimized
  *
  * @version $Revision$ $Date$
  * @since 2.2
@@ -120,8 +121,8 @@ public abstract class BaseAbstractScalar
     }
 
     /** {@inheritDoc} */
-    public void setConvergenceChecker(RealConvergenceChecker checker) {
-        this.checker = checker;
+    public void setConvergenceChecker(RealConvergenceChecker convergenceChecker) {
+        this.checker = convergenceChecker;
     }
 
     /** {@inheritDoc} */

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/AbstractUnivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/AbstractUnivariateRealOptimizer.java?rev=981238&r1=981237&r2=981238&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/AbstractUnivariateRealOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/AbstractUnivariateRealOptimizer.java Sun Aug  1 15:01:30 2010
@@ -46,13 +46,13 @@ public abstract class AbstractUnivariate
     /** Number of evaluations already performed. */
     private int evaluations;
     /** Optimization type */
-    private GoalType goal;
+    private GoalType optimizationGoal;
     /** Lower end of search interval. */
-    private double min;
+    private double searchMin;
     /** Higher end of search interval. */
-    private double max;
+    private double searchMax;
     /** Initial guess . */
-    private double startValue;
+    private double searchStart;
     /** Function to optimize. */
     private UnivariateRealFunction function;
 
@@ -155,25 +155,25 @@ public abstract class AbstractUnivariate
      * @return the optimization type.
      */
     public GoalType getGoalType() {
-        return goal;
+        return optimizationGoal;
     }
     /**
      * @return the lower of the search interval.
      */
     public double getMin() {
-        return min;
+        return searchMin;
     }
     /**
      * @return the higher of the search interval.
      */
     public double getMax() {
-        return max;
+        return searchMax;
     }
     /**
      * @return the initial guess.
      */
     public double getStartValue() {
-        return startValue;
+        return searchStart;
     }
 
     /**
@@ -215,15 +215,15 @@ public abstract class AbstractUnivariate
     }
 
     /** {@inheritDoc} */
-    public double optimize(UnivariateRealFunction function, GoalType goal,
+    public double optimize(UnivariateRealFunction f, GoalType goal,
                            double min, double max, double startValue)
         throws MaxIterationsExceededException, FunctionEvaluationException {
         // Initialize.
-        this.min = min;
-        this.max = max;
-        this.startValue = startValue;
-        this.goal = goal;
-        this.function = function;
+        this.searchMin = min;
+        this.searchMax = max;
+        this.searchStart = startValue;
+        this.optimizationGoal = goal;
+        this.function = f;
 
         // Reset.
         functionValue = Double.NaN;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BracketFinder.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BracketFinder.java?rev=981238&r1=981237&r2=981238&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BracketFinder.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BracketFinder.java Sun Aug  1 15:01:30 2010
@@ -228,24 +228,53 @@ public class BracketFinder {
 
     /**
      * @return the lower bound of the bracket.
+     * @see #getFLow()
      */
     public double getLo() {
         return lo;
     }
+
+    /**
+     * Get function value at {@link #getLo()}.
+     * @return function value at {@link #getLo()}
+     */
+    public double getFLow() {
+        return fLo;
+    }
+
     /**
      * @return the higher bound of the bracket.
+     * @see #getFHi()
      */
     public double getHi() {
         return hi;
     }
+
+    /**
+     * Get function value at {@link #getHi()}.
+     * @return function value at {@link #getHi()}
+     */
+    public double getFHi() {
+        return fHi;
+    }
+
     /**
      * @return a point in the middle of the bracket.
+     * @see #getFMid()
      */
     public double getMid() {
         return mid;
     }
 
     /**
+     * Get function value at {@link #getMid()}.
+     * @return function value at {@link #getMid()}
+     */
+    public double getFMid() {
+        return fMid;
+    }
+
+    /**
      * @param f Function.
      * @param x Argument.
      * @return {@code f(x)}

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=981238&r1=981237&r2=981238&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Sun Aug  1 15:01:30 2010
@@ -1868,10 +1868,18 @@ public final class MathUtils {
     }
 
     public static class Order {
+
+        /** Enumerate type for increasing/decreasing directions. */
         public static enum Direction {
-                INCREASING,
-                DECREASING
+
+            /** Constant for increasing direction. */
+            INCREASING,
+
+            /** Constant for decreasing direction. */
+            DECREASING
+
         };
+
     }
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java?rev=981238&r1=981237&r2=981238&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java Sun Aug  1 15:01:30 2010
@@ -140,7 +140,7 @@ public class MultidimensionalCounter imp
          * of the iterator.
          * @throws IndexOutOfBoundsException if {@code index} is not in the
          * correct interval (as defined by the length of the argument in the
-         * {@link #MultidimensionalCounter(int[])
+         * {@link MultidimensionalCounter#MultidimensionalCounter(int[])
          * constructor of the enclosing class}).
          */
         public int getCount(int dim) {
@@ -159,7 +159,7 @@ public class MultidimensionalCounter imp
      * Create a counter.
      *
      * @param size Counter sizes (number of slots in each dimension).
-     * @throws {@link NotStrictlyPositiveException} if one of the sizes is
+     * @throws NotStrictlyPositiveException if one of the sizes is
      * negative or zero.
      */
     public MultidimensionalCounter(int ... size) {
@@ -210,12 +210,12 @@ public class MultidimensionalCounter imp
      *
      * @param index Index in unidimensional counter.
      * @return the multidimensional counts.
-     * @throws {@link OutOfRangeException} if {@code index} is not between
+     * @throws OutOfRangeException if {@code index} is not between
      * {@code 0} and the value returned by {@link #getSize()} (excluded).
      */
     public int[] getCounts(int index) {
-        if (index < 0
-            || index >= totalSize) {
+        if (index < 0 ||
+            index >= totalSize) {
             throw new OutOfRangeException(index, 0, totalSize);
         }
 
@@ -250,21 +250,21 @@ public class MultidimensionalCounter imp
      *
      * @param c Indices in multidimensional counter.
      * @return the index within the unidimensionl counter.
-     * @throws {@link DimensionMismatchException} if the size of {@code c}
-     * does not match the size of the array given in the contructor.
-     * @throws {@link OutOfRangeException} if a value of {@code c} is not in
+     * @throws DimensionMismatchException if the size of {@code c}
+     * does not match the size of the array given in the constructor.
+     * @throws OutOfRangeException if a value of {@code c} is not in
      * the range of the corresponding dimension, as defined in the
-     * {@link #MultidimensionalCounter(int[]) constructor}.
+     * {@link MultidimensionalCounter#MultidimensionalCounter(int...) constructor}.
      */
-    public int getCount(int ... c) {
+    public int getCount(int ... c) throws OutOfRangeException {
         if (c.length != dimension) {
             throw new DimensionMismatchException(c.length, dimension);
         }
         int count = 0;
         for (int i = 0; i < dimension; i++) {
             final int index = c[i];
-            if (index < 0
-                || index >= size[i]) {
+            if (index < 0 ||
+                index >= size[i]) {
                 throw new OutOfRangeException(index, 0, size[i] - 1);
             }
             count += uniCounterOffset[i] * c[i];



Re: svn commit: r981238 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math: analysis/interpolation/ optimization/general/ optimization/univariate/ util/

Posted by Luc Maisonobe <Lu...@free.fr>.
Le 01/08/2010 20:56, Luc Maisonobe a écrit :
> Le 01/08/2010 19:06, Gilles Sadowski a écrit :
>>>      /** {@inheritDoc} */
>>> -    public void setConvergenceChecker(RealConvergenceChecker checker) {
>>> -        this.checker = checker;
>>> +    public void setConvergenceChecker(RealConvergenceChecker convergenceChecker) {
>>> +        this.checker = convergenceChecker;
>>>      }
>>
>> Why does "checkstyle" complain about the name "checker" for the parameter?
> 
> It hides a field.

To be more precise, it hides a field and the name of the field is not
exactly the name of the set method (checkstyle recognizes setters and we
have set up a configuration were hiding a field in a setter was allowed).


> 
>>
>>> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
>>> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=981238&r1=981237&r2=981238&view=diff
>>> ==============================================================================
>>> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original)
>>> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Sun Aug  1 15:01:30 2010
>>> @@ -1868,10 +1868,18 @@ public final class MathUtils {
>>>      }
>>>  
>>>      public static class Order {
>>> +
>>> +        /** Enumerate type for increasing/decreasing directions. */
>>>          public static enum Direction {
>>> -                INCREASING,
>>> -                DECREASING
>>> +
>>> +            /** Constant for increasing direction. */
>>> +            INCREASING,
>>> +
>>> +            /** Constant for decreasing direction. */
>>> +            DECREASING
>>
>> Indeed, I don't know why I had created a two-level enum...
>> Although, maybe it was because I was thinking that we could put other
>> "characteristics" there, such as "strictness" (which now is specified
>> through a boolean).
> 
> The perhaps we could revert to one level only ?
> 
>>
>>> -     * @throws {@link NotStrictlyPositiveException} if one of the sizes is
>>> +     * @throws NotStrictlyPositiveException if one of the sizes is
>>
>> Does Javadoc automatically create an HTML link for the argument of the
>> "@throws" tag?
>>
>>> -    public int getCount(int ... c) {
>>> +    public int getCount(int ... c) throws OutOfRangeException {
>>
>> Does "checkstyle" complain about unchecked exceptions not appearing in the
>> throws clause?
> 
> It depends on the configuration. The current setting we have in [math]
> is to allow missing RuntimeException. This specific change is an error
> from me. I tried different solutions because checkstyle had a problem
> with this file and stopped with an error. Feel free to revert it.
> 
>> On the one hand I would agree to put unchecked exceptions if it prevents
>> tools from complaining about unused "import". On the other hand, it is
>> considered to be bad programming style since it cannot mean that only the
>> unchecked exceptions referred to there can actually be thrown.
> 
> I'm on the fence here. Personnally I would like to have all exceptions
> declared and checkstyle could help us here if we adjust its setting. But
> we did set it up this way and I don't remember why.
> 
> Luc
> 
>>
>>
>> Gilles
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r981238 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math: analysis/interpolation/ optimization/general/ optimization/univariate/ util/

Posted by Luc Maisonobe <Lu...@free.fr>.
Le 01/08/2010 19:06, Gilles Sadowski a écrit :
>>      /** {@inheritDoc} */
>> -    public void setConvergenceChecker(RealConvergenceChecker checker) {
>> -        this.checker = checker;
>> +    public void setConvergenceChecker(RealConvergenceChecker convergenceChecker) {
>> +        this.checker = convergenceChecker;
>>      }
> 
> Why does "checkstyle" complain about the name "checker" for the parameter?

It hides a field.

> 
>> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
>> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=981238&r1=981237&r2=981238&view=diff
>> ==============================================================================
>> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original)
>> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Sun Aug  1 15:01:30 2010
>> @@ -1868,10 +1868,18 @@ public final class MathUtils {
>>      }
>>  
>>      public static class Order {
>> +
>> +        /** Enumerate type for increasing/decreasing directions. */
>>          public static enum Direction {
>> -                INCREASING,
>> -                DECREASING
>> +
>> +            /** Constant for increasing direction. */
>> +            INCREASING,
>> +
>> +            /** Constant for decreasing direction. */
>> +            DECREASING
> 
> Indeed, I don't know why I had created a two-level enum...
> Although, maybe it was because I was thinking that we could put other
> "characteristics" there, such as "strictness" (which now is specified
> through a boolean).

The perhaps we could revert to one level only ?

> 
>> -     * @throws {@link NotStrictlyPositiveException} if one of the sizes is
>> +     * @throws NotStrictlyPositiveException if one of the sizes is
> 
> Does Javadoc automatically create an HTML link for the argument of the
> "@throws" tag?
> 
>> -    public int getCount(int ... c) {
>> +    public int getCount(int ... c) throws OutOfRangeException {
> 
> Does "checkstyle" complain about unchecked exceptions not appearing in the
> throws clause?

It depends on the configuration. The current setting we have in [math]
is to allow missing RuntimeException. This specific change is an error
from me. I tried different solutions because checkstyle had a problem
with this file and stopped with an error. Feel free to revert it.

> On the one hand I would agree to put unchecked exceptions if it prevents
> tools from complaining about unused "import". On the other hand, it is
> considered to be bad programming style since it cannot mean that only the
> unchecked exceptions referred to there can actually be thrown.

I'm on the fence here. Personnally I would like to have all exceptions
declared and checkstyle could help us here if we adjust its setting. But
we did set it up this way and I don't remember why.

Luc

> 
> 
> Gilles
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r981238 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math: analysis/interpolation/ optimization/general/ optimization/univariate/ util/

Posted by Gilles Sadowski <gi...@harfang.homelinux.org>.
>      /** {@inheritDoc} */
> -    public void setConvergenceChecker(RealConvergenceChecker checker) {
> -        this.checker = checker;
> +    public void setConvergenceChecker(RealConvergenceChecker convergenceChecker) {
> +        this.checker = convergenceChecker;
>      }

Why does "checkstyle" complain about the name "checker" for the parameter?

> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=981238&r1=981237&r2=981238&view=diff
> ==============================================================================
> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original)
> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Sun Aug  1 15:01:30 2010
> @@ -1868,10 +1868,18 @@ public final class MathUtils {
>      }
>  
>      public static class Order {
> +
> +        /** Enumerate type for increasing/decreasing directions. */
>          public static enum Direction {
> -                INCREASING,
> -                DECREASING
> +
> +            /** Constant for increasing direction. */
> +            INCREASING,
> +
> +            /** Constant for decreasing direction. */
> +            DECREASING

Indeed, I don't know why I had created a two-level enum...
Although, maybe it was because I was thinking that we could put other
"characteristics" there, such as "strictness" (which now is specified
through a boolean).

> -     * @throws {@link NotStrictlyPositiveException} if one of the sizes is
> +     * @throws NotStrictlyPositiveException if one of the sizes is

Does Javadoc automatically create an HTML link for the argument of the
"@throws" tag?

> -    public int getCount(int ... c) {
> +    public int getCount(int ... c) throws OutOfRangeException {

Does "checkstyle" complain about unchecked exceptions not appearing in the
throws clause?
On the one hand I would agree to put unchecked exceptions if it prevents
tools from complaining about unused "import". On the other hand, it is
considered to be bad programming style since it cannot mean that only the
unchecked exceptions referred to there can actually be thrown.


Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org