Skip to content

Commit 8db3386

Browse files
committed
NumberContext
1 parent c001583 commit 8db3386

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+555
-206
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="src" path="test"/>
5-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
66
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
77
<classpathentry kind="output" path="bin"/>
88
</classpath>

.settings/org.eclipse.jdt.core.prefs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
33
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
55
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6-
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.compliance=1.7
77
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
88
org.eclipse.jdt.core.compiler.debug.localVariable=generate
99
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
1010
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
1111
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12-
org.eclipse.jdt.core.compiler.source=1.8
12+
org.eclipse.jdt.core.compiler.source=1.7

src/org/ojalgo/access/Access1D.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,16 @@ public interface Elements extends Structure1D {
5858

5959
/**
6060
* @see Scalar#isZero()
61+
* @deprecated v37
6162
*/
63+
@Deprecated
6264
boolean isZero(long index);
6365

66+
/**
67+
* @see Scalar#isSmall(double)
68+
*/
69+
boolean isSmall(long index, double comparedTo);
70+
6471
}
6572

6673
public interface Factory<I extends Access1D<?>> {

src/org/ojalgo/access/Access2D.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,16 @@ public interface Elements extends Structure2D, Access1D.Elements {
6868

6969
/**
7070
* @see Scalar#isZero()
71+
* @deprecated v37
7172
*/
73+
@Deprecated
7274
boolean isZero(long row, long column);
7375

76+
/**
77+
* @see Scalar#isSmall(double)
78+
*/
79+
boolean isSmall(long row, long column, double comparedTo);
80+
7481
}
7582

7683
public interface Factory<I extends Access2D<?>> {

src/org/ojalgo/access/AccessAnyD.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public interface Elements extends StructureAnyD, Access1D.Elements {
6161
*/
6262
boolean isZero(long[] reference);
6363

64+
/**
65+
* @see Scalar#isSmall(double)
66+
*/
67+
boolean isSmall(long[] reference, double comparedTo);
68+
6469
}
6570

6671
public interface Factory<I extends AccessAnyD<?>> {

src/org/ojalgo/access/AccessUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,14 @@ public static boolean equals(final Access1D<?> accessA, final Access1D<?> access
500500
final Access1D<ComplexNumber> tmpAccessB = (Access1D<ComplexNumber>) accessB;
501501

502502
for (int i = 0; retVal && (i < tmpLength); i++) {
503-
retVal &= context.isSmallError(tmpAccessA.get(i).doubleValue(), tmpAccessB.get(i).doubleValue());
504-
retVal &= context.isSmallError(tmpAccessA.get(i).i, tmpAccessB.get(i).i);
503+
retVal &= !context.isDifferent(tmpAccessA.get(i).getReal(), tmpAccessB.get(i).getReal());
504+
retVal &= !context.isDifferent(tmpAccessA.get(i).i, tmpAccessB.get(i).i);
505505
}
506506

507507
} else {
508508

509509
for (int i = 0; retVal && (i < tmpLength); i++) {
510-
retVal &= context.isSmallError(accessA.doubleValue(i), accessB.doubleValue(i));
510+
retVal &= !context.isDifferent(accessA.doubleValue(i), accessB.doubleValue(i));
511511
}
512512
}
513513

src/org/ojalgo/array/Array1D.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* @author apete
4747
*/
4848
public final class Array1D<N extends Number> extends AbstractList<N> implements Access1D<N>, Access1D.Elements, Access1D.Fillable<N>, Access1D.Modifiable<N>,
49-
Access1D.Visitable<N>, RandomAccess, Serializable {
49+
Access1D.Visitable<N>, RandomAccess, Serializable {
5050

5151
public static abstract class Factory<N extends Number> implements Access1D.Factory<Array1D<N>> {
5252

@@ -398,6 +398,10 @@ public boolean isRangeZeros(final long first, final long limit) {
398398
return myDelegate.isZeros((myFirst + (myStep * first)), (myFirst + (myStep * limit)), myStep);
399399
}
400400

401+
public boolean isSmall(final long index, final double comparedTo) {
402+
return myDelegate.isSmall(myFirst + (myStep * index), comparedTo);
403+
}
404+
401405
/**
402406
* @see Scalar#isZero()
403407
*/

src/org/ojalgo/array/Array2D.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* @author apete
4747
*/
4848
public final class Array2D<N extends Number> implements Access2D<N>, Access2D.Elements, Access2D.Fillable<N>, Access2D.Iterable2D<N>, Access2D.Modifiable<N>,
49-
Access2D.Visitable<N>, Serializable {
49+
Access2D.Visitable<N>, Serializable {
5050

5151
public static abstract class Factory<N extends Number> implements Access2D.Factory<Array2D<N>> {
5252

@@ -441,6 +441,14 @@ public boolean isRowZeros(final long row, final long column) {
441441
return myDelegate.isZeros(row + (column * myRowsCount), row + (myColumnsCount * myRowsCount), myRowsCount);
442442
}
443443

444+
public boolean isSmall(final long index, final double comparedTo) {
445+
return myDelegate.isSmall(index, comparedTo);
446+
}
447+
448+
public boolean isSmall(final long row, final long column, final double comparedTo) {
449+
return myDelegate.isSmall(row + (column * myRowsCount), comparedTo);
450+
}
451+
444452
public boolean isZero(final long index) {
445453
return myDelegate.isZero(index);
446454
}

src/org/ojalgo/array/ArrayAnyD.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ public boolean isPositive(final long[] reference) {
239239
return myDelegate.isPositive(AccessUtils.index(myStructure, reference));
240240
}
241241

242+
public boolean isSmall(final long index, final double comparedTo) {
243+
return myDelegate.isSmall(index, comparedTo);
244+
}
245+
246+
public boolean isSmall(final long[] reference, final double comparedTo) {
247+
return myDelegate.isSmall(AccessUtils.index(myStructure, reference), comparedTo);
248+
}
249+
242250
public boolean isZero(final long index) {
243251
return myDelegate.isZero(index);
244252
}

src/org/ojalgo/array/BigArray.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,9 @@ DenseArray<BigDecimal> newInstance(final int capacity) {
368368
return new BigArray(capacity);
369369
}
370370

371+
@Override
372+
protected boolean isSmall(final int index, final double comparedTo) {
373+
return BigScalar.isSmall(comparedTo, data[index]);
374+
}
375+
371376
}

0 commit comments

Comments
 (0)