File indexing completed on 2024-12-22 04:09:56

0001 /////////////////////////////////////////////////////////////////////////////
0002 //  einspline:  a library for creating and evaluating B-splines            //
0003 //  Copyright (C) 2007 Kenneth P. Esler, Jr.                               //
0004 //                                                                         //
0005 //  This program is free software; you can redistribute it and/or modify   //
0006 //  it under the terms of the GNU General Public License as published by   //
0007 //  the Free Software Foundation; either version 2 of the License, or      //
0008 //  (at your option) any later version.                                    //
0009 //                                                                         //
0010 //  This program is distributed in the hope that it will be useful,        //
0011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of         //
0012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          //
0013 //  GNU General Public License for more details.                           //
0014 //                                                                         //
0015 //  You should have received a copy of the GNU General Public License      //
0016 //  along with this program; if not, write to the Free Software            //
0017 //  Foundation, Inc., 51 Franklin Street, Fifth Floor,                     //
0018 //  Boston, MA  02110-1301  USA                                            //
0019 /////////////////////////////////////////////////////////////////////////////
0020 
0021 #ifndef NUGRID_H
0022 #define NUGRID_H
0023 
0024 #include "local_definitions.h"
0025 
0026 typedef enum { LINEAR, GENERAL, CENTER, LOG } grid_type;
0027 
0028 // Nonuniform grid base structure
0029 typedef struct
0030 {
0031   // public data
0032   grid_type code;
0033   double start, end;
0034   double* restrict points;
0035   int num_points;
0036   int (*reverse_map)(void *grid, double x);
0037 } NUgrid;
0038 
0039 #ifdef __cplusplus
0040 extern "C" 
0041 #endif
0042 
0043 
0044 typedef struct
0045 {
0046   // public data
0047   grid_type code;
0048   double start, end;
0049   double* restrict points;
0050   int num_points;
0051   int (*reverse_map)(void *grid, double x);
0052 
0053   // private data
0054   double a, aInv, b, bInv, center, even_half;
0055   int half_points, odd_one;
0056   bool odd;
0057 } center_grid;
0058 
0059 
0060 typedef struct
0061 {
0062   // public data
0063   grid_type code;
0064   double start, end;
0065   double* restrict points;
0066   int num_points;
0067   int (*reverse_map)(void *grid, double x);
0068 
0069   // private data
0070   double a, ainv, startinv;
0071 } log_grid;
0072 
0073 
0074 #ifdef __cplusplus
0075 extern "C" {
0076 #endif
0077 
0078 NUgrid*
0079 create_center_grid (double start, double end, double ratio, 
0080             int num_points);
0081 
0082 NUgrid*
0083 create_log_grid (double start, double end, int num_points);
0084 
0085 NUgrid*
0086 create_general_grid (double *points, int num_points);
0087 
0088 void
0089 destroy_grid (NUgrid *grid);
0090 
0091 #ifdef __cplusplus
0092 }
0093 #endif
0094 #endif