Ejemplo n.º 1
0
 /*************************************************************************
 *  This subroutine differentiates the spline.
 *
 *  INPUT PARAMETERS:
 *   C   -   spline interpolant.
 *   X   -   point
 *
 *  Result:
 *   S   -   S(x)
 *   DS  -   S'(x)
 *   D2S -   S''(x)
 *
 *  -- ALGLIB PROJECT --
 *    Copyright 24.06.2007 by Bochkanov Sergey
 *************************************************************************/
 public static void spline1ddiff(Spline1dinterpolant c, double x, out double s, out double ds, out double d2s)
 {
     s   = 0;
     ds  = 0;
     d2s = 0;
     Spline1d.spline1ddiff(c.innerobj, x, ref s, ref ds, ref d2s);
     return;
 }
Ejemplo n.º 2
0
        public static void spline1dbuildlinear(double[] x, double[] y, out Spline1dinterpolant c)
        {
            int n;

            if ((ap.len(x) != ap.len(y)))
            {
                throw new alglibexception("Ошибка при вызове 'spline1dbuildlinear': похоже, что один из аргументов имеет неправильный размер");
            }
            c = new Spline1dinterpolant();
            n = ap.len(x);
            Spline1d.spline1dbuildlinear(x, y, n, c.innerobj);
        }
Ejemplo n.º 3
0
        public static void spline1dbuildhermite(double[] x, double[] y, double[] d, out Spline1dinterpolant c)
        {
            int n;

            if ((ap.len(x) != ap.len(y)) || (ap.len(x) != ap.len(d)))
            {
                throw new alglibexception("Error while calling 'spline1dbuildhermite': looks like one of arguments has wrong size");
            }
            c = new Spline1dinterpolant();
            n = ap.len(x);
            Spline1d.spline1dbuildhermite(x, y, d, n, c.innerobj);

            return;
        }
Ejemplo n.º 4
0
        public static void spline1dbuildcatmullrom(double[] x, double[] y, out Spline1dinterpolant c)
        {
            int    n;
            int    boundtype;
            double tension;

            if ((ap.len(x) != ap.len(y)))
            {
                throw new alglibexception("Error while calling 'spline1dbuildcatmullrom': looks like one of arguments has wrong size");
            }
            c         = new Spline1dinterpolant();
            n         = ap.len(x);
            boundtype = 0;
            tension   = 0;
            Spline1d.spline1dbuildcatmullrom(x, y, n, boundtype, tension, c.innerobj);

            return;
        }
Ejemplo n.º 5
0
        public static void spline1dbuildcubic(double[] x, double[] y, out Spline1dinterpolant c)
        {
            int    n;
            int    boundltype;
            double boundl;
            int    boundrtype;
            double boundr;

            if ((ap.len(x) != ap.len(y)))
            {
                throw new alglibexception("Error while calling 'spline1dbuildcubic': looks like one of arguments has wrong size");
            }
            c          = new Spline1dinterpolant();
            n          = ap.len(x);
            boundltype = 0;
            boundl     = 0;
            boundrtype = 0;
            boundr     = 0;
            Spline1d.spline1dbuildcubic(x, y, n, boundltype, boundl, boundrtype, boundr, c.innerobj);

            return;
        }
Ejemplo n.º 6
0
 /*************************************************************************
 *  This subroutine builds Hermite spline interpolant.
 *
 *  INPUT PARAMETERS:
 *   X           -   spline nodes, array[0..N-1]
 *   Y           -   function values, array[0..N-1]
 *   D           -   derivatives, array[0..N-1]
 *   N           -   points count (optional):
 * N>=2
 * if given, only first N points are used to build spline
 * if not given, automatically detected from X/Y sizes
 *                     (len(X) must be equal to len(Y))
 *
 *  OUTPUT PARAMETERS:
 *   C           -   spline interpolant.
 *
 *
 *  ORDER OF POINTS
 *
 *  Subroutine automatically sorts points, so caller may pass unsorted array.
 *
 *  -- ALGLIB PROJECT --
 *    Copyright 23.06.2007 by Bochkanov Sergey
 *************************************************************************/
 public static void spline1dbuildhermite(double[] x, double[] y, double[] d, int n, out Spline1dinterpolant c)
 {
     c = new Spline1dinterpolant();
     Spline1d.spline1dbuildhermite(x, y, d, n, c.innerobj);
     return;
 }
Ejemplo n.º 7
0
 /*************************************************************************
 *  This subroutine builds cubic spline interpolant.
 *
 *  INPUT PARAMETERS:
 *   X           -   spline nodes, array[0..N-1].
 *   Y           -   function values, array[0..N-1].
 *
 *  OPTIONAL PARAMETERS:
 *   N           -   points count:
 * N>=2
 * if given, only first N points are used to build spline
 * if not given, automatically detected from X/Y sizes
 *                     (len(X) must be equal to len(Y))
 *   BoundLType  -   boundary condition type for the left boundary
 *   BoundL      -   left boundary condition (first or second derivative,
 *                   depending on the BoundLType)
 *   BoundRType  -   boundary condition type for the right boundary
 *   BoundR      -   right boundary condition (first or second derivative,
 *                   depending on the BoundRType)
 *
 *  OUTPUT PARAMETERS:
 *   C           -   spline interpolant
 *
 *  ORDER OF POINTS
 *
 *  Subroutine automatically sorts points, so caller may pass unsorted array.
 *
 *  SETTING BOUNDARY VALUES:
 *
 *  The BoundLType/BoundRType parameters can have the following values:
 * -1, which corresonds to the periodic (cyclic) boundary conditions.
 *         In this case:
 * both BoundLType and BoundRType must be equal to -1.
 * BoundL/BoundR are ignored
 * Y[last] is ignored (it is assumed to be equal to Y[first]).
 *  0, which  corresponds  to  the  parabolically   terminated  spline
 *         (BoundL and/or BoundR are ignored).
 *  1, which corresponds to the first derivative boundary condition
 *  2, which corresponds to the second derivative boundary condition
 *  by default, BoundType=0 is used
 *
 *  PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
 *
 *  Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
 *  However, this subroutine doesn't require you to specify equal  values  for
 *  the first and last points - it automatically forces them  to  be  equal by
 *  copying  Y[first_point]  (corresponds  to the leftmost,  minimal  X[])  to
 *  Y[last_point]. However it is recommended to pass consistent values of Y[],
 *  i.e. to make Y[first_point]=Y[last_point].
 *
 *  -- ALGLIB PROJECT --
 *    Copyright 23.06.2007 by Bochkanov Sergey
 *************************************************************************/
 public static void spline1dbuildcubic(double[] x, double[] y, int n, int boundltype, double boundl, int boundrtype, double boundr, out Spline1dinterpolant c)
 {
     c = new Spline1dinterpolant();
     Spline1d.spline1dbuildcubic(x, y, n, boundltype, boundl, boundrtype, boundr, c.innerobj);
     return;
 }
Ejemplo n.º 8
0
 /*************************************************************************
 *  This subroutine builds Catmull-Rom spline interpolant.
 *
 *  INPUT PARAMETERS:
 *   X           -   spline nodes, array[0..N-1].
 *   Y           -   function values, array[0..N-1].
 *
 *  OPTIONAL PARAMETERS:
 *   N           -   points count:
 * N>=2
 * if given, only first N points are used to build spline
 * if not given, automatically detected from X/Y sizes
 *                     (len(X) must be equal to len(Y))
 *   BoundType   -   boundary condition type:
 * -1 for periodic boundary condition
 *  0 for parabolically terminated spline (default)
 *   Tension     -   tension parameter:
 * tension=0   corresponds to classic Catmull-Rom spline (default)
 * 0<tension<1 corresponds to more general form - cardinal spline
 *
 *  OUTPUT PARAMETERS:
 *   C           -   spline interpolant
 *
 *
 *  ORDER OF POINTS
 *
 *  Subroutine automatically sorts points, so caller may pass unsorted array.
 *
 *  PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
 *
 *  Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
 *  However, this subroutine doesn't require you to specify equal  values  for
 *  the first and last points - it automatically forces them  to  be  equal by
 *  copying  Y[first_point]  (corresponds  to the leftmost,  minimal  X[])  to
 *  Y[last_point]. However it is recommended to pass consistent values of Y[],
 *  i.e. to make Y[first_point]=Y[last_point].
 *
 *  -- ALGLIB PROJECT --
 *    Copyright 23.06.2007 by Bochkanov Sergey
 *************************************************************************/
 public static void spline1dbuildcatmullrom(double[] x, double[] y, int n, int boundtype, double tension, out Spline1dinterpolant c)
 {
     c = new Spline1dinterpolant();
     Spline1d.spline1dbuildcatmullrom(x, y, n, boundtype, tension, c.innerobj);
     return;
 }
Ejemplo n.º 9
0
 /*************************************************************************
 *  Эта подпрограмма строит интеполянт линейного сплайна
 *
 *  ВХОДНЫЕ ПАРАМЕТРЫ:
 *   X   -   узлы сплайна, массив[0..N-1]
 *   Y   -   значения функци, массив[0..N-1]
 *   N   -   число точек (опционально):
 * N>=2
 * если задано, для построения сплайна используются только первые N точек
 * если не указано, автоматически определяется по размерам X / Y
 *             (length(X) должно быть равно length(Y))
 *
 *  ВЫХОДНЫЕ ПАРАМЕТРЫ:
 *   C   -   интерполянт сплайна
 *
 *
 *  ПОРЯДОК ТОЧЕК:
 *
 *  Подпрограмма автоматически сортирует точки, поэтому вызывающий может передать несортированный массив.
 *
 *  -- ALGLIB PROJECT --
 *    Copyright 24.06.2007 by Bochkanov Sergey
 *************************************************************************/
 public static void spline1dbuildlinear(double[] x, double[] y, int n, out Spline1dinterpolant c)
 {
     c = new Spline1dinterpolant();
     Spline1d.spline1dbuildlinear(x, y, n, c.innerobj);
 }
Ejemplo n.º 10
0
        /*************************************************************************
        *  This subroutine integrates the spline.
        *
        *  INPUT PARAMETERS:
        *   C   -   spline interpolant.
        *   X   -   right bound of the integration interval [a, x],
        *           here 'a' denotes min(x[])
        *  Result:
        *   integral(S(t)dt,a,x)
        *
        *  -- ALGLIB PROJECT --
        *    Copyright 23.06.2007 by Bochkanov Sergey
        *************************************************************************/
        public static double spline1dintegrate(Spline1dinterpolant c, double x)
        {
            double result = Spline1d.spline1dintegrate(c.innerobj, x);

            return(result);
        }
Ejemplo n.º 11
0
 /*************************************************************************
 *  This subroutine builds Akima spline interpolant
 *
 *  INPUT PARAMETERS:
 *   X           -   spline nodes, array[0..N-1]
 *   Y           -   function values, array[0..N-1]
 *   N           -   points count (optional):
 * N>=2
 * if given, only first N points are used to build spline
 * if not given, automatically detected from X/Y sizes
 *                     (len(X) must be equal to len(Y))
 *
 *  OUTPUT PARAMETERS:
 *   C           -   spline interpolant
 *
 *
 *  ORDER OF POINTS
 *
 *  Subroutine automatically sorts points, so caller may pass unsorted array.
 *
 *  -- ALGLIB PROJECT --
 *    Copyright 24.06.2007 by Bochkanov Sergey
 *************************************************************************/
 public static void spline1dbuildakima(double[] x, double[] y, int n, out Spline1dinterpolant c)
 {
     c = new Spline1dinterpolant();
     Spline1d.spline1dbuildakima(x, y, n, c.innerobj);
     return;
 }