org.apache.commons.math.exception.NonMonotonousSequenceException Java Examples

The following examples show how to use org.apache.commons.math.exception.NonMonotonousSequenceException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NevilleInterpolatorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test of parameters for the interpolator.
 */
@Test
public void testParameters() throws Exception {
    UnivariateRealInterpolator interpolator = new NevilleInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateRealFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        Assert.fail("Expecting NonMonotonousSequenceException - bad abscissas array");
    } catch (NonMonotonousSequenceException ex) {
        // expected
    }
}
 
Example #2
Source File: DividedDifferenceInterpolatorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test of parameters for the interpolator.
 */
@Test
public void testParameters() throws Exception {
    UnivariateRealInterpolator interpolator = new DividedDifferenceInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateRealFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        Assert.fail("Expecting NonMonotonousSequenceException - bad abscissas array");
    } catch (NonMonotonousSequenceException ex) {
        // expected
    }
}
 
Example #3
Source File: NevilleInterpolatorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test of parameters for the interpolator.
 */
@Test
public void testParameters() throws Exception {
    UnivariateRealInterpolator interpolator = new NevilleInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateRealFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        Assert.fail("Expecting NonMonotonousSequenceException - bad abscissas array");
    } catch (NonMonotonousSequenceException ex) {
        // expected
    }
}
 
Example #4
Source File: DividedDifferenceInterpolatorTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test of parameters for the interpolator.
 */
@Test
public void testParameters() throws Exception {
    UnivariateRealInterpolator interpolator = new DividedDifferenceInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateRealFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        Assert.fail("Expecting NonMonotonousSequenceException - bad abscissas array");
    } catch (NonMonotonousSequenceException ex) {
        // expected
    }
}
 
Example #5
Source File: DividedDifferenceInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test of parameters for the interpolator.
 */
public void testParameters() throws Exception {
    UnivariateRealInterpolator interpolator = new DividedDifferenceInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateRealFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        fail("Expecting NonMonotonousSequenceException - bad abscissas array");
    } catch (NonMonotonousSequenceException ex) {
        // expected
    }
}
 
Example #6
Source File: UnivariateRealPeriodicInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testUnsortedSamples() {
    final double[] xval = { 2, 3, 7, 4, 6 };
    final double[] yval = { 1, 6, 5, -1, -2 };
    final double period = 10;

    final UnivariateRealInterpolator interpolator
        = new UnivariateRealPeriodicInterpolator(new LinearInterpolator(), period);
    interpolator.interpolate(xval, yval);
}
 
Example #7
Source File: UnivariateRealPeriodicInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testUnsortedSamples() {
    final double[] xval = { 2, 3, 7, 4, 6 };
    final double[] yval = { 1, 6, 5, -1, -2 };
    final double period = 10;

    final UnivariateRealInterpolator interpolator
        = new UnivariateRealPeriodicInterpolator(new LinearInterpolator(), period);
    interpolator.interpolate(xval, yval);
}
 
Example #8
Source File: NevilleInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test of parameters for the interpolator.
 */
public void testParameters() throws Exception {
    UnivariateRealInterpolator interpolator = new NevilleInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateRealFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        fail("Expecting NonMonotonousSequenceException - bad abscissas array");
    } catch (NonMonotonousSequenceException ex) {
        // expected
    }
}
 
Example #9
Source File: MathUtils.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #10
Source File: 1_MathUtils.java    From SimFix with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #11
Source File: Cardumen_0053_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #12
Source File: LoessInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testNonStrictlyIncreasing2() {
    new LoessInterpolator().smooth(new double[] {1,2,2,3}, new double[] {3,4,5,6});
}
 
Example #13
Source File: LoessInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testNonStrictlyIncreasing1() {
    new LoessInterpolator().smooth(new double[] {4,3,1,2}, new double[] {3,4,5,6});
}
 
Example #14
Source File: Cardumen_0053_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #15
Source File: StepFunctionTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testPreconditions6() {
    new StepFunction(new double[] {1, 0, 1}, new double[] {0, -1, -2});
}
 
Example #16
Source File: MathUtils.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @param abort Whether to throw an exception if the check fails.
 * @return {@code true} if the array is sorted.
 * @throws NonMonotonousSequenceException if the array is not sorted
 * and {@code abort} is {@code true}.
 */
public static boolean checkOrder(double[] val, OrderDirection dir,
                                 boolean strict, boolean abort) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok &&
            abort) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }

    return ok;
}
 
Example #17
Source File: Cardumen_00267_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #18
Source File: Cardumen_00267_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #19
Source File: LoessInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testNonStrictlyIncreasing2() {
    new LoessInterpolator().smooth(new double[] {1,2,2,3}, new double[] {3,4,5,6});
}
 
Example #20
Source File: LoessInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testNonStrictlyIncreasing1() {
    new LoessInterpolator().smooth(new double[] {4,3,1,2}, new double[] {3,4,5,6});
}
 
Example #21
Source File: Cardumen_00224_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #22
Source File: StepFunctionTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testPreconditions6() {
    new StepFunction(new double[] {1, 0, 1}, new double[] {0, -1, -2});
}
 
Example #23
Source File: MathUtils.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @param abort Whether to throw an exception if the check fails.
 * @return {@code true} if the array is sorted.
 * @throws NonMonotonousSequenceException if the array is not sorted
 * and {@code abort} is {@code true}.
 */
public static boolean checkOrder(double[] val, OrderDirection dir,
                                 boolean strict, boolean abort) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok &&
            abort) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }

    return ok;
}
 
Example #24
Source File: Cardumen_00120_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #25
Source File: Cardumen_00224_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #26
Source File: LoessInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testNonStrictlyIncreasing2() {
    new LoessInterpolator().smooth(new double[] {1,2,2,3}, new double[] {3,4,5,6});
}
 
Example #27
Source File: LoessInterpolatorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testNonStrictlyIncreasing1() {
    new LoessInterpolator().smooth(new double[] {4,3,1,2}, new double[] {3,4,5,6});
}
 
Example #28
Source File: 1_MathUtils.java    From SimFix with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @throws NonMonotonousSequenceException if the array is not sorted.
 */
public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }
}
 
Example #29
Source File: StepFunctionTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test(expected=NonMonotonousSequenceException.class)
public void testPreconditions6() {
    new StepFunction(new double[] {1, 0, 1}, new double[] {0, -1, -2});
}
 
Example #30
Source File: MathUtils.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the given array is sorted.
 *
 * @param val Values.
 * @param dir Ordering direction.
 * @param strict Whether the order should be strict.
 * @param abort Whether to throw an exception if the check fails.
 * @return {@code true} if the array is sorted.
 * @throws NonMonotonousSequenceException if the array is not sorted
 * and {@code abort} is {@code true}.
 */
public static boolean checkOrder(double[] val, OrderDirection dir,
                                 boolean strict, boolean abort) {
    double previous = val[0];
    boolean ok = true;

    int max = val.length;
    for (int i = 1; i < max; i++) {
        switch (dir) {
        case INCREASING:
            if (strict) {
                if (val[i] <= previous) {
                    ok = false;
                }
            } else {
                if (val[i] < previous) {
                    ok = false;
                }
            }
            break;
        case DECREASING:
            if (strict) {
                if (val[i] >= previous) {
                    ok = false;
                }
            } else {
                if (val[i] > previous) {
                    ok = false;
                }
            }
            break;
        default:
            // Should never happen.
            throw new IllegalArgumentException();
        }

        if (!ok &&
            abort) {
            throw new NonMonotonousSequenceException(val[i], previous, i, dir, strict);
        }
        previous = val[i];
    }

    return ok;
}