Skip to content

Commit

Permalink
update computing of ceil_nroot and floor_nroot for PropPowEven
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurGodet committed Oct 7, 2023
1 parent 46f3fc9 commit 1daacbe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @since 18/05/11
*/
public class PropPowEven extends Propagator<IntVar> {
protected static final double PRECISION = 1e-9;
final IntIterableBitSet vrms;
final boolean bothEnum;
final int exponent;
Expand Down Expand Up @@ -79,14 +80,14 @@ int floor_nroot(int n) {
if (n < 0) {
return 0;
}
return MathUtils.safeCast((long) Math.floor(Math.pow(n, 1. / exponent)));
return MathUtils.safeCast((long) Math.floor(Math.pow(n, 1. / (exponent - PRECISION))));
}

int ceil_nroot(int n) {
if (n < 0) {
return 0;
}
return MathUtils.safeCast((long) Math.ceil(Math.pow(n, 1. / exponent)));
return MathUtils.safeCast((long) Math.ceil(Math.pow(n, 1. / (exponent + PRECISION))));
}

int pow(int n) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* @since 18/05/11
*/
public class PropPowOdd extends PropPowEven {
private static final double PRECISION = 1e-9;

public PropPowOdd(IntVar X, IntVar Y, int n) {
super(X, Y, n);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @since 14/02/2022
*/
public class PowTest extends AbstractBinaryTest {
private int TEST_VALUE = 5; // TODO How to change this dependency to use AbstractBinaryTest
private int TEST_VALUE = 5;

@DataProvider
public static Object[][] even() {
Expand Down

0 comments on commit 1daacbe

Please sign in to comment.