1 ///////////////////////////////////////////////////////////////////////////// 2 // einspline: a library for creating and evaluating B-splines // 3 // Copyright (C) 2007 Kenneth P. Esler, Jr. // 4 // // 5 // This program is free software; you can redistribute it and/or modify // 6 // it under the terms of the GNU General Public License as published by // 7 // the Free Software Foundation; either version 2 of the License, or // 8 // (at your option) any later version. // 9 // // 10 // This program is distributed in the hope that it will be useful, // 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 13 // GNU General Public License for more details. // 14 // // 15 // You should have received a copy of the GNU General Public License // 16 // along with this program; if not, write to the Free Software // 17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, // 18 // Boston, MA 02110-1301 USA // 19 ///////////////////////////////////////////////////////////////////////////// 20 21 #ifndef NUGRID_H 22 #define NUGRID_H 23 24 #include "local_definitions.h" 25 26 typedef enum { LINEAR, GENERAL, CENTER, LOG } grid_type; 27 28 // Nonuniform grid base structure 29 typedef struct 30 { 31 // public data 32 grid_type code; 33 double start, end; 34 double* restrict points; 35 int num_points; 36 int (*reverse_map)(void *grid, double x); 37 } NUgrid; 38 39 #ifdef __cplusplus 40 extern "C" 41 #endif 42 43 44 typedef struct 45 { 46 // public data 47 grid_type code; 48 double start, end; 49 double* restrict points; 50 int num_points; 51 int (*reverse_map)(void *grid, double x); 52 53 // private data 54 double a, aInv, b, bInv, center, even_half; 55 int half_points, odd_one; 56 bool odd; 57 } center_grid; 58 59 60 typedef struct 61 { 62 // public data 63 grid_type code; 64 double start, end; 65 double* restrict points; 66 int num_points; 67 int (*reverse_map)(void *grid, double x); 68 69 // private data 70 double a, ainv, startinv; 71 } log_grid; 72 73 74 #ifdef __cplusplus 75 extern "C" { 76 #endif 77 78 NUgrid* 79 create_center_grid (double start, double end, double ratio, 80 int num_points); 81 82 NUgrid* 83 create_log_grid (double start, double end, int num_points); 84 85 NUgrid* 86 create_general_grid (double *points, int num_points); 87 88 void 89 destroy_grid (NUgrid *grid); 90 91 #ifdef __cplusplus 92 } 93 #endif 94 #endif 95