File indexing completed on 2024-12-22 04:09:52
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 NUBASIS_H 0022 #define NUBASIS_H 0023 0024 #include "nugrid.h" 0025 //#include "config.h" 0026 0027 typedef struct 0028 { 0029 NUgrid* restrict grid; 0030 // xVals is just the grid points, augmented by two extra points on 0031 // either side. These are necessary to generate enough basis 0032 // functions. 0033 double* restrict xVals; 0034 // dxInv[3*i+j] = 1.0/(grid(i+j-1)-grid(i-2)) 0035 double* restrict dxInv; 0036 bool periodic; 0037 } NUBasis; 0038 0039 0040 #ifdef __cplusplus 0041 extern "C" { 0042 #endif 0043 0044 ///////////////// 0045 // Constructor // 0046 ///////////////// 0047 NUBasis* 0048 create_NUBasis (NUgrid *grid, bool periodic); 0049 0050 //////////////// 0051 // Destructor // 0052 //////////////// 0053 void 0054 destroy_NUBasis (NUBasis *basis); 0055 0056 0057 //////////////////////////////////////////////// 0058 // Single-precision basis function evaluation // 0059 //////////////////////////////////////////////// 0060 int 0061 get_NUBasis_funcs_s (NUBasis* restrict basis, double x, 0062 float bfuncs[4]); 0063 void 0064 get_NUBasis_funcs_si (NUBasis* restrict basis, int i, 0065 float bfuncs[4]); 0066 0067 int 0068 get_NUBasis_dfuncs_s (NUBasis* restrict basis, double x, 0069 float bfuncs[4], float dbfuncs[4]); 0070 void 0071 get_NUBasis_dfuncs_si (NUBasis* restrict basis, int i, 0072 float bfuncs[4], float dbfuncs[4]); 0073 0074 int 0075 get_NUBasis_d2funcs_s (NUBasis* restrict basis, double x, 0076 float bfuncs[4], float dbfuncs[4], float d2bfuncs[4]); 0077 void 0078 get_NUBasis_d2funcs_si (NUBasis* restrict basis, int i, 0079 float bfuncs[4], float dbfuncs[4], float d2bfuncs[4]); 0080 0081 //////////////////////////////////////////////// 0082 // Double-precision basis function evaluation // 0083 //////////////////////////////////////////////// 0084 int 0085 get_NUBasis_funcs_d (NUBasis* restrict basis, double x, 0086 double bfuncs[4]); 0087 void 0088 get_NUBasis_funcs_di (NUBasis* restrict basis, int i, 0089 double bfuncs[4]); 0090 int 0091 get_NUBasis_dfuncs_d (NUBasis* restrict basis, double x, 0092 double bfuncs[4], double dbfuncs[4]); 0093 void 0094 get_NUBasis_dfuncs_di (NUBasis* restrict basis, int i, 0095 double bfuncs[4], double dbfuncs[4]); 0096 int 0097 get_NUBasis_d2funcs_d (NUBasis* restrict basis, double x, 0098 double bfuncs[4], double dbfuncs[4], 0099 double d2bfuncs[4]); 0100 void 0101 get_NUBasis_d2funcs_di (NUBasis* restrict basis, int i, 0102 double bfuncs[4], double dbfuncs[4], 0103 double d2bfuncs[4]); 0104 #ifdef __cplusplus 0105 } 0106 #endif 0107 0108 #ifdef HAVE_SSE2 0109 #include <xmmintrin.h> 0110 #include <emmintrin.h> 0111 0112 #ifdef __cplusplus 0113 extern "C" { 0114 #endif 0115 int 0116 get_NUBasis_funcs_sse_s (NUBasis* restrict basis, double x, 0117 __m128 *restrict funcs); 0118 int 0119 get_NUBasis_dfuncs_sse_s (NUBasis* restrict basis, double x, 0120 __m128 *restrict funcs, __m128 *restrict dfuncs); 0121 int 0122 get_NUBasis_d2funcs_sse_s (NUBasis* restrict basis, double x, 0123 __m128 *restrict funcs, 0124 __m128 *restrict dfuncs, 0125 __m128 *restrict d2funcs); 0126 0127 int 0128 get_NUBasis_funcs_sse_d (NUBasis* restrict basis, double x, 0129 __m128d *restrict f01, __m128d *restrict f23); 0130 int 0131 get_NUBasis_dfuncs_sse_d (NUBasis* restrict basis, double x, 0132 __m128d *restrict f01, __m128d *restrict f23, 0133 __m128d *restrict df01, __m128d *restrict df23); 0134 int 0135 get_NUBasis_d2funcs_sse_d (NUBasis* restrict basis, double x, 0136 __m128d *restrict f01, __m128d *restrict f23, 0137 __m128d *restrict df01, __m128d *restrict df23, 0138 __m128d *restrict d2f01, __m128d *restrict d2f23); 0139 #ifdef __cplusplus 0140 } 0141 #endif 0142 #endif // #ifdef HAVE_SSE2 0143 0144 #endif // #ifdef NUBASIS_H