/// <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];
            }
Exemplo n.º 2
0
            /// <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="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;
        }
Exemplo n.º 5
0
        /// <summary>Initializes a new instance of the <see cref="SmartReadOnlyGridPointCurve&lt;TLabel&gt;"/> 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>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)
 {
 }
Exemplo n.º 7
0
 /// <summary>Initializes a new instance of the <see cref="Differentiable"/> 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 Differentiable(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)
     : base(curveInterpolator, leftExtrapolator, rightExtrapolator, gridPointCount, gridPointLabels, gridPointArguments, gridPointValues, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement, gridPointValueIncrement)
 {
 }