Krita Source Code Documentation
Loading...
Searching...
No Matches
nubspline_create.h File Reference

Go to the source code of this file.

Functions

NUgridcreate_center_grid (double start, double end, double ratio, int num_points)
 
NUgridcreate_general_grid (double *points, int num_points)
 
NUBspline_1d_ccreate_NUBspline_1d_c (NUgrid *x_grid, BCtype_c xBC, complex_float *data)
 
NUBspline_1d_dcreate_NUBspline_1d_d (NUgrid *x_grid, BCtype_d xBC, double *data)
 
NUBspline_1d_screate_NUBspline_1d_s (NUgrid *x_grid, BCtype_s xBC, float *data)
 
NUBspline_1d_zcreate_NUBspline_1d_z (NUgrid *x_grid, BCtype_z xBC, complex_double *data)
 
NUBspline_2d_ccreate_NUBspline_2d_c (NUgrid *x_grid, NUgrid *y_grid, BCtype_c xBC, BCtype_c yBC, complex_float *data)
 
NUBspline_2d_dcreate_NUBspline_2d_d (NUgrid *x_grid, NUgrid *y_grid, BCtype_d xBC, BCtype_d yBC, double *data)
 
NUBspline_2d_screate_NUBspline_2d_s (NUgrid *x_grid, NUgrid *y_grid, BCtype_s xBC, BCtype_s yBC, float *data)
 
NUBspline_2d_zcreate_NUBspline_2d_z (NUgrid *x_grid, NUgrid *restrict y_grid, BCtype_z xBC, BCtype_z yBC, complex_double *data)
 
NUBspline_3d_ccreate_NUBspline_3d_c (NUgrid *x_grid, NUgrid *y_grid, NUgrid *z_grid, BCtype_c xBC, BCtype_c yBC, BCtype_c zBC, complex_float *data)
 
NUBspline_3d_dcreate_NUBspline_3d_d (NUgrid *x_grid, NUgrid *y_grid, NUgrid *z_grid, BCtype_d xBC, BCtype_d yBC, BCtype_d zBC, double *data)
 
NUBspline_3d_screate_NUBspline_3d_s (NUgrid *x_grid, NUgrid *y_grid, NUgrid *z_grid, BCtype_s xBC, BCtype_s yBC, BCtype_s zBC, float *data)
 
NUBspline_3d_zcreate_NUBspline_3d_z (NUgrid *x_grid, NUgrid *y_grid, NUgrid *z_grid, BCtype_z xBC, BCtype_z yBC, BCtype_z zBC, complex_double *data)
 

Function Documentation

◆ create_center_grid()

NUgrid * create_center_grid ( double start,
double end,
double ratio,
int num_points )

Definition at line 83 of file nugrid.cpp.

85{
86 center_grid *grid = new center_grid;
87 if (grid != NULL) {
88 assert (ratio > 1.0);
89 grid->start = start;
90 grid->end = end;
91 grid->center = 0.5*(start + end);
92 grid->num_points = num_points;
93 grid->half_points = num_points/2;
94 grid->odd = ((num_points % 2) == 1);
95 grid->b = log(ratio) / (double)(grid->half_points-1);
96 grid->bInv = 1.0/grid->b;
97 grid->points = new double[num_points];
98 if (grid->odd) {
99 grid->even_half = 0.0;
100 grid->odd_one = 1;
101 grid->a = 0.5*(end-start)/expm1(grid->b*grid->half_points);
102 grid->aInv = 1.0/grid->a;
103 for (int i=-grid->half_points; i<=grid->half_points; i++) {
104 double sign;
105 if (i<0)
106 sign = -1.0;
107 else
108 sign = 1.0;
109 grid->points[i+grid->half_points] =
110 sign * grid->a*expm1(grid->b*abs(i))+grid->center;
111 }
112 }
113 else {
114 grid->even_half = 0.5;
115 grid->odd_one = 0;
116 grid->a =
117 0.5*(end-start)/expm1(grid->b*(-0.5+grid->half_points));
118 grid->aInv = 1.0/grid->a;
119 for (int i=-grid->half_points; i<grid->half_points; i++) {
120 double sign;
121 if (i<0) sign = -1.0;
122 else sign = 1.0;
123 grid->points[i+grid->half_points] =
124 sign * grid->a*expm1(grid->b*fabs(0.5+i)) + grid->center;
125 }
126 }
128 grid->code = CENTER;
129 }
130 return (NUgrid*) grid;
131}
Point abs(const Point &pt)
int center_grid_reverse_map(void *gridptr, double x)
Definition nugrid.cpp:32
@ CENTER
Definition nugrid.h:26
int odd_one
Definition nugrid.h:55
double end
Definition nugrid.h:48
grid_type code
Definition nugrid.h:47
int(* reverse_map)(void *grid, double x)
Definition nugrid.h:51
double a
Definition nugrid.h:54
double *restrict points
Definition nugrid.h:49
int num_points
Definition nugrid.h:50
int half_points
Definition nugrid.h:55
double even_half
Definition nugrid.h:54
double b
Definition nugrid.h:54
double center
Definition nugrid.h:54
double aInv
Definition nugrid.h:54
bool odd
Definition nugrid.h:56
double bInv
Definition nugrid.h:54
double start
Definition nugrid.h:48

References center_grid::a, center_grid::aInv, center_grid::b, center_grid::bInv, CENTER, center_grid::center, center_grid_reverse_map(), center_grid::code, center_grid::end, center_grid::even_half, center_grid::half_points, center_grid::num_points, center_grid::odd, center_grid::odd_one, center_grid::points, center_grid::reverse_map, sign(), and center_grid::start.

◆ create_general_grid()

NUgrid * create_general_grid ( double * points,
int num_points )

Definition at line 155 of file nugrid.cpp.

156{
157 NUgrid* grid = new NUgrid;
158 if (grid != NULL) {
160 grid->code = GENERAL;
161 grid->points = new double[num_points];
162 grid->start = points[0];
163 grid->end = points[num_points-1];
164 grid->num_points = num_points;
165 for (int i=0; i<num_points; i++)
166 grid->points[i] = points[i];
167 grid->code = GENERAL;
168 }
169 return grid;
170}
int general_grid_reverse_map(void *gridptr, double x)
Definition nugrid.cpp:57
@ GENERAL
Definition nugrid.h:26
int(* reverse_map)(void *grid, double x)
Definition nugrid.h:36
int num_points
Definition nugrid.h:35
double end
Definition nugrid.h:33
double start
Definition nugrid.h:33
grid_type code
Definition nugrid.h:32
double *restrict points
Definition nugrid.h:34

References NUgrid::code, NUgrid::end, GENERAL, general_grid_reverse_map(), NUgrid::num_points, NUgrid::points, NUgrid::reverse_map, and NUgrid::start.

◆ create_NUBspline_1d_c()

NUBspline_1d_c * create_NUBspline_1d_c ( NUgrid * x_grid,
BCtype_c xBC,
complex_float * data )

Definition at line 763 of file nubspline_create.cpp.

764{
765 // First, create the spline structure
766 NUBspline_1d_c* spline = static_cast<NUBspline_1d_c*>(malloc(sizeof(NUBspline_1d_c)));
767 if (spline == NULL)
768 return spline;
769 spline->sp_code = NU1D;
770 spline->t_code = SINGLE_COMPLEX;
771
772 // Next, create the basis
773 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
774 // M is the number of data points
775// int M;
776// if (xBC.lCode == PERIODIC) M = x_grid->num_points - 1;
777// else M = x_grid->num_points;
778 int N = x_grid->num_points + 2;
779
780 // Allocate coefficients and solve
781 spline->coefs = (complex_float*)malloc (sizeof(complex_float)*N);
782 find_NUBcoefs_1d_c (spline->x_basis, xBC, data, 1, spline->coefs, 1);
783
784 return spline;
785}
complex float complex_float
@ SINGLE_COMPLEX
@ PERIODIC
@ NU1D
NUBasis * create_NUBasis(NUgrid *grid, bool periodic)
Definition nubasis.cpp:27
void find_NUBcoefs_1d_c(NUBasis *restrict basis, BCtype_c bc, complex_float *data, int dstride, complex_float *coefs, int cstride)
bc_code lCode
NUBasis *restrict x_basis
complex_float *restrict coefs

References NUBspline_1d_c::coefs, create_NUBasis(), find_NUBcoefs_1d_c(), BCtype_c::lCode, NU1D, NUgrid::num_points, PERIODIC, SINGLE_COMPLEX, NUBspline_1d_c::sp_code, NUBspline_1d_c::t_code, and NUBspline_1d_c::x_basis.

◆ create_NUBspline_1d_d()

NUBspline_1d_d * create_NUBspline_1d_d ( NUgrid * x_grid,
BCtype_d xBC,
double * data )

Definition at line 591 of file nubspline_create.cpp.

592{
593 // First, create the spline structure
594 NUBspline_1d_d* spline = static_cast<NUBspline_1d_d*>(malloc(sizeof(NUBspline_1d_d)));
595 if (spline == NULL)
596 return spline;
597 spline->sp_code = NU1D;
598 spline->t_code = DOUBLE_REAL;
599
600 // Next, create the basis
601 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
602 // M is the number of data points (set but unused)
603// int M;
604// if (xBC.lCode == PERIODIC) M = x_grid->num_points - 1;
605// else M = x_grid->num_points;
606 int N = x_grid->num_points + 2;
607
608 // Allocate coefficients and solve
609 spline->coefs = (double*)malloc (sizeof(double)*N);
610 find_NUBcoefs_1d_d (spline->x_basis, xBC, data, 1, spline->coefs, 1);
611
612 return spline;
613}
@ DOUBLE_REAL
void find_NUBcoefs_1d_d(NUBasis *restrict basis, BCtype_d bc, double *data, int dstride, double *coefs, int cstride)
bc_code lCode
double *restrict coefs
spline_code sp_code
NUBasis *restrict x_basis

References NUBspline_1d_d::coefs, create_NUBasis(), DOUBLE_REAL, find_NUBcoefs_1d_d(), BCtype_d::lCode, NU1D, NUgrid::num_points, PERIODIC, NUBspline_1d_d::sp_code, NUBspline_1d_d::t_code, and NUBspline_1d_d::x_basis.

◆ create_NUBspline_1d_s()

NUBspline_1d_s * create_NUBspline_1d_s ( NUgrid * x_grid,
BCtype_s xBC,
float * data )

Definition at line 247 of file nubspline_create.cpp.

248{
249 // First, create the spline structure
250 NUBspline_1d_s* spline = static_cast<NUBspline_1d_s*>(malloc(sizeof(NUBspline_1d_s)));
251 if (spline == NULL)
252 return spline;
253 spline->sp_code = NU1D;
254 spline->t_code = SINGLE_REAL;
255
256 // Next, create the basis
257 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
258 // M is the number of data points (but is unused)
259// int M;
260// if (xBC.lCode == PERIODIC) M = x_grid->num_points - 1;
261// else M = x_grid->num_points;
262 int N = x_grid->num_points + 2;
263
264 // Allocate coefficients and solve
265 spline->coefs = (float*)malloc (sizeof(float)*N);
266 find_NUBcoefs_1d_s (spline->x_basis, xBC, data, 1, spline->coefs, 1);
267
268 return spline;
269}
@ SINGLE_REAL
void find_NUBcoefs_1d_s(NUBasis *restrict basis, BCtype_s bc, float *data, int dstride, float *coefs, int cstride)
bc_code lCode
float *restrict coefs
NUBasis *restrict x_basis
spline_code sp_code

References NUBspline_1d_s::coefs, create_NUBasis(), find_NUBcoefs_1d_s(), BCtype_s::lCode, NU1D, NUgrid::num_points, PERIODIC, SINGLE_REAL, NUBspline_1d_s::sp_code, NUBspline_1d_s::t_code, and NUBspline_1d_s::x_basis.

◆ create_NUBspline_1d_z()

NUBspline_1d_z * create_NUBspline_1d_z ( NUgrid * x_grid,
BCtype_z xBC,
complex_double * data )

Definition at line 932 of file nubspline_create.cpp.

933{
934 // First, create the spline structure
935 NUBspline_1d_z* spline = static_cast<NUBspline_1d_z*>(malloc(sizeof(NUBspline_1d_z)));
936 if (spline == NULL)
937 return spline;
938 spline->sp_code = NU1D;
939 spline->t_code = DOUBLE_COMPLEX;
940
941 // Next, create the basis
942 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
943 // M is the number of data points
944// int M;
945// if (xBC.lCode == PERIODIC) M = x_grid->num_points - 1;
946// else M = x_grid->num_points;
947 int N = x_grid->num_points + 2;
948
949 // Allocate coefficients and solve
950 spline->coefs = (complex_double*)malloc (sizeof(complex_double)*N);
951 find_NUBcoefs_1d_z (spline->x_basis, xBC, data, 1, spline->coefs, 1);
952
953 return spline;
954}
@ DOUBLE_COMPLEX
complex double complex_double
void find_NUBcoefs_1d_z(NUBasis *restrict basis, BCtype_z bc, complex_double *data, int dstride, complex_double *coefs, int cstride)
bc_code lCode
complex_double *restrict coefs
NUBasis *restrict x_basis

References NUBspline_1d_z::coefs, create_NUBasis(), DOUBLE_COMPLEX, find_NUBcoefs_1d_z(), BCtype_z::lCode, NU1D, NUgrid::num_points, PERIODIC, NUBspline_1d_z::sp_code, NUBspline_1d_z::t_code, and NUBspline_1d_z::x_basis.

◆ create_NUBspline_2d_c()

NUBspline_2d_c * create_NUBspline_2d_c ( NUgrid * x_grid,
NUgrid * y_grid,
BCtype_c xBC,
BCtype_c yBC,
complex_float * data )

Definition at line 788 of file nubspline_create.cpp.

790{
791 // First, create the spline structure
792 NUBspline_2d_c* spline = static_cast<NUBspline_2d_c*>(malloc(sizeof(NUBspline_2d_c)));
793 if (spline == NULL)
794 return spline;
795 spline->sp_code = NU2D;
796 spline->t_code = SINGLE_COMPLEX;
797
798 // Next, create the bases
799 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
800 spline->y_basis = create_NUBasis (y_grid, yBC.lCode==PERIODIC);
801// int Mx,
802 int My, Nx, Ny;
803// if (xBC.lCode == PERIODIC) Mx = x_grid->num_points - 1;
804// else Mx = x_grid->num_points;
805 if (yBC.lCode == PERIODIC) My = y_grid->num_points - 1;
806 else My = y_grid->num_points;
807
808 Nx = x_grid->num_points + 2;
809 Ny = y_grid->num_points + 2;
810
811 spline->x_stride = Ny;
812#ifndef HAVE_SSE2
813 spline->coefs = (complex_float*)malloc (sizeof(complex_float)*Nx*Ny);
814#else
815 posix_memalign ((void**)&spline->coefs, 16, sizeof(complex_float)*Nx*Ny);
816#endif
817
818 // First, solve in the X-direction
819 for (int iy=0; iy<My; iy++) {
820 int doffset = iy;
821 int coffset = iy;
822 find_NUBcoefs_1d_c (spline->x_basis, xBC, data+doffset, My,
823 spline->coefs+coffset, Ny);
824 }
825
826 // Now, solve in the Y-direction
827 for (int ix=0; ix<Nx; ix++) {
828 int doffset = ix*Ny;
829 int coffset = ix*Ny;
830 find_NUBcoefs_1d_c (spline->y_basis, yBC, spline->coefs+doffset, 1,
831 spline->coefs+coffset, 1);
832 }
833
834 return spline;
835}
@ NU2D
int posix_memalign(void **memptr, size_t alignment, size_t size)
NUBasis *restrict *restrict y_basis
NUBasis *restrict x_basis
complex_float *restrict coefs

References NUBspline_2d_c::coefs, create_NUBasis(), find_NUBcoefs_1d_c(), BCtype_c::lCode, NU2D, NUgrid::num_points, PERIODIC, posix_memalign(), SINGLE_COMPLEX, NUBspline_2d_c::sp_code, NUBspline_2d_c::t_code, NUBspline_2d_c::x_basis, NUBspline_2d_c::x_stride, and NUBspline_2d_c::y_basis.

◆ create_NUBspline_2d_d()

NUBspline_2d_d * create_NUBspline_2d_d ( NUgrid * x_grid,
NUgrid * y_grid,
BCtype_d xBC,
BCtype_d yBC,
double * data )

Definition at line 616 of file nubspline_create.cpp.

618{
619 // First, create the spline structure
620 NUBspline_2d_d* spline = static_cast<NUBspline_2d_d*>(malloc(sizeof(NUBspline_2d_d)));
621 if (spline == NULL)
622 return spline;
623 spline->sp_code = NU2D;
624 spline->t_code = DOUBLE_REAL;
625
626 // Next, create the bases
627 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
628 spline->y_basis = create_NUBasis (y_grid, yBC.lCode==PERIODIC);
629
630 // int Mx, (set but unused)
631 int My, Nx, Ny;
632// if (xBC.lCode == PERIODIC) Mx = x_grid->num_points - 1;
633// else Mx = x_grid->num_points;
634 if (yBC.lCode == PERIODIC) My = y_grid->num_points - 1;
635 else My = y_grid->num_points;
636
637 Nx = x_grid->num_points + 2;
638 Ny = y_grid->num_points + 2;
639
640 spline->x_stride = Ny;
641#ifndef HAVE_SSE2
642 spline->coefs = (double*)malloc (sizeof(double)*Nx*Ny);
643#else
644 posix_memalign ((void**)&spline->coefs, 16, sizeof(double)*Nx*Ny);
645#endif
646
647 // First, solve in the X-direction
648 for (int iy=0; iy<My; iy++) {
649 int doffset = iy;
650 int coffset = iy;
651 find_NUBcoefs_1d_d (spline->x_basis, xBC, data+doffset, My,
652 spline->coefs+coffset, Ny);
653 }
654
655 // Now, solve in the Y-direction
656 for (int ix=0; ix<Nx; ix++) {
657 int doffset = ix*Ny;
658 int coffset = ix*Ny;
659 find_NUBcoefs_1d_d (spline->y_basis, yBC, spline->coefs+doffset, 1,
660 spline->coefs+coffset, 1);
661 }
662
663 return spline;
664}
double *restrict coefs
NUBasis *restrict *restrict y_basis
NUBasis *restrict x_basis

References NUBspline_2d_d::coefs, create_NUBasis(), DOUBLE_REAL, find_NUBcoefs_1d_d(), BCtype_d::lCode, NU2D, NUgrid::num_points, PERIODIC, posix_memalign(), NUBspline_2d_d::sp_code, NUBspline_2d_d::t_code, NUBspline_2d_d::x_basis, NUBspline_2d_d::x_stride, and NUBspline_2d_d::y_basis.

◆ create_NUBspline_2d_s()

NUBspline_2d_s * create_NUBspline_2d_s ( NUgrid * x_grid,
NUgrid * y_grid,
BCtype_s xBC,
BCtype_s yBC,
float * data )

Definition at line 272 of file nubspline_create.cpp.

274{
275 // First, create the spline structure
276 NUBspline_2d_s* spline = static_cast<NUBspline_2d_s*>(malloc(sizeof(NUBspline_2d_s)));
277 if (spline == NULL)
278 return spline;
279 spline->sp_code = NU2D;
280 spline->t_code = SINGLE_REAL;
281
282 // Next, create the bases
283 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
284 spline->y_basis = create_NUBasis (y_grid, yBC.lCode==PERIODIC);
285 // set but unused
286 //int Mx,
287 int My, Nx, Ny;
288// if (xBC.lCode == PERIODIC) Mx = x_grid->num_points - 1;
289// else Mx = x_grid->num_points;
290 if (yBC.lCode == PERIODIC) My = y_grid->num_points - 1;
291 else My = y_grid->num_points;
292
293 Nx = x_grid->num_points + 2;
294 Ny = y_grid->num_points + 2;
295
296 spline->x_stride = Ny;
297#ifndef HAVE_SSE2
298 spline->coefs = (float*)malloc (sizeof(float)*Nx*Ny);
299#else
300 posix_memalign ((void**)&spline->coefs, 16, sizeof(float)*Nx*Ny);
301#endif
302
303 // First, solve in the X-direction
304 for (int iy=0; iy<My; iy++) {
305 int doffset = iy;
306 int coffset = iy;
307 find_NUBcoefs_1d_s (spline->x_basis, xBC, data+doffset, My,
308 spline->coefs+coffset, Ny);
309 }
310
311 // Now, solve in the Y-direction
312 for (int ix=0; ix<Nx; ix++) {
313 int doffset = ix*Ny;
314 int coffset = ix*Ny;
315 find_NUBcoefs_1d_s (spline->y_basis, yBC, spline->coefs+doffset, 1,
316 spline->coefs+coffset, 1);
317 }
318
319 return spline;
320}
NUBasis *restrict *restrict y_basis
NUBasis *restrict x_basis
float *restrict coefs
spline_code sp_code

References NUBspline_2d_s::coefs, create_NUBasis(), find_NUBcoefs_1d_s(), BCtype_s::lCode, NU2D, NUgrid::num_points, PERIODIC, posix_memalign(), SINGLE_REAL, NUBspline_2d_s::sp_code, NUBspline_2d_s::t_code, NUBspline_2d_s::x_basis, NUBspline_2d_s::x_stride, and NUBspline_2d_s::y_basis.

◆ create_NUBspline_2d_z()

NUBspline_2d_z * create_NUBspline_2d_z ( NUgrid * x_grid,
NUgrid *restrict y_grid,
BCtype_z xBC,
BCtype_z yBC,
complex_double * data )

◆ create_NUBspline_3d_c()

NUBspline_3d_c * create_NUBspline_3d_c ( NUgrid * x_grid,
NUgrid * y_grid,
NUgrid * z_grid,
BCtype_c xBC,
BCtype_c yBC,
BCtype_c zBC,
complex_float * data )

Definition at line 839 of file nubspline_create.cpp.

841{
842 // First, create the spline structure
843 NUBspline_3d_c* spline = static_cast<NUBspline_3d_c*>(malloc(sizeof(NUBspline_3d_c)));
844 if (spline == NULL)
845 return spline;
846 spline->sp_code = NU3D;
847 spline->t_code = SINGLE_COMPLEX;
848
849 // Next, create the bases
850 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
851 spline->y_basis = create_NUBasis (y_grid, yBC.lCode==PERIODIC);
852 spline->z_basis = create_NUBasis (z_grid, zBC.lCode==PERIODIC);
853// int Mx,
854 int My, Mz, Nx, Ny, Nz;
855// if (xBC.lCode == PERIODIC) Mx = x_grid->num_points - 1;
856// else Mx = x_grid->num_points;
857 if (yBC.lCode == PERIODIC) My = y_grid->num_points - 1;
858 else My = y_grid->num_points;
859 if (zBC.lCode == PERIODIC) Mz = z_grid->num_points - 1;
860 else Mz = z_grid->num_points;
861
862 Nx = x_grid->num_points + 2;
863 Ny = y_grid->num_points + 2;
864 Nz = z_grid->num_points + 2;
865
866 // Allocate coefficients and solve
867 spline->x_stride = Ny*Nz;
868 spline->y_stride = Nz;
869#ifndef HAVE_SSE2
870 spline->coefs = (complex_float*)malloc (sizeof(complex_float)*Nx*Ny*Nz);
871#else
872 posix_memalign ((void**)&spline->coefs, 16, sizeof(complex_float)*Nx*Ny*Nz);
873#endif
874
875 // First, solve in the X-direction
876 for (int iy=0; iy<My; iy++)
877 for (int iz=0; iz<Mz; iz++) {
878 int doffset = iy*Mz+iz;
879 int coffset = iy*Nz+iz;
880 find_NUBcoefs_1d_c (spline->x_basis, xBC, data+doffset, My*Mz,
881 spline->coefs+coffset, Ny*Nz);
882 }
883
884 // Now, solve in the Y-direction
885 for (int ix=0; ix<Nx; ix++)
886 for (int iz=0; iz<Nz; iz++) {
887 int doffset = ix*Ny*Nz + iz;
888 int coffset = ix*Ny*Nz + iz;
889 find_NUBcoefs_1d_c (spline->y_basis, yBC, spline->coefs+doffset, Nz,
890 spline->coefs+coffset, Nz);
891 }
892
893 // Now, solve in the Z-direction
894 for (int ix=0; ix<Nx; ix++)
895 for (int iy=0; iy<Ny; iy++) {
896 int doffset = (ix*Ny+iy)*Nz;
897 int coffset = (ix*Ny+iy)*Nz;
898 find_NUBcoefs_1d_c (spline->z_basis, zBC, spline->coefs+doffset, 1,
899 spline->coefs+coffset, 1);
900 }
901 return spline;
902}
@ NU3D
NUBasis *restrict *restrict y_basis
NUBasis *restrict x_basis
complex_float *restrict coefs
NUBasis *restrict *restrict *restrict z_basis

References NUBspline_3d_c::coefs, create_NUBasis(), find_NUBcoefs_1d_c(), BCtype_c::lCode, NU3D, NUgrid::num_points, PERIODIC, posix_memalign(), SINGLE_COMPLEX, NUBspline_3d_c::sp_code, NUBspline_3d_c::t_code, NUBspline_3d_c::x_basis, NUBspline_3d_c::x_stride, NUBspline_3d_c::y_basis, NUBspline_3d_c::y_stride, and NUBspline_3d_c::z_basis.

◆ create_NUBspline_3d_d()

NUBspline_3d_d * create_NUBspline_3d_d ( NUgrid * x_grid,
NUgrid * y_grid,
NUgrid * z_grid,
BCtype_d xBC,
BCtype_d yBC,
BCtype_d zBC,
double * data )

Definition at line 668 of file nubspline_create.cpp.

670{
671 // First, create the spline structure
672 NUBspline_3d_d* spline = static_cast<NUBspline_3d_d*>(malloc(sizeof(NUBspline_3d_d)));
673 if (spline == NULL)
674 return spline;
675 spline->sp_code = NU3D;
676 spline->t_code = DOUBLE_REAL;
677
678 // Next, create the bases
679 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
680 spline->y_basis = create_NUBasis (y_grid, yBC.lCode==PERIODIC);
681 spline->z_basis = create_NUBasis (z_grid, zBC.lCode==PERIODIC);
682
683 // set but unused
684 //int Mx,
685 int My, Mz, Nx, Ny, Nz;
686// if (xBC.lCode == PERIODIC) Mx = x_grid->num_points - 1;
687// else Mx = x_grid->num_points;
688 if (yBC.lCode == PERIODIC) My = y_grid->num_points - 1;
689 else My = y_grid->num_points;
690 if (zBC.lCode == PERIODIC) Mz = z_grid->num_points - 1;
691 else Mz = z_grid->num_points;
692
693 Nx = x_grid->num_points + 2;
694 Ny = y_grid->num_points + 2;
695 Nz = z_grid->num_points + 2;
696
697 spline->x_stride = Ny*Nz;
698 spline->y_stride = Nz;
699#ifndef HAVE_SSE2
700 spline->coefs = (double*)malloc (sizeof(double)*Nx*Ny*Nz);
701#else
702 posix_memalign ((void**)&spline->coefs, 16, sizeof(double)*Nx*Ny*Nz);
703#endif
704
705 // First, solve in the X-direction
706 for (int iy=0; iy<My; iy++)
707 for (int iz=0; iz<Mz; iz++) {
708 int doffset = iy*Mz+iz;
709 int coffset = iy*Nz+iz;
710 find_NUBcoefs_1d_d (spline->x_basis, xBC, data+doffset, My*Mz,
711 spline->coefs+coffset, Ny*Nz);
712 }
713
714 // Now, solve in the Y-direction
715 for (int ix=0; ix<Nx; ix++)
716 for (int iz=0; iz<Nz; iz++) {
717 int doffset = ix*Ny*Nz + iz;
718 int coffset = ix*Ny*Nz + iz;
719 find_NUBcoefs_1d_d (spline->y_basis, yBC, spline->coefs+doffset, Nz,
720 spline->coefs+coffset, Nz);
721 }
722
723 // Now, solve in the Z-direction
724 for (int ix=0; ix<Nx; ix++)
725 for (int iy=0; iy<Ny; iy++) {
726 int doffset = (ix*Ny+iy)*Nz;
727 int coffset = (ix*Ny+iy)*Nz;
728 find_NUBcoefs_1d_d (spline->z_basis, zBC, spline->coefs+doffset, 1,
729 spline->coefs+coffset, 1);
730 }
731 return spline;
732}
NUBasis *restrict *restrict *restrict z_basis
NUBasis *restrict x_basis
NUBasis *restrict *restrict y_basis
double *restrict coefs

References NUBspline_3d_d::coefs, create_NUBasis(), DOUBLE_REAL, find_NUBcoefs_1d_d(), BCtype_d::lCode, NU3D, NUgrid::num_points, PERIODIC, posix_memalign(), NUBspline_3d_d::sp_code, NUBspline_3d_d::t_code, NUBspline_3d_d::x_basis, NUBspline_3d_d::x_stride, NUBspline_3d_d::y_basis, NUBspline_3d_d::y_stride, and NUBspline_3d_d::z_basis.

◆ create_NUBspline_3d_s()

NUBspline_3d_s * create_NUBspline_3d_s ( NUgrid * x_grid,
NUgrid * y_grid,
NUgrid * z_grid,
BCtype_s xBC,
BCtype_s yBC,
BCtype_s zBC,
float * data )

Definition at line 324 of file nubspline_create.cpp.

326{
327 // First, create the spline structure
328 NUBspline_3d_s* spline = static_cast<NUBspline_3d_s*>(malloc(sizeof(NUBspline_3d_s)));
329 if (spline == NULL)
330 return spline;
331 spline->sp_code = NU3D;
332 spline->t_code = SINGLE_REAL;
333
334 // Next, create the bases
335 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
336 spline->y_basis = create_NUBasis (y_grid, yBC.lCode==PERIODIC);
337 spline->z_basis = create_NUBasis (z_grid, zBC.lCode==PERIODIC);
338 // set but unused
339 // int Mx,
340 int My, Mz, Nx, Ny, Nz;
341// if (xBC.lCode == PERIODIC) Mx = x_grid->num_points - 1;
342// else Mx = x_grid->num_points;
343 if (yBC.lCode == PERIODIC) My = y_grid->num_points - 1;
344 else My = y_grid->num_points;
345 if (zBC.lCode == PERIODIC) Mz = z_grid->num_points - 1;
346 else Mz = z_grid->num_points;
347
348 Nx = x_grid->num_points + 2;
349 Ny = y_grid->num_points + 2;
350 Nz = z_grid->num_points + 2;
351
352 // Allocate coefficients and solve
353 spline->x_stride = Ny*Nz;
354 spline->y_stride = Nz;
355#ifndef HAVE_SSE2
356 spline->coefs = (float*)malloc (sizeof(float)*Nx*Ny*Nz);
357#else
358 posix_memalign ((void**)&spline->coefs, 16, sizeof(float)*Nx*Ny*Nz);
359#endif
360
361 // First, solve in the X-direction
362 for (int iy=0; iy<My; iy++)
363 for (int iz=0; iz<Mz; iz++) {
364 int doffset = iy*Mz+iz;
365 int coffset = iy*Nz+iz;
366 find_NUBcoefs_1d_s (spline->x_basis, xBC, data+doffset, My*Mz,
367 spline->coefs+coffset, Ny*Nz);
368 }
369
370 // Now, solve in the Y-direction
371 for (int ix=0; ix<Nx; ix++)
372 for (int iz=0; iz<Nz; iz++) {
373 int doffset = ix*Ny*Nz + iz;
374 int coffset = ix*Ny*Nz + iz;
375 find_NUBcoefs_1d_s (spline->y_basis, yBC, spline->coefs+doffset, Nz,
376 spline->coefs+coffset, Nz);
377 }
378
379 // Now, solve in the Z-direction
380 for (int ix=0; ix<Nx; ix++)
381 for (int iy=0; iy<Ny; iy++) {
382 int doffset = (ix*Ny+iy)*Nz;
383 int coffset = (ix*Ny+iy)*Nz;
384 find_NUBcoefs_1d_s (spline->z_basis, zBC, spline->coefs+doffset, 1,
385 spline->coefs+coffset, 1);
386 }
387 return spline;
388}
spline_code sp_code
NUBasis *restrict x_basis
NUBasis *restrict *restrict y_basis
float *restrict coefs
NUBasis *restrict *restrict *restrict z_basis

References NUBspline_3d_s::coefs, create_NUBasis(), find_NUBcoefs_1d_s(), BCtype_s::lCode, NU3D, NUgrid::num_points, PERIODIC, posix_memalign(), SINGLE_REAL, NUBspline_3d_s::sp_code, NUBspline_3d_s::t_code, NUBspline_3d_s::x_basis, NUBspline_3d_s::x_stride, NUBspline_3d_s::y_basis, NUBspline_3d_s::y_stride, and NUBspline_3d_s::z_basis.

◆ create_NUBspline_3d_z()

NUBspline_3d_z * create_NUBspline_3d_z ( NUgrid * x_grid,
NUgrid * y_grid,
NUgrid * z_grid,
BCtype_z xBC,
BCtype_z yBC,
BCtype_z zBC,
complex_double * data )

Definition at line 1008 of file nubspline_create.cpp.

1010{
1011 // First, create the spline structure
1012 NUBspline_3d_z* spline = static_cast<NUBspline_3d_z*>(malloc(sizeof(NUBspline_3d_z)));
1013 if (spline == NULL)
1014 return spline;
1015 spline->sp_code = NU3D;
1016 spline->t_code = DOUBLE_COMPLEX;
1017 spline->x_grid = x_grid;
1018 spline->y_grid = y_grid;
1019 spline->z_grid = z_grid;
1020
1021 // Next, create the bases
1022 spline->x_basis = create_NUBasis (x_grid, xBC.lCode==PERIODIC);
1023 spline->y_basis = create_NUBasis (y_grid, yBC.lCode==PERIODIC);
1024 spline->z_basis = create_NUBasis (z_grid, zBC.lCode==PERIODIC);
1025// int Mx,
1026 int My, Mz, Nx, Ny, Nz;
1027// if (xBC.lCode == PERIODIC) Mx = x_grid->num_points - 1;
1028// else Mx = x_grid->num_points;
1029 if (yBC.lCode == PERIODIC) My = y_grid->num_points - 1;
1030 else My = y_grid->num_points;
1031 if (zBC.lCode == PERIODIC) Mz = z_grid->num_points - 1;
1032 else Mz = z_grid->num_points;
1033
1034 Nx = x_grid->num_points + 2;
1035 Ny = y_grid->num_points + 2;
1036 Nz = z_grid->num_points + 2;
1037
1038 // Allocate coefficients and solve
1039 spline->x_stride = Ny*Nz;
1040 spline->y_stride = Nz;
1041#ifndef HAVE_SSE2
1042 spline->coefs = (complex_double*)malloc (sizeof(complex_double)*Nx*Ny*Nz);
1043#else
1044 posix_memalign ((void**)&spline->coefs, 16, sizeof(complex_double)*Nx*Ny*Nz);
1045#endif
1046
1047 // First, solve in the X-direction
1048 for (int iy=0; iy<My; iy++)
1049 for (int iz=0; iz<Mz; iz++) {
1050 int doffset = iy*Mz+iz;
1051 int coffset = iy*Nz+iz;
1052 find_NUBcoefs_1d_z (spline->x_basis, xBC, data+doffset, My*Mz,
1053 spline->coefs+coffset, Ny*Nz);
1054 /* for (int ix=0; ix<Nx; ix++) {
1055 complex_double z = spline->coefs[coffset+ix*spline->x_stride];
1056 if (isnan(creal(z)))
1057 fprintf (stderr, "NAN encountered in create_NUBspline_3d_z at real part of (%d,%d,%d)\n",
1058 ix,iy,iz);
1059 if (isnan(cimag(z)))
1060 fprintf (stderr, "NAN encountered in create_NUBspline_3d_z at imag part of (%d,%d,%d)\n",
1061 ix,iy,iz);
1062 } */
1063 }
1064
1065 // Now, solve in the Y-direction
1066 for (int ix=0; ix<Nx; ix++)
1067 for (int iz=0; iz<Nz; iz++) {
1068 int doffset = ix*Ny*Nz + iz;
1069 int coffset = ix*Ny*Nz + iz;
1070 find_NUBcoefs_1d_z (spline->y_basis, yBC, spline->coefs+doffset, Nz,
1071 spline->coefs+coffset, Nz);
1072 }
1073
1074 // Now, solve in the Z-direction
1075 for (int ix=0; ix<Nx; ix++)
1076 for (int iy=0; iy<Ny; iy++) {
1077 int doffset = (ix*Ny+iy)*Nz;
1078 int coffset = (ix*Ny+iy)*Nz;
1079 find_NUBcoefs_1d_z (spline->z_basis, zBC, spline->coefs+doffset, 1,
1080 spline->coefs+coffset, 1);
1081 }
1082 return spline;
1083}
NUgrid *restrict x_grid
complex_double *restrict coefs
NUgrid *restrict *restrict y_grid
NUBasis *restrict *restrict *restrict z_basis
NUgrid *restrict *restrict *restrict z_grid
NUBasis *restrict x_basis
NUBasis *restrict *restrict y_basis

References NUBspline_3d_z::coefs, create_NUBasis(), DOUBLE_COMPLEX, find_NUBcoefs_1d_z(), BCtype_z::lCode, NU3D, NUgrid::num_points, PERIODIC, posix_memalign(), NUBspline_3d_z::sp_code, NUBspline_3d_z::t_code, NUBspline_3d_z::x_basis, NUBspline_3d_z::x_grid, NUBspline_3d_z::x_stride, NUBspline_3d_z::y_basis, NUBspline_3d_z::y_grid, NUBspline_3d_z::y_stride, NUBspline_3d_z::z_basis, and NUBspline_3d_z::z_grid.