/// <summary>Initializes a new instance of the <see cref="Extrapolator"/> class. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <param name="buildingDirection">The building direction of the curve extrapolation.</param> /// <param name="value">The individual value to take into account for the constant curve extrapolation.</param> /// <param name="extrapolatorFactory">The <see cref="GridPointCurve.Extrapolator"/> object that serves as factory for the current object.</param> public Extrapolator(ICurveDataFitting curveInterpolator, BuildingDirection buildingDirection, double value, GridPointCurve.Extrapolator extrapolatorFactory) { m_CurveInterpolator = curveInterpolator ?? throw new ArgumentNullException(nameof(curveInterpolator)); m_BuildingDirection = buildingDirection; m_GridPointValue = value; Factory = extrapolatorFactory; }
/// <summary>Initializes a new instance of the <see cref="HInterpolation"/> class. /// </summary> /// <param name="gridPointMatrix">The grid point matrix.</param> /// <param name="verticalCurveFactory">A factory for grid point curves along vertical direction, i.e. taken into account a specified interpolation, parametrization etc.</param> /// <param name="horizontalInterpolator">The interpolation approach along horizontal direction.</param> /// <param name="horizontalLeftExtrapolator">The extrapolation approach in horizontal direction on the left side of the grid points.</param> /// <param name="horizontalRightExtrapolator">The extrapolation approach in horizontal direction on the right side of the grid points.</param> internal HInterpolation(LabelMatrix <THorizontalLabel, TVerticalLabel> gridPointMatrix, Func <THorizontalLabel, IGridPointCurveFactory <TVerticalLabel> > verticalCurveFactory, GridPointCurve.Interpolator horizontalInterpolator, GridPointCurve.Extrapolator horizontalLeftExtrapolator, GridPointCurve.Extrapolator horizontalRightExtrapolator) : base(gridPointMatrix, verticalCurveFactory) { m_HorizontalInterpolatorFactory = horizontalInterpolator ?? throw new NullReferenceException(nameof(horizontalInterpolator)); m_HorizontalInterpolator = horizontalInterpolator.Create(); if (horizontalLeftExtrapolator == null) { throw new NullReferenceException(nameof(horizontalLeftExtrapolator)); } if (horizontalLeftExtrapolator.ExtrapolationBuildingDirection != GridPointCurve.Extrapolator.BuildingDirection.FromFirstGridPoint) { throw new ArgumentException(String.Format("Invalid building direction of extrapolation on left side of the grid points."), nameof(horizontalLeftExtrapolator)); } m_HorizontalLeftExtrapolatorFactory = horizontalLeftExtrapolator; m_HorizontalLeftExtrapolator = horizontalLeftExtrapolator.Create(m_HorizontalInterpolator); if (horizontalRightExtrapolator == null) { throw new NullReferenceException(nameof(horizontalRightExtrapolator)); } if (horizontalRightExtrapolator.ExtrapolationBuildingDirection != GridPointCurve.Extrapolator.BuildingDirection.FromLastGridPoint) { throw new ArgumentException(String.Format("Invalid building direction of extrapolation on the right side of the grid points."), nameof(horizontalRightExtrapolator)); } m_HorizontalRightExtrapolatorFactory = horizontalRightExtrapolator; m_HorizontalRightExtrapolator = horizontalRightExtrapolator.Create(m_HorizontalInterpolator); m_TempValuesForHorizontalEvaluation = new double[m_HorizontalDoubleLabels.Length]; m_TempHorizontalDoubleLabels = new double[m_GridPointMatrix.ColumnCount]; }
/// <summary>Initializes a new instance of the <see cref="VInterpolation"/> class. /// </summary> /// <param name="gridPointMatrix">The grid point matrix.</param> /// <param name="horizontalCurveFactory">A factory for grid point curves along horizontal direction, i.e. taken into account a specified interpolation, parametrization etc.</param> /// <param name="verticalInterpolator">The interpolation approach along vertical direction.</param> /// <param name="verticalAboveExtrapolator">The extrapolation approach in vertical direction above the grid points.</param> /// <param name="verticalBelowExtrapolator">The extrapolation approach in vertical direction below the grid points.</param> internal VInterpolation(LabelMatrix <THorizontalLabel, TVerticalLabel> gridPointMatrix, Func <TVerticalLabel, IGridPointCurveFactory <THorizontalLabel> > horizontalCurveFactory, GridPointCurve.Interpolator verticalInterpolator, GridPointCurve.Extrapolator verticalAboveExtrapolator, GridPointCurve.Extrapolator verticalBelowExtrapolator) : base(gridPointMatrix, horizontalCurveFactory) { m_VerticalInterpolatorFactory = verticalInterpolator ?? throw new NullReferenceException(nameof(verticalInterpolator)); m_VerticalInterpolator = verticalInterpolator.Create(); if (verticalAboveExtrapolator == null) { throw new NullReferenceException(nameof(verticalAboveExtrapolator)); } if (verticalAboveExtrapolator.ExtrapolationBuildingDirection != GridPointCurve.Extrapolator.BuildingDirection.FromFirstGridPoint) { throw new ArgumentException(String.Format("Invalid building direction of extrapolation above grid points."), nameof(verticalAboveExtrapolator)); } m_VerticalAboveExtrapolatorFactory = verticalAboveExtrapolator; m_VerticalAboveExtrapolator = verticalAboveExtrapolator.Create(m_VerticalInterpolator); if (verticalBelowExtrapolator == null) { throw new NullReferenceException(nameof(verticalBelowExtrapolator)); } if (verticalBelowExtrapolator.ExtrapolationBuildingDirection != GridPointCurve.Extrapolator.BuildingDirection.FromLastGridPoint) { throw new ArgumentException(String.Format("Invalid building direction of extrapolation below grid points."), nameof(verticalBelowExtrapolator)); } m_VerticalBelowExtrapolatorFactory = verticalBelowExtrapolator; m_VerticalBelowExtrapolator = verticalBelowExtrapolator.Create(m_VerticalInterpolator); m_TempValuesForVerticalEvaluation = new double[m_VerticalDoubleLabels.Length]; m_TempVerticalDoubleLabels = new double[m_GridPointMatrix.RowCount]; }
/// <summary>Initializes a new instance of the <see cref="HParametrization"/> class. /// </summary> /// <param name="gridPointMatrix">The grid point matrix.</param> /// <param name="verticalCurveFactory">A factory for grid point curves along vertical direction, i.e. taken into account a specified interpolation, parametrization etc.</param> /// <param name="horizontalParametrization">The interpolation approach along horizontal direction.</param> internal HParametrization(LabelMatrix <THorizontalLabel, TVerticalLabel> gridPointMatrix, Func <THorizontalLabel, IGridPointCurveFactory <TVerticalLabel> > verticalCurveFactory, GridPointCurve.Parametrization horizontalParametrization) : base(gridPointMatrix, verticalCurveFactory) { m_HorizontalParametrizationFactory = horizontalParametrization ?? throw new NullReferenceException(nameof(horizontalParametrization)); m_HorizontalParametrization = horizontalParametrization.Create(); m_TempValuesForHorizontalEvaluation = new double[m_HorizontalDoubleLabels.Length]; m_TempHorizontalDoubleLabels = new double[m_GridPointMatrix.ColumnCount]; }
/// <summary>Initializes a new instance of the <see cref="Extrapolator"/> class. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <param name="buildingDirection">The building direction of the curve extrapolation.</param> /// <param name="slope">The slope.</param> /// <param name="extrapolatorFactory">The <see cref="GridPointCurve.Extrapolator"/> object that serves as factory for the current object.</param> public Extrapolator(ICurveDataFitting curveInterpolator, BuildingDirection buildingDirection, double slope, GridPointCurve.Extrapolator extrapolatorFactory) { m_CurveInterpolator = curveInterpolator ?? throw new ArgumentNullException(nameof(curveInterpolator)); m_BuildingDirection = buildingDirection; m_Slope = slope; m_ReferencePoint = Double.NaN; m_ReferenceValue = Double.NaN; Factory = extrapolatorFactory; }
/// <summary>Initializes a new instance of the <see cref="StandardGridPointCurveNoLabels"/> class. /// </summary> /// <param name="curveInterpolatorFactory">The curve interpolator factory.</param> /// <param name="curveInterpolator">The curve interpolator.</param> /// <param name="leftExtrapolatorFactory">The left extrapolator factory.</param> /// <param name="leftExtrapolator">The left extrapolator.</param> /// <param name="rightExtrapolatorFactory">The right extrapolator factory.</param> /// <param name="rightExtrapolator">The right extrapolator.</param> /// <param name="capacity">The number of elements that the new grid point curve can initially store.</param> internal StandardGridPointCurveNoLabels(GridPointCurve.Interpolator curveInterpolatorFactory, ICurveDataFitting curveInterpolator, GridPointCurve.Extrapolator leftExtrapolatorFactory, ICurveExtrapolator leftExtrapolator, GridPointCurve.Extrapolator rightExtrapolatorFactory, ICurveExtrapolator rightExtrapolator, int capacity = 20) { m_GridPointArguments = new List<double>(capacity); m_GridPointValues = new List<double>(capacity); m_CurveBuilder = curveInterpolator; m_LeftExtrapolator = leftExtrapolator; m_RightExtrapolator = rightExtrapolator; m_State = GridPointCurve.State.GridPointChanged; m_ReadOnlyGridPointValues = new ReadOnlyCollection<double>(m_GridPointValues); m_ReadOnlyGridPointArguments = new ReadOnlyCollection<double>(m_GridPointArguments); }
/// <summary>Initializes a new instance of the <see cref="StandardGridPointCurveNoLabels"/> class. /// </summary> /// <param name="curveParametrizationFactory">The curve parametrization factory.</param> /// <param name="curveParametrization">The curve parametrization.</param> /// <param name="capacity">The number of elements that the new grid point curve can initially store.</param> internal StandardGridPointCurveNoLabels(GridPointCurve.Parametrization curveParametrizationFactory, ICurveDataFitting curveParametrization, int capacity = 20) { m_GridPointArguments = new List<double>(capacity); m_GridPointValues = new List<double>(capacity); m_CurveBuilder = curveParametrization; // do not apply any truncation (extrapolation) approach: m_LeftExtrapolator = GridPointCurve.Extrapolator.None.First.Create(curveParametrization); m_RightExtrapolator = GridPointCurve.Extrapolator.None.Last.Create(curveParametrization); m_ReadOnlyGridPointValues = new ReadOnlyCollection<double>(m_GridPointValues); m_ReadOnlyGridPointArguments = new ReadOnlyCollection<double>(m_GridPointArguments); m_State = GridPointCurve.State.GridPointChanged; }
/// <summary>Initializes a new instance of the <see cref="Extrapolator"/> class. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <param name="buildingDirection">The building direction of the curve extrapolation.</param> /// <param name="extrapolatorFactory">The <see cref="GridPointCurve.Extrapolator"/> object that serves as factory for the current object.</param> public Extrapolator(ICurveDataFitting curveInterpolator, BuildingDirection buildingDirection, GridPointCurve.Extrapolator extrapolatorFactory) { if (curveInterpolator == null) { throw new ArgumentNullException(nameof(curveInterpolator)); } if ((curveInterpolator is IDifferentiableRealValuedCurve) == false) { throw new ArgumentException(nameof(curveInterpolator)); } m_CurveInterpolator = (IDifferentiableRealValuedCurve)curveInterpolator; m_BuildingDirection = buildingDirection; m_Slope = Double.NaN; m_ReferencePoint = Double.NaN; m_ReferenceValue = Double.NaN; Factory = extrapolatorFactory; }
/// <summary>Initializes a new instance of the <see cref="SmartReadOnlyGridPointCurve<TLabel>"/> class. /// </summary> /// <param name="curveInterpolator">The curve interpolator.</param> /// <param name="leftExtrapolator">The left extrapolator.</param> /// <param name="rightExtrapolator">The right extrapolator.</param> /// <param name="gridPointCount">The number of grid points, i.e. the number of relevant elements of <paramref name="gridPointLabels"/>, <paramref name="gridPointArguments"/> and <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointLabels">The labels of the grid points (the reference will be stored only).</param> /// <param name="gridPointArguments">The arguments of the grid points, thus labels of the curve in its <see cref="System.Double"/> representation.</param> /// <param name="gridPointValues">The values of the grid points corresponding to <paramref name="gridPointArguments"/>.</param> /// <param name="gridPointArgumentStartIndex">The null-based start index of <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/> to take into account.</param> /// <param name="gridPointValueStartIndex">The null-based start index of <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointArgumentIncrement">The increment for <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/>.</param> /// <param name="gridPointValueIncrement">The increment for <paramref name="gridPointValues"/>.</param> internal SmartReadOnlyGridPointCurve(ICurveDataFitting curveInterpolator, ICurveExtrapolator leftExtrapolator, ICurveExtrapolator rightExtrapolator, int gridPointCount, IList <TLabel> gridPointLabels, IList <double> gridPointArguments, IList <double> gridPointValues, int gridPointArgumentStartIndex = 0, int gridPointValueStartIndex = 0, int gridPointArgumentIncrement = 1, int gridPointValueIncrement = 1) { m_CurveInterpolator = curveInterpolator; m_LeftExtrapolator = leftExtrapolator; m_RightExtrapolator = rightExtrapolator; m_GridPointLabels = new SmartReadOnlyCollection <TLabel>(gridPointCount, gridPointLabels, gridPointArgumentStartIndex, gridPointArgumentIncrement); curveInterpolator.Update(gridPointCount, gridPointArguments, gridPointValues, GridPointCurve.State.GridPointChanged, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement = 1, gridPointValueIncrement); if (curveInterpolator.IsOperable == false) { throw new ArgumentException(); } leftExtrapolator.Update(); if (leftExtrapolator.IsOperable == false) { throw new ArgumentException(); } rightExtrapolator.Update(); if (rightExtrapolator.IsOperable == false) { throw new ArgumentException(); } }
/// <summary>Creates a <see cref="ICurveExtrapolator"/> object that represents the implementation of the extrapolation approach. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <returns>A <see cref="ICurveExtrapolator"/> object that represents the implementation of the extrapolation approach.</returns> public override ICurveExtrapolator Create(ICurveDataFitting curveInterpolator) { return(new Extrapolator(curveInterpolator, ExtrapolationBuildingDirection, m_Slope, this)); }
/// <summary>Initializes a new instance of the <see cref="Differentiable"/> class. /// </summary> /// <param name="curveInterpolator">The curve interpolator, i.e. curve parametrization.</param> /// <param name="gridPointCount">The number of grid points, i.e. the number of relevant elements of <paramref name="gridPointLabels"/>, <paramref name="gridPointArguments"/> and <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointLabels">The labels of the grid points (the reference will be stored only).</param> /// <param name="gridPointArguments">The arguments of the grid points, thus labels of the curve in its <see cref="System.Double"/> representation.</param> /// <param name="gridPointValues">The values of the grid points corresponding to <paramref name="gridPointArguments"/>.</param> /// <param name="gridPointArgumentStartIndex">The null-based start index of <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/> to take into account.</param> /// <param name="gridPointValueStartIndex">The null-based start index of <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointArgumentIncrement">The increment for <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/>.</param> /// <param name="gridPointValueIncrement">The increment for <paramref name="gridPointValues"/>.</param> internal Differentiable(ICurveDataFitting curveInterpolator, int gridPointCount, IList <TLabel> gridPointLabels, IList <double> gridPointArguments, IList <double> gridPointValues, int gridPointArgumentStartIndex = 0, int gridPointValueStartIndex = 0, int gridPointArgumentIncrement = 1, int gridPointValueIncrement = 1) : base(curveInterpolator, gridPointCount, gridPointLabels, gridPointArguments, gridPointValues, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement, gridPointValueIncrement) { }
/// <summary>Initializes a new instance of the <see cref="SmartReadOnlyGridPointCurve<TLabel>"/> class. /// </summary> /// <param name="curveInterpolator">The curve interpolator, i.e. curve parametrization.</param> /// <param name="gridPointCount">The number of grid points, i.e. the number of relevant elements of <paramref name="gridPointLabels"/>, <paramref name="gridPointArguments"/> and <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointLabels">The labels of the grid points (the reference will be stored only).</param> /// <param name="gridPointArguments">The arguments of the grid points, thus labels of the curve in its <see cref="System.Double"/> representation.</param> /// <param name="gridPointValues">The values of the grid points corresponding to <paramref name="gridPointArguments"/>.</param> /// <param name="gridPointArgumentStartIndex">The null-based start index of <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/> to take into account.</param> /// <param name="gridPointValueStartIndex">The null-based start index of <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointArgumentIncrement">The increment for <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/>.</param> /// <param name="gridPointValueIncrement">The increment for <paramref name="gridPointValues"/>.</param> internal SmartReadOnlyGridPointCurve(ICurveDataFitting curveInterpolator, int gridPointCount, IList <TLabel> gridPointLabels, IList <double> gridPointArguments, IList <double> gridPointValues, int gridPointArgumentStartIndex = 0, int gridPointValueStartIndex = 0, int gridPointArgumentIncrement = 1, int gridPointValueIncrement = 1) : this(curveInterpolator, GridPointCurve.Extrapolator.None.First.Create(curveInterpolator), GridPointCurve.Extrapolator.None.Last.Create(curveInterpolator), gridPointCount, gridPointLabels, gridPointArguments, gridPointValues, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement, gridPointValueIncrement) { }
/// <summary>Initializes a new instance of the <see cref="CurveInterpolatorIntegralCache" /> class. /// </summary> /// <param name="curveDataFitting">The curve data fitting.</param> public CurveInterpolatorIntegralCache(ICurveDataFitting curveDataFitting) { CurveDataFitting = curveDataFitting; }
/// <summary>Gets the estimation of a specified missing value via a interpolation along the y-axis. /// </summary> /// <param name="rowIndex">The null-based index of the row that describes the position of the missing value in <paramref name="matrix"/>.</param> /// <param name="columnIndex">The null-based index of the column that describes the position of the missing value in <paramref name="matrix"/>.</param> /// <param name="matrix">The matrix.</param> /// <param name="rowCount">The number of rows.</param> /// <param name="yAxisLabeling">The labels of the y-axis in its <see cref="System.Double"/> representation, i.e. at least <paramref name="rowCount"/> elements.</param> /// <param name="curveInterpolator">The (curve) interpolator along y-axis.</param> /// <returns>The estimated value for position (<paramref name="rowIndex"/>, <paramref name="columnIndex"/>).</returns> /// <exception cref="InvalidOperationException">Thrown, if in the interpolation failed.</exception> internal static double GetInterpolatedValueAlongYAxis(int rowIndex, int columnIndex, IList <double> matrix, int rowCount, IList <double> yAxisLabeling, ICurveDataFitting curveInterpolator) { int lowIndex = rowIndex; bool foundLowValue = false; int arrayOffset = columnIndex * rowCount; while ((lowIndex >= 1) && (foundLowValue == false)) { lowIndex--; if (Double.IsNaN(matrix[lowIndex + arrayOffset]) == false) // matrix[lowIndex][columnIndex] { foundLowValue = true; } } int higherIndex = rowIndex; bool foundHigherValue = false; while ((higherIndex <= rowCount - 2) && (foundHigherValue == false)) { higherIndex++; if (Double.IsNaN(matrix[higherIndex + arrayOffset]) == false) // matrix[higherIndex][columnIndex] { foundHigherValue = true; } } if (foundLowValue && foundHigherValue) { curveInterpolator.Update(2, yAxisLabeling, matrix, GridPointCurve.State.GridPointChanged, lowIndex, lowIndex + arrayOffset, higherIndex - lowIndex, higherIndex - lowIndex); return(curveInterpolator.GetValue(yAxisLabeling[rowIndex])); } else if (foundLowValue) { return(matrix[lowIndex + arrayOffset]); // matrix[lowIndex][columnIndex] } else if (foundHigherValue) { return(matrix[higherIndex + arrayOffset]); // matrix[higherIndex][columnIndex] } throw new InvalidOperationException(String.Format("Replenish failed at position ({0};{1}).", rowIndex, columnIndex)); }
/// <summary>Initializes a new instance of the <see cref="Extrapolator"/> class. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <param name="extrapolatorFactory">The <see cref="GridPointCurve.Extrapolator"/> object that serves as factory for the current object.</param> public Extrapolator(ICurveDataFitting curveInterpolator, GridPointCurve.Extrapolator extrapolatorFactory) { m_CurveInterpolator = curveInterpolator ?? throw new ArgumentNullException(nameof(curveInterpolator)); m_GridPointValue = Double.NaN; Factory = extrapolatorFactory; }
/// <summary>Initializes a new instance of the <see cref="Differentiable"/> class. /// </summary> /// <param name="curveInterpolatorFactory">The curve interpolator factory.</param> /// <param name="curveInterpolator">The curve interpolator.</param> /// <param name="leftExtrapolatorFactory">The left extrapolator factory.</param> /// <param name="leftExtrapolator">The left extrapolator.</param> /// <param name="rightExtrapolatorFactory">The right extrapolator factory.</param> /// <param name="rightExtrapolator">The right extrapolator.</param> /// <param name="capacity">The number of elements that the new grid point curve can initially store.</param> internal Differentiable(GridPointCurve.Interpolator curveInterpolatorFactory, ICurveDataFitting curveInterpolator, GridPointCurve.Extrapolator leftExtrapolatorFactory, ICurveExtrapolator leftExtrapolator, GridPointCurve.Extrapolator rightExtrapolatorFactory, ICurveExtrapolator rightExtrapolator, int capacity) : base(curveInterpolatorFactory, curveInterpolator, leftExtrapolatorFactory, leftExtrapolator, rightExtrapolatorFactory, rightExtrapolator, capacity) { }
/// <summary>Initializes a new instance of the <see cref="Replenishment"/> class. /// </summary> /// <param name="verticalInterpolator">The (curve) interpolator along y-axis.</param> internal Replenishment(GridPointCurve.Interpolator verticalInterpolator) { m_VerticalInterpolator = verticalInterpolator.Create(); }
/// <summary>Creates a <see cref="ICurveExtrapolator"/> object that represents the implementation of the extrapolation approach. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <returns>A <see cref="ICurveExtrapolator"/> object that represents the implementation of the extrapolation approach.</returns> public abstract ICurveExtrapolator Create(ICurveDataFitting curveInterpolator);
/// <summary>Creates a <see cref="ICurveExtrapolator"/> object that represents the implementation of the extrapolation approach. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <returns>A <see cref="ICurveExtrapolator"/> object that represents the implementation of the extrapolation approach.</returns> public override ICurveExtrapolator Create(ICurveDataFitting curveInterpolator) { return(new Extrapolator(curveInterpolator, this)); }
/// <summary>Gets the estimation of a specified missing value via a interpolation along the x-axis. /// </summary> /// <param name="rowIndex">The null-based index of the row that describes the position of the missing value in <paramref name="matrix"/>.</param> /// <param name="columnIndex">The null-based index of the column that describes the position of the missing value in <paramref name="matrix"/>.</param> /// <param name="matrix">The matrix.</param> /// <param name="rowCount">The number of rows.</param> /// <param name="columnCount">The number of columns.</param> /// <param name="xAxisLabeling">The labels of the x-axis in its <see cref="System.Double"/> representation, i.e. at least <paramref name="columnCount"/> elements.</param> /// <param name="curveInterpolator">The (curve) interpolator along x-axis.</param> /// <returns>The estimated value for position (<paramref name="rowIndex"/>, <paramref name="columnIndex"/>).</returns> /// <exception cref="InvalidOperationException">Thrown, if in the interpolation failed.</exception> internal static double GetInterpolatedValueAlongXAxis(int rowIndex, int columnIndex, IList <double> matrix, int rowCount, int columnCount, IList <double> xAxisLabeling, ICurveDataFitting curveInterpolator) { int leftIndex = columnIndex; bool foundLeftValue = false; while ((leftIndex >= 1) && (foundLeftValue == false)) { leftIndex--; if (Double.IsNaN(matrix[rowIndex + leftIndex * rowCount]) == false) // matrix[rowIndex][leftIndex] { foundLeftValue = true; } } int rightIndex = columnIndex; bool foundRightValue = false; while ((rightIndex <= columnCount - 2) && (foundRightValue == false)) { rightIndex++; if (Double.IsNaN(matrix[rowIndex + rightIndex * rowCount]) == false) // matrix[rowIndex][rightIndex] { foundRightValue = true; } } if (foundLeftValue && foundRightValue) { curveInterpolator.Update(2, xAxisLabeling, matrix, GridPointCurve.State.GridPointChanged, leftIndex, rowIndex + leftIndex * rowCount, rightIndex - leftIndex, rowCount * (rightIndex - leftIndex)); return(curveInterpolator.GetValue(xAxisLabeling[columnIndex])); } else if (foundLeftValue) { return(matrix[rowIndex + leftIndex * rowCount]); // matrix[rowIndex][leftIndex] } else if (foundRightValue) { return(matrix[rowIndex + rightIndex * rowCount]); // matrix[rowIndex][rightIndex] } throw new InvalidOperationException(String.Format("Replenish failed at position ({0};{1}).", rowIndex, columnIndex)); }
/// <summary>Initializes a new instance of the <see cref="Differentiable"/> class. /// </summary> /// <param name="curveParametrizationFactory">The curve parametrization factory.</param> /// <param name="curveParametrization">The curve parametrization.</param> /// <param name="capacity">The number of elements that the new grid point curve can initially store.</param> internal Differentiable(GridPointCurve.Parametrization curveParametrizationFactory, ICurveDataFitting curveParametrization, int capacity) : base(curveParametrizationFactory, curveParametrization, capacity) { }
/// <summary>Initializes a new instance of the <see cref="Replenishment"/> class. /// </summary> /// <param name="horizontalInterpolator">The (curve) interpolator along x-axis.</param> internal Replenishment(GridPointCurve.Interpolator horizontalInterpolator) { m_HorizontalInterpolator = horizontalInterpolator.Create(); }
/// <summary>Initializes a new instance of the <see cref="Extrapolator"/> class. /// </summary> /// <param name="curveInterpolator">The interpolation approach of the curve.</param> /// <param name="extrapolatorFactory">The <see cref="GridPointCurve.Extrapolator"/> object that serves as factory for the current object.</param> public Extrapolator(ICurveDataFitting curveInterpolator, GridPointCurve.Extrapolator extrapolatorFactory) { m_CurveBuilder = curveInterpolator; Factory = extrapolatorFactory; }
/// <summary>Initializes a new instance of the <see cref="Replenishment"/> class. /// </summary> /// <param name="horizontalInterpolator">The (curve) interpolator along x-axis.</param> /// <param name="verticalInterpolator"></param> /// <param name="weight">The weight for the convex combination of the interpolated values which are the result of a linear interpolation in horizontal and vertical direction.</param> internal Replenishment(GridPointCurve.Interpolator horizontalInterpolator, GridPointCurve.Interpolator verticalInterpolator, double weight) { m_HorizontalInterpolator = horizontalInterpolator.Create(); m_VerticalInterpolator = verticalInterpolator.Create(); m_Weight = weight; }