diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java index 3b1dede6663d434ec087373e8da5530928c818a3..0205e3f7dd8c888670225dd629433f65d6aa691e 100644 --- a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java +++ b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java @@ -155,6 +155,15 @@ public class MinMaxTreeTile extends SimpleTile { } + /** Check if the merging operation between level and level+1 is a column merging. + * @param level level to check + * @return true if the merging operation between level and level+1 is a column + * merging, false if is a row merging + */ + public boolean isColumnMerging(final int level) { + return (level & 0x1) != (start.length & 0x1); + } + /** Recursive setting of tree levels. * <p> * The following algorithms works for any array shape, even with @@ -228,7 +237,8 @@ public class MinMaxTreeTile extends SimpleTile { final int level, final int levelRows, final int levelColumns, final BivariateFunction f, final double[] base, final int first) { - if ((level & 0x1) != (start.length & 0x1)) { + + if (isColumnMerging(level)) { // merge columns pairs int iTree = start[level]; diff --git a/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java b/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java index a4edf7eb4c6e742764acbe7b4cec22df12b2e955..b22f7f07bf959f3f8e5fd0552e79102929158c3a 100644 --- a/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java +++ b/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileTest.java @@ -47,6 +47,16 @@ public class MinMaxTreeTileTest { Assert.assertEquals( 577, start[ 7]); Assert.assertEquals(1117, start[ 8]); + Assert.assertTrue(tile.isColumnMerging(8)); + Assert.assertFalse(tile.isColumnMerging(7)); + Assert.assertTrue(tile.isColumnMerging(6)); + Assert.assertFalse(tile.isColumnMerging(5)); + Assert.assertTrue(tile.isColumnMerging(4)); + Assert.assertFalse(tile.isColumnMerging(3)); + Assert.assertTrue(tile.isColumnMerging(2)); + Assert.assertFalse(tile.isColumnMerging(1)); + Assert.assertTrue(tile.isColumnMerging(0)); + Field minTreeField = MinMaxTreeTile.class.getDeclaredField("minTree"); minTreeField.setAccessible(true); Assert.assertEquals(2187, ((double[]) minTreeField.get(tile)).length); @@ -71,6 +81,11 @@ public class MinMaxTreeTileTest { Assert.assertEquals( 6, start[ 2]); Assert.assertEquals(14, start[ 3]); + Assert.assertTrue(tile.isColumnMerging(3)); + Assert.assertFalse(tile.isColumnMerging(2)); + Assert.assertTrue(tile.isColumnMerging(1)); + Assert.assertFalse(tile.isColumnMerging(0)); + Field minTreeField = MinMaxTreeTile.class.getDeclaredField("minTree"); minTreeField.setAccessible(true); Assert.assertEquals(30, ((double[]) minTreeField.get(tile)).length);