Exemple #1
0
        /// <summary>
        /// No clamped points added
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void notClampedTest()
        public virtual void notClampedTest()
        {
            double[][] xValuesSet = new double[][]
            {
                new double[] { -5.0, -1.4, 3.2, 3.5, 7.6 },
                new double[] { 1.0, 2.0, 4.5, 12.1, 14.2 },
                new double[] { -5.2, -3.4, -3.2, -0.9, -0.2 }
            };
            double[][] yValuesSet = new double[][]
            {
                new double[] { -2.2, 1.1, 1.9, 2.3, -0.1 },
                new double[] { 3.4, 5.2, 4.3, 1.1, 0.2 },
                new double[] { 1.4, 2.2, 4.1, 1.9, 0.99 }
            };

            for (int k = 0; k < xValuesSet.Length; ++k)
            {
                double[] xValues  = Arrays.copyOf(xValuesSet[k], xValuesSet[k].Length);
                double[] yValues  = Arrays.copyOf(yValuesSet[k], yValuesSet[k].Length);
                int      nData    = xValues.Length;
                double[] xyValues = new double[nData];
                for (int j = 0; j < nData; ++j)
                {
                    xyValues[j] = xValues[j] * yValues[j];
                }
                int    nKeys    = 100;
                double interval = (xValues[nData - 1] - xValues[0]) / (nKeys - 1.0);

                int n = INTERP.Length;
                for (int i = 0; i < n; ++i)
                {
                    ProductPiecewisePolynomialInterpolator interp = new ProductPiecewisePolynomialInterpolator(INTERP[i]);
                    for (int j = 0; j < nKeys; ++j)
                    {
                        double key = xValues[0] + interval * j;
                        InterpolatorTestUtil.assertRelative("notClampedTest", INTERP[i].interpolate(xValues, xyValues, key), interp.interpolate(xValues, yValues, key), EPS);
                    }
                }
                n = INTERP_SENSE.Length;
                for (int i = 0; i < n; ++i)
                {
                    ProductPiecewisePolynomialInterpolator    interp     = new ProductPiecewisePolynomialInterpolator(INTERP_SENSE[i]);
                    PiecewisePolynomialResultsWithSensitivity result     = interp.interpolateWithSensitivity(xValues, yValues);
                    PiecewisePolynomialResultsWithSensitivity resultBase = INTERP_SENSE[i].interpolateWithSensitivity(xValues, xyValues);
                    for (int j = 0; j < nKeys; ++j)
                    {
                        double key = xValues[0] + interval * j;
                        InterpolatorTestUtil.assertRelative("notClampedTest", FUNC.evaluate(resultBase, key).get(0), FUNC.evaluate(result, key).get(0), EPS);
                        InterpolatorTestUtil.assertArrayRelative("notClampedTest", FUNC.nodeSensitivity(resultBase, key).toArray(), FUNC.nodeSensitivity(result, key).toArray(), EPS);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Clamped points
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void clampedTest()
        public virtual void clampedTest()
        {
            double[]   xValues           = new double[] { -5.0, -1.4, 3.2, 3.5, 7.6 };
            double[]   yValues           = new double[] { -2.2, 1.1, 1.9, 2.3, -0.1 };
            double[][] xValuesClampedSet = new double[][]
            {
                new double[] { 0.0 },
                new double[] { -7.2, -2.5, 8.45 },
                new double[] {}
            };
            double[][] yValuesClampedSet = new double[][]
            {
                new double[] { 0.0 },
                new double[] { -1.2, -1.4, 2.2 },
                new double[] {}
            };

            for (int k = 0; k < xValuesClampedSet.Length; ++k)
            {
                double[] xValuesClamped = Arrays.copyOf(xValuesClampedSet[k], xValuesClampedSet[k].Length);
                double[] yValuesClamped = Arrays.copyOf(yValuesClampedSet[k], yValuesClampedSet[k].Length);
                int      nData          = xValues.Length;
                int      nClamped       = xValuesClamped.Length;
                int      nTotal         = nData + nClamped;
                double[] xValuesForBase = new double[nTotal];
                double[] yValuesForBase = new double[nTotal];
                Array.Copy(xValues, 0, xValuesForBase, 0, nData);
                Array.Copy(yValues, 0, yValuesForBase, 0, nData);
                Array.Copy(xValuesClamped, 0, xValuesForBase, nData, nClamped);
                Array.Copy(yValuesClamped, 0, yValuesForBase, nData, nClamped);
                DoubleArrayMath.sortPairs(xValuesForBase, yValuesForBase);

                double[] xyValuesBase = new double[nTotal];
                for (int j = 0; j < nTotal; ++j)
                {
                    xyValuesBase[j] = xValuesForBase[j] * yValuesForBase[j];
                }
                int    nKeys    = 100;
                double interval = (xValues[nData - 1] - xValues[0]) / (nKeys - 1.0);

                int n = INTERP.Length;
                for (int i = 0; i < n; ++i)
                {
                    ProductPiecewisePolynomialInterpolator interp = new ProductPiecewisePolynomialInterpolator(INTERP[i], xValuesClamped, yValuesClamped);
                    for (int j = 0; j < nKeys; ++j)
                    {
                        double key = xValues[0] + interval * j;
                        InterpolatorTestUtil.assertRelative("clampedTest", INTERP[i].interpolate(xValuesForBase, xyValuesBase, key), interp.interpolate(xValues, yValues, key), EPS);
                    }
                }
                n = INTERP_SENSE.Length;
                for (int i = 0; i < n; ++i)
                {
                    ProductPiecewisePolynomialInterpolator    interp     = new ProductPiecewisePolynomialInterpolator(INTERP_SENSE[i], xValuesClamped, yValuesClamped);
                    PiecewisePolynomialResultsWithSensitivity result     = interp.interpolateWithSensitivity(xValues, yValues);
                    PiecewisePolynomialResultsWithSensitivity resultBase = INTERP_SENSE[i].interpolateWithSensitivity(xValuesForBase, xyValuesBase);
                    for (int j = 0; j < nKeys; ++j)
                    {
                        double key = xValues[0] + interval * j;
                        InterpolatorTestUtil.assertRelative("clampedTest", FUNC.evaluate(resultBase, key).get(0), FUNC.evaluate(result, key).get(0), EPS);
                        InterpolatorTestUtil.assertArrayRelative("clampedTest", FUNC.nodeSensitivity(resultBase, key).toArray(), FUNC.nodeSensitivity(result, key).toArray(), EPS);
                    }
                }
            }
        }