// Path: src/main/java/ro/hasna/ts/math/exception/ArrayLengthIsTooSmallException.java
// public class ArrayLengthIsTooSmallException extends NumberIsTooSmallException {
//     private static final long serialVersionUID = -2633584088507009304L;
// 
//     /**
//      * Construct the exception.
//      *
//      * @param wrong          Value that is smaller than the minimum.
//      * @param min            Minimum.
//      * @param boundIsAllowed Whether {@code min} is included in the allowed range.
//      */
//     public ArrayLengthIsTooSmallException(Number wrong, Number min, boolean boundIsAllowed) {
//         super(wrong, min, boundIsAllowed);
//     }
// 
//     /**
//      * Construct the exception with a specific context.
//      *
//      * @param specific       Specific context pattern.
//      * @param wrong          Value that is smaller than the minimum.
//      * @param min            Minimum.
//      * @param boundIsAllowed Whether {@code min} is included in the allowed range.
//      */
//     public ArrayLengthIsTooSmallException(Localizable specific, Number wrong, Number min, boolean boundIsAllowed) {
//         super(specific, wrong, min, boundIsAllowed);
//     }
// }
// 
// Path: src/main/java/ro/hasna/ts/math/util/TimeSeriesPrecision.java
// public class TimeSeriesPrecision {
//     public static final double EPSILON = FastMath.pow(2, -30);
// 
//     /**
//      * Private constructor.
//      */
//     private TimeSeriesPrecision() {
//     }
// }


import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.fitting.AbstractCurveFitter;
import org.apache.commons.math3.fitting.PolynomialCurveFitter;
import org.junit.*;
import org.junit.rules.ExpectedException;
import ro.hasna.ts.math.exception.ArrayLengthIsTooSmallException;
import ro.hasna.ts.math.util.TimeSeriesPrecision;
        curveFitter = null;
    }

    @Test
    public void testConstructor() throws Exception {
        thrown.expect(NumberIsTooSmallException.class);
        thrown.expectMessage("0 is smaller than the minimum (1)");

        new PiecewiseCurveFitterApproximation(0, curveFitter);
    }

    @Test
    public void testTransformMoreSegmentsThanValues() throws Exception {
        thrown.expect(ArrayLengthIsTooSmallException.class);
        thrown.expectMessage("3 is smaller than the minimum (4)");

        PiecewiseCurveFitterApproximation pcfa = new PiecewiseCurveFitterApproximation(4, curveFitter);
        double[] v = {1, 2, 3};

        pcfa.transform(v);
    }

    @Test
    public void testTransformStrict() throws Exception {
        PiecewiseCurveFitterApproximation pcfa = new PiecewiseCurveFitterApproximation(2, curveFitter);
        double[] v = {1, 2, 3, 4, 5, 6};
        double[][] expected = {{2.0}, {5.0}};

        double[][] result = pcfa.transform(v);

// Path: src/main/java/ro/hasna/ts/math/exception/ArrayLengthIsTooSmallException.java
// public class ArrayLengthIsTooSmallException extends NumberIsTooSmallException {
//     private static final long serialVersionUID = -2633584088507009304L;
// 
//     /**
//      * Construct the exception.
//      *
//      * @param wrong          Value that is smaller than the minimum.
//      * @param min            Minimum.
//      * @param boundIsAllowed Whether {@code min} is included in the allowed range.
//      */
//     public ArrayLengthIsTooSmallException(Number wrong, Number min, boolean boundIsAllowed) {
//         super(wrong, min, boundIsAllowed);
//     }
// 
//     /**
//      * Construct the exception with a specific context.
//      *
//      * @param specific       Specific context pattern.
//      * @param wrong          Value that is smaller than the minimum.
//      * @param min            Minimum.
//      * @param boundIsAllowed Whether {@code min} is included in the allowed range.
//      */
//     public ArrayLengthIsTooSmallException(Localizable specific, Number wrong, Number min, boolean boundIsAllowed) {
//         super(specific, wrong, min, boundIsAllowed);
//     }
// }
// 
// Path: src/main/java/ro/hasna/ts/math/util/TimeSeriesPrecision.java
// public class TimeSeriesPrecision {
//     public static final double EPSILON = FastMath.pow(2, -30);
// 
//     /**
//      * Private constructor.
//      */
//     private TimeSeriesPrecision() {
//     }
// }


// Path: src/test/java/ro/hasna/ts/math/representation/PiecewiseCurveFitterApproximationTest.java
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.fitting.AbstractCurveFitter;
import org.apache.commons.math3.fitting.PolynomialCurveFitter;
import org.junit.*;
import org.junit.rules.ExpectedException;
import ro.hasna.ts.math.exception.ArrayLengthIsTooSmallException;
import ro.hasna.ts.math.util.TimeSeriesPrecision;

        curveFitter = null;
    }

    @Test
    public void testConstructor() throws Exception {
        thrown.expect(NumberIsTooSmallException.class);
        thrown.expectMessage("0 is smaller than the minimum (1)");

        new PiecewiseCurveFitterApproximation(0, curveFitter);
    }

    @Test
    public void testTransformMoreSegmentsThanValues() throws Exception {
        thrown.expect(ArrayLengthIsTooSmallException.class);
        thrown.expectMessage("3 is smaller than the minimum (4)");

        PiecewiseCurveFitterApproximation pcfa = new PiecewiseCurveFitterApproximation(4, curveFitter);
        double[] v = {1, 2, 3};

        pcfa.transform(v);
    }

    @Test
    public void testTransformStrict() throws Exception {
        PiecewiseCurveFitterApproximation pcfa = new PiecewiseCurveFitterApproximation(2, curveFitter);
        double[] v = {1, 2, 3, 4, 5, 6};
        double[][] expected = {{2.0}, {5.0}};

        double[][] result = pcfa.transform(v);

        assertMatrixEquals(expected, result, TimeSeriesPrecision.EPSILON);