public void GetValue_TestCase1(GridPointCurve.Interpolator horizontalInterpolator, GridPointCurve.Extrapolator horizontalLeftExtrapolator, GridPointCurve.Extrapolator horizontalRightExtrapolator, GridPointCurve.Interpolator verticalInterpolator, GridPointCurve.Extrapolator verticalAboveExtrapolator, GridPointCurve.Extrapolator verticalBelowExtrapolator, GridPointSurface2d.ConstructionOrder constructionOrder, double x, double y, double expected)
        {
            int rowCount    = 3;
            int columnCount = 3;
            var xLabels     = new double[] { 1.1, 2.12, 3.4 };
            var yLabels     = new double[] { 1.05, 2.07, 3.65 };

            double[] matrixEntries = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // matrix is provided column-by-column

            var labelMatrix = LabelMatrix.Create(rowCount, columnCount, matrixEntries, xLabels, yLabels);

            var surface = GridPointSurface2d.Create(labelMatrix, horizontalInterpolator, horizontalLeftExtrapolator, horizontalRightExtrapolator, verticalInterpolator, verticalAboveExtrapolator, verticalBelowExtrapolator, constructionOrder);

            double actual = surface.GetValue(x, y);

            Assert.That(actual, Is.EqualTo(expected).Within(1E-7), String.Format("expected: {0}, actual: {1}", expected, actual));
        }
Exemplo n.º 2
0
        public void GetValue_AtGridPoint_GridPointValue_TestCase2(GridPointCurve.Interpolator horizontalInterpolator, GridPointCurve.Extrapolator horizontalLeftExtrapolator, GridPointCurve.Extrapolator horizontalRightExtrapolator, GridPointCurve.Interpolator verticalInterpolator, GridPointCurve.Extrapolator verticalAboveExtrapolator, GridPointCurve.Extrapolator verticalBelowExtrapolator, GridPointSurface2d.ConstructionOrder constructionOrder)
        {
            int rowCount    = 2;
            int columnCount = 5;

            var xLabels = new double[] { 1.05, 2.6, 3, 4, 5 };
            var yLabels = new double[] { 1.3, 2.8 };

            var matrixEntries = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // matrix is provided column-by-column
            var labelMatrix   = LabelMatrix.Create(rowCount, columnCount, matrixEntries, xLabels, yLabels);

            var surface = GridPointSurface2d.Create(labelMatrix, horizontalInterpolator, horizontalLeftExtrapolator, horizontalRightExtrapolator, verticalInterpolator, verticalAboveExtrapolator, verticalBelowExtrapolator, constructionOrder);

            for (int j = 0; j < rowCount; j++)
            {
                for (int k = 0; k < columnCount; k++)
                {
                    double expected = labelMatrix[j, k];

                    double actual = surface.GetValue(x: labelMatrix.HorizontalDoubleLabels[k], y: labelMatrix.VerticalDoubleLabels[j]);
                    Assert.That(actual, Is.EqualTo(expected).Within(1E-7), String.Format("Row: {0}, Column: {1}, expected: {2}, actual: {3}", j, k, expected, actual));
                }
            }
        }