commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r1343163 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/linear/ test/java/org/apache/commons/math3/linear/
Date Mon, 28 May 2012 10:26:24 GMT
2012/5/28 Gilles Sadowski <gilles@harfang.homelinux.org>:
> Hi Sébastien.
>
>> [...]
>> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
>> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java?rev=1343163&r1=1343162&r2=1343163&view=diff
>> ==============================================================================
>> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
(original)
>> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
Mon May 28 08:31:13 2012
>> @@ -22,6 +22,7 @@ import java.util.NoSuchElementException;
>>
>>  import org.apache.commons.math3.exception.MathUnsupportedOperationException;
>>  import org.apache.commons.math3.exception.DimensionMismatchException;
>> +import org.apache.commons.math3.exception.NumberIsTooSmallException;
>>  import org.apache.commons.math3.exception.OutOfRangeException;
>>  import org.apache.commons.math3.exception.MathArithmeticException;
>>  import org.apache.commons.math3.analysis.FunctionUtils;
>> @@ -191,6 +192,37 @@ public abstract class RealVector {
>>      }
>>
>>      /**
>> +     * Checks that the indices of a subvector are valid.
>> +     *
>> +     * @param start the index of the first entry of the subvector
>> +     * @param end the index of the last entry of the subvector (inclusive)
>> +     * @throws OutOfRangeException if {@code start} of {@code end} are not valid
>> +     * @throws NumberIsTooSmallException if {@code end < start}
>> +     */
>> +    protected void checkIndices(final int start, final int end) {
>> +        final int dim = getDimension();
>> +        if ((start < 0) || (start >= dim)) {
>> +            throw new OutOfRangeException(LocalizedFormats.INDEX,
>> +                                          Integer.valueOf(start),
>                                             ^^^^^^^^^^^^^^^
>
> Why do you call "valueOf"?
>

I am not Sébastien, but this should be obvious:

The constructor used here is

public OutOfRangeException(Localizable specific,
Number wrong,
Number lo,
Number hi)

Integer.valueOf() is the best way to convert  int -> Integer


Best regards,
Konstantin  Kolinko
>> +                                          Integer.valueOf(0),
>> +                                          Integer.valueOf(dim
- 1));
>> +        }
>> +        if ((end < 0) || (end >= dim)) {
>> +            throw new OutOfRangeException(LocalizedFormats.INDEX,
>> +                                          Integer.valueOf(end),
>> +                                          Integer.valueOf(0),
>> +                                          Integer.valueOf(dim
- 1));
>> +        }
>> +        if (end < start){
>> +            // TODO Use more specific error message
>> +            throw new NumberIsTooSmallException(LocalizedFormats.INITIAL_ROW_AFTER_FINAL_ROW,
>> +                                                Integer.valueOf(end),
>> +                                                Integer.valueOf(start),
>> +                                                false);
>> +        }
>> +    }
>

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


Mime
View raw message