Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
apete committed Nov 24, 2019
1 parent 55ff509 commit e112d5b
Show file tree
Hide file tree
Showing 78 changed files with 1,008 additions and 1,008 deletions.
8 changes: 4 additions & 4 deletions src/org/ojalgo/algebra/ScalarOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface Addition<T, N extends Comparable<N>> extends ScalarOperation {
/**
* @return <code>this + scalarAddend</code>.
*/
default T add(float scalarAddend) {
default T add(final float scalarAddend) {
return this.add((double) scalarAddend);
}

Expand All @@ -57,7 +57,7 @@ public interface Division<T, N extends Comparable<N>> extends ScalarOperation {
/**
* @return <code>this / scalarDivisor</code>.
*/
default T divide(float scalarDivisor) {
default T divide(final float scalarDivisor) {
return this.divide((double) scalarDivisor);
}

Expand All @@ -78,7 +78,7 @@ public interface Multiplication<T, N extends Comparable<N>> extends ScalarOperat
/**
* @return <code>this * scalarMultiplicand</code>.
*/
default T multiply(float scalarMultiplicand) {
default T multiply(final float scalarMultiplicand) {
return this.multiply((double) scalarMultiplicand);
}

Expand All @@ -99,7 +99,7 @@ public interface Subtraction<T, N extends Comparable<N>> extends ScalarOperation
/**
* @return <code>this - scalarSubtrahend</code>.
*/
default T subtract(float scalarSubtrahend) {
default T subtract(final float scalarSubtrahend) {
return this.subtract((double) scalarSubtrahend);
}

Expand Down
8 changes: 4 additions & 4 deletions src/org/ojalgo/array/Array1D.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public Array1D<N> make(final long count) {
return this.makeDense(count);
}

public Array1D<N> makeDense(final long count) {
return myDelegate.makeToBeFilled(count).wrapInArray1D();
}

public Array1D<N> makeFilled(final long count, final NullaryFunction<?> supplier) {
return myDelegate.makeFilled(count, supplier).wrapInArray1D();
}
Expand All @@ -106,10 +110,6 @@ public Array1D<N> wrap(final BasicArray<N> array) {
return array.wrapInArray1D();
}

public Array1D<N> makeDense(long count) {
return myDelegate.makeToBeFilled(count).wrapInArray1D();
}

}

static final class QuickAscendingSorter extends RecursiveAction {
Expand Down
8 changes: 4 additions & 4 deletions src/org/ojalgo/array/Array2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ public Array2D<N> make(final long rows, final long columns) {
return this.makeDense(rows, columns);
}

public Array2D<N> makeDense(final long rows, final long columns) {
return myDelegate.makeToBeFilled(rows, columns).wrapInArray2D(rows);
}

public Array2D<N> makeFilled(final long rows, final long columns, final NullaryFunction<?> supplier) {

final BasicArray<N> tmpDelegate = myDelegate.makeToBeFilled(rows, columns);
Expand Down Expand Up @@ -257,10 +261,6 @@ public Scalar.Factory<N> scalar() {
return myDelegate.scalar();
}

public Array2D<N> makeDense(long rows, long columns) {
return myDelegate.makeToBeFilled(rows, columns).wrapInArray2D(rows);
}

}

public static final Factory<BigDecimal> BIG = new Factory<>(BigArray.FACTORY);
Expand Down
42 changes: 21 additions & 21 deletions src/org/ojalgo/array/ArrayAnyD.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public FunctionSet<N> function() {
return myDelegate.function();
}

@Override
public ArrayAnyD<N> make(final long... structure) {
return this.makeDense(structure);
}

public ArrayAnyD<N> makeDense(final long... structure) {
return myDelegate.makeToBeFilled(structure).wrapInArrayAnyD(structure);
}

/**
* @deprecated v48 Use {@link ArrayAnyD#fillAll(NullaryFunction)}
*/
Expand All @@ -87,20 +96,11 @@ public ArrayAnyD<N> makeSparse(final long... structure) {
return myDelegate.makeStructuredZero(structure).wrapInArrayAnyD(structure);
}

@Override
public ArrayAnyD<N> make(final long... structure) {
return this.makeDense(structure);
}

@Override
public Scalar.Factory<N> scalar() {
return myDelegate.scalar();
}

public ArrayAnyD<N> makeDense(long... structure) {
return myDelegate.makeToBeFilled(structure).wrapInArrayAnyD(structure);
}

}

public static final Factory<BigDecimal> BIG = new Factory<>(BigArray.FACTORY);
Expand Down Expand Up @@ -133,32 +133,32 @@ private ArrayAnyD() {
}

@Override
public void add(final long index, final double addend) {
public void add(final long index, final Comparable<?> addend) {
myDelegate.add(index, addend);
}

@Override
public void add(final long index, final float addend) {
public void add(final long index, final double addend) {
myDelegate.add(index, addend);
}

@Override
public void add(final long index, final Comparable<?> addend) {
public void add(final long index, final float addend) {
myDelegate.add(index, addend);
}

@Override
public void add(final long[] reference, final double addend) {
public void add(final long[] reference, final Comparable<?> addend) {
myDelegate.add(StructureAnyD.index(myStructure, reference), addend);
}

@Override
public void add(final long[] reference, final float addend) {
public void add(final long[] reference, final double addend) {
myDelegate.add(StructureAnyD.index(myStructure, reference), addend);
}

@Override
public void add(final long[] reference, final Comparable<?> addend) {
public void add(final long[] reference, final float addend) {
myDelegate.add(StructureAnyD.index(myStructure, reference), addend);
}

Expand Down Expand Up @@ -456,32 +456,32 @@ public Array2D<N> reduce(final int rowDimension, final int columnDimension, fina
}

@Override
public void set(final long index, final double value) {
public void set(final long index, final Comparable<?> value) {
myDelegate.set(index, value);
}

@Override
public void set(final long index, final float value) {
public void set(final long index, final double value) {
myDelegate.set(index, value);
}

@Override
public void set(final long index, final Comparable<?> value) {
public void set(final long index, final float value) {
myDelegate.set(index, value);
}

@Override
public void set(final long[] reference, final double value) {
public void set(final long[] reference, final Comparable<?> value) {
myDelegate.set(StructureAnyD.index(myStructure, reference), value);
}

@Override
public void set(final long[] reference, final float value) {
public void set(final long[] reference, final double value) {
myDelegate.set(StructureAnyD.index(myStructure, reference), value);
}

@Override
public void set(final long[] reference, final Comparable<?> value) {
public void set(final long[] reference, final float value) {
myDelegate.set(StructureAnyD.index(myStructure, reference), value);
}

Expand Down
26 changes: 13 additions & 13 deletions src/org/ojalgo/array/ArrayFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public final I copy(final Access1D<?> source) {
return retVal;
}

public final I copy(final Comparable<?>... source) {
final int length = source.length;
final I retVal = this.makeToBeFilled(length);
for (int i = 0; i < length; i++) {
retVal.set(i, source[i]);
}
return retVal;
}

public final I copy(final double... source) {
final int length = source.length;
final I retVal = this.makeToBeFilled(length);
Expand All @@ -62,17 +71,12 @@ public final I copy(final List<? extends Comparable<?>> source) {
return retVal;
}

public final I copy(final Comparable<?>... source) {
final int length = source.length;
final I retVal = this.makeToBeFilled(length);
for (int i = 0; i < length; i++) {
retVal.set(i, source[i]);
}
return retVal;
}

public abstract FunctionSet<N> function();

public final I make(final long count) {
return this.makeStructuredZero(count);
}

public final I makeFilled(final long count, final NullaryFunction<?> supplier) {
final I retVal = this.makeToBeFilled(count);
if (retVal.isPrimitive()) {
Expand All @@ -87,10 +91,6 @@ public final I makeFilled(final long count, final NullaryFunction<?> supplier) {
return retVal;
}

public final I make(final long count) {
return this.makeStructuredZero(count);
}

public abstract Scalar.Factory<N> scalar();

abstract long getCapacityLimit();
Expand Down
24 changes: 12 additions & 12 deletions src/org/ojalgo/array/BigArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public void sortDescending() {
Arrays.parallelSort(data, Comparator.reverseOrder());
}

@Override
protected final void add(final int index, final Comparable<?> addend) {
this.fillOne(index, this.get(index).add(this.valueOf(addend)));
}

@Override
protected final void add(final int index, final double addend) {
this.fillOne(index, this.get(index).add(this.valueOf(addend)));
Expand All @@ -131,8 +136,13 @@ protected final void add(final int index, final float addend) {
}

@Override
protected final void add(final int index, final Comparable<?> addend) {
this.fillOne(index, this.get(index).add(this.valueOf(addend)));
protected final double doubleValue(final int index) {
return data[index].doubleValue();
}

@Override
protected final void fillOne(final int index, final Access1D<?> values, final long valueIndex) {
data[index] = this.valueOf(values.get(valueIndex));
}

@Override
Expand All @@ -150,14 +160,4 @@ protected boolean isSmall(final int index, final double comparedTo) {
return BigScalar.isSmall(comparedTo, data[index]);
}

@Override
protected final double doubleValue(final int index) {
return data[index].doubleValue();
}

@Override
protected final void fillOne(final int index, final Access1D<?> values, final long valueIndex) {
data[index] = this.valueOf(values.get(valueIndex));
}

}
10 changes: 5 additions & 5 deletions src/org/ojalgo/array/BufferArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ public int size() {
return myBuffer.capacity();
}

@Override
protected void add(final int index, final Comparable<?> addend) {
this.set(index, this.doubleValue(index) + Scalar.doubleValue(addend));
}

@Override
protected void add(final int index, final double addend) {
this.set(index, this.doubleValue(index) + addend);
Expand All @@ -398,11 +403,6 @@ protected void add(final int index, final float addend) {
this.set(index, this.floatValue(index) + addend);
}

@Override
protected void add(final int index, final Comparable<?> addend) {
this.set(index, this.doubleValue(index) + Scalar.doubleValue(addend));
}

@Override
protected void exchange(final int firstA, final int firstB, final int step, final int count) {

Expand Down
12 changes: 6 additions & 6 deletions src/org/ojalgo/array/NumberList.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void add(final int index, final N element) {
}

@Override
public void add(final long index, final double addend) {
public void add(final long index, final Comparable<?> addend) {
if (index >= myActualCount) {
throw new ArrayIndexOutOfBoundsException();
} else {
Expand All @@ -135,7 +135,7 @@ public void add(final long index, final double addend) {
}

@Override
public void add(final long index, final float addend) {
public void add(final long index, final double addend) {
if (index >= myActualCount) {
throw new ArrayIndexOutOfBoundsException();
} else {
Expand All @@ -144,7 +144,7 @@ public void add(final long index, final float addend) {
}

@Override
public void add(final long index, final Comparable<?> addend) {
public void add(final long index, final float addend) {
if (index >= myActualCount) {
throw new ArrayIndexOutOfBoundsException();
} else {
Expand Down Expand Up @@ -403,7 +403,7 @@ public N set(final int index, final N element) {
}

@Override
public void set(final long index, final double value) {
public void set(final long index, final Comparable<?> value) {
if (index >= myActualCount) {
throw new ArrayIndexOutOfBoundsException();
} else {
Expand All @@ -412,7 +412,7 @@ public void set(final long index, final double value) {
}

@Override
public void set(final long index, final float value) {
public void set(final long index, final double value) {
if (index >= myActualCount) {
throw new ArrayIndexOutOfBoundsException();
} else {
Expand All @@ -421,7 +421,7 @@ public void set(final long index, final float value) {
}

@Override
public void set(final long index, final Comparable<?> value) {
public void set(final long index, final float value) {
if (index >= myActualCount) {
throw new ArrayIndexOutOfBoundsException();
} else {
Expand Down
Loading

0 comments on commit e112d5b

Please sign in to comment.