/// <summary>Creates a new <see cref="IGridPointCurve<TLabel>"/> object with respect to a specified curve parametrization. /// </summary> /// <param name="curveParametrization">The curve parametrization.</param> /// <param name="capacity">The number of elements that the new grid point curve can initially store.</param> /// <returns>A <see cref="IGridPointCurve{TLabel}"/> object with respect to a specified curve parametrization.</returns> public static IGridPointCurve <double> Create(Parametrization curveParametrization, int capacity = 20) { if (curveParametrization == null) { throw new ArgumentException(nameof(curveParametrization)); } var parametrization = curveParametrization.Create(); if (parametrization is IDifferentiableRealValuedCurve) { return(new StandardGridPointCurveNoLabels.Differentiable(curveParametrization, parametrization, capacity)); } return(new StandardGridPointCurveNoLabels(curveParametrization, parametrization, capacity)); }
/// <summary>Creates a new read-only <see cref="IGridPointCurve<TLabel>"/> object with respect to a specified curve parametrization. /// </summary> /// <typeparam name="TLabel">The type of the label.</typeparam> /// <param name="curveParametrization">The 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 in ascending order.</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> /// <returns>A read-only <see cref="IGridPointCurve<TLabel>"/> object with respect to the desired interpolation and extrapolation approaches.</returns> /// <remarks>This method is mainly used for two-dimensional surface interpolation. Assuming a large grid point matrix, for example 1.000 x 1.000 and one may apply for example a linear interpolation /// along horizontal direction and afterwards a linear interpolation along vertical direction. Then we create 1.000 curves in horizontal direction, where the (double) labels and values are constant. The /// standard implementation create a copy of 3 * 1.000 x 1.000 = 3.000.000 values and calles the update method of the underlying <see cref="ICurveDataFitting"/> object which again copy 2 * 1.000 * 1.000 = 2.000.000 values, i.e. in total 5 Mio values. /// This implementation takes into account references, the underlying <see cref="ICurveDataFitting"/> implementation should create deep copies of grid point arguments/values only, i.e. 2 Mio double values.</remarks> public static IGridPointCurve <TLabel> Create <TLabel>(Parametrization curveParametrization, int gridPointCount, IList <TLabel> gridPointLabels, IList <double> gridPointArguments, IList <double> gridPointValues, int gridPointArgumentStartIndex = 0, int gridPointValueStartIndex = 0, int gridPointArgumentIncrement = 1, int gridPointValueIncrement = 1) where TLabel : IEquatable <TLabel> { if (curveParametrization == null) { throw new ArgumentException(nameof(curveParametrization)); } var parametrization = curveParametrization.Create(); if (parametrization is IDifferentiableRealValuedCurve) { return(new SmartReadOnlyGridPointCurve <TLabel> .Differentiable(parametrization, gridPointCount, gridPointLabels, gridPointArguments, gridPointValues, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement, gridPointValueIncrement)); } return(new SmartReadOnlyGridPointCurve <TLabel>(parametrization, gridPointCount, gridPointLabels, gridPointArguments, gridPointValues, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement, gridPointValueIncrement)); }