Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ public String nextHexString(int len,
final byte[] hash = alg.digest();

// Loop over the hash, converting each byte to 2 hex digits
for (int i = 0; i < hash.length; i++) {
final Integer c = Integer.valueOf(hash[i]);
for (byte hash1 : hash) {
final Integer c = Integer.valueOf(hash1);

// Add 128 to byte value to make interval 0-255.
// This guarantees <= 2 hex digits from "toHexString".
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/commons/math4/stat/StatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ public static double[] normalize(final double[] sample) {
DescriptiveStatistics stats = new DescriptiveStatistics();

// Add the data from the series to stats
for (int i = 0; i < sample.length; i++) {
stats.addValue(sample[i]);
for (double v : sample) {
stats.addValue(v);
}

// Compute mean and standard deviation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,8 @@ public RegressionResults regress(int numberOfRegressors) throws ModelSpecificati
double[] cov = this.cov(numberOfRegressors);

int rnk = 0;
for (int i = 0; i < this.lindep.length; i++) {
if (!this.lindep[i]) {
for (boolean b : this.lindep) {
if (!b) {
++rnk;
}
}
Expand Down Expand Up @@ -1034,9 +1034,9 @@ public RegressionResults regress(int[] variablesToInclude) throws ModelSpecifica
if (iExclude > 0) {
int j = 0;
series = new int[variablesToInclude.length - iExclude];
for (int i = 0; i < variablesToInclude.length; i++) {
if (variablesToInclude[i] > -1) {
series[j] = variablesToInclude[i];
for (int i1 : variablesToInclude) {
if (i1 > -1) {
series[j] = i1;
++j;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ public void removeData(final double x,final double y) {
* greater than or equal to 2
*/
public void addData(final double[][] data) throws ModelSpecificationException {
for (int i = 0; i < data.length; i++) {
if( data[i].length < 2 ){
throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
data[i].length, 2);
for (double[] datum : data) {
if (datum.length < 2) {
throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
datum.length, 2);
}
addData(data[i][0], data[i][1]);
addData(datum[0], datum[1]);
}
}

Expand Down Expand Up @@ -301,8 +301,8 @@ public void addObservations(final double[][] x,final double[] y) throws ModelSpe
(y == null) ? 0 : y.length);
}
boolean obsOk=true;
for( int i = 0 ; i < x.length; i++){
if( x[i] == null || x[i].length == 0 ){
for (double[] x1 : x) {
if (x1 == null || x1.length == 0) {
obsOk = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public static Number parseNumber(final String source, final NumberFormat format,
final double[] special = {
Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY
};
for (int i = 0; i < special.length; ++i) {
number = parseNumber(source, special[i], pos);
for (double v : special) {
number = parseNumber(source, v, pos);
if (number != null) {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/apache/commons/math4/util/MathArrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,9 @@ public static double[] concatenate(double[] ...x) {
int offset = 0;
int curLength = 0;
final double[] combined = new double[combinedLength];
for (int i = 0; i < x.length; i++) {
curLength = x[i].length;
System.arraycopy(x[i], 0, combined, offset, curLength);
for (double[] x1 : x) {
curLength = x1.length;
System.arraycopy(x1, 0, combined, offset, curLength);
offset += curLength;
}
return combined;
Expand Down