23#define _XOPEN_SOURCE 600
42 double *data, intptr_t dstride,
43 double *coefs, intptr_t cstride);
71 float *data, intptr_t dstride,
72 float *coefs, intptr_t cstride);
92 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_1d_s.\n");
97 spline->xBC = xBC; spline->x_grid = x_grid;
98 spline->num_splines = num_splines;
119 spline->x_stride = N;
121 spline->x_grid = x_grid;
122#ifndef HAVE_POSIX_MEMALIGN
123 spline->coefs = (
float*)malloc (
sizeof(
float)*Nx*N);
125 posix_memalign ((
void**)&spline->coefs, 64, (
sizeof(
float)*Nx*N));
130 if (!spline->coefs) {
131 fprintf (stderr,
"Out of memory allocating spline coefficient in create_multi_UBspline_1d_s.\n");
143 float *coefs = spline->
coefs + num;
157 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_2d_s.\n");
164 spline->num_splines = num_splines;
177 spline->x_grid = x_grid;
185 spline->y_grid = y_grid;
194 spline->x_stride = Ny*N;
195 spline->y_stride = N;
197#ifndef HAVE_POSIX_MEMALIGN
198 spline->coefs = (
float*)malloc (
sizeof(
float)*Nx*Ny*N);
201 sizeof(
float)*Nx*Ny*N);
206 if (!spline->coefs) {
207 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_2d_s.\n");
230 float *coefs = spline->
coefs + num;
233 for (
int iy=0; iy<My; iy++) {
234 intptr_t doffset = iy;
235 intptr_t coffset = iy*ys;
237 coefs+coffset, (intptr_t)Ny*ys);
241 for (
int ix=0; ix<Nx; ix++) {
242 intptr_t doffset = ix*Ny*ys;
243 intptr_t coffset = ix*Ny*ys;
245 coefs+coffset, (intptr_t)ys);
258 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_3d_s.\n");
266 spline->num_splines = num_splines;
268 int Mx = x_grid.
num;
int My = y_grid.
num;
int Mz = z_grid.
num;
277 spline->x_grid = x_grid;
285 spline->y_grid = y_grid;
293 spline->z_grid = z_grid;
301 spline->x_stride = Ny*Nz*N;
302 spline->y_stride = Nz*N;
303 spline->z_stride = N;
305#ifndef HAVE_POSIX_MEMALIGN
306 spline->coefs =
new float[Nx*Ny*Nz*N];
309 (
sizeof(
float)*Nx*Ny*Nz*N));
314 if (!spline->coefs) {
315 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_3d_s.\n");
343 float *coefs = spline->
coefs + num;
347 for (
int iy=0; iy<My; iy++)
348 for (
int iz=0; iz<Mz; iz++) {
349 intptr_t doffset = iy*Mz+iz;
350 intptr_t coffset = (iy*Nz+iz)*zs;
352 coefs+coffset, (intptr_t)Ny*Nz*zs);
356 for (
int ix=0; ix<Nx; ix++)
357 for (
int iz=0; iz<Nz; iz++) {
358 intptr_t doffset = (ix*Ny*Nz + iz)*zs;
359 intptr_t coffset = (ix*Ny*Nz + iz)*zs;
361 coefs+coffset, (intptr_t)Nz*zs);
365 for (
int ix=0; ix<Nx; ix++)
366 for (
int iy=0; iy<Ny; iy++) {
367 intptr_t doffset = ((ix*Ny+iy)*Nz)*zs;
368 intptr_t coffset = ((ix*Ny+iy)*Nz)*zs;
370 (intptr_t)zs, coefs+coffset, (intptr_t)zs);
393 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_1d_c.\n");
399 spline->num_splines = num_splines;
414 spline->x_grid = x_grid;
415 spline->x_stride = num_splines;
416#ifndef HAVE_POSIX_MEMALIGN
417 spline->coefs = (
complex_float*)malloc (2*
sizeof(
float)*N*num_splines);
419 posix_memalign ((
void**)&spline->coefs, 64, 2*
sizeof(
float)*N*num_splines);
424 if (!spline->coefs) {
425 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_1d_c.\n");
446 (
float*)data, (intptr_t)2, (
float*)coefs, (intptr_t)2*xs);
449 ((
float*)data)+1, (intptr_t)2, ((
float*)coefs+1), (intptr_t)2*xs);
461 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_2d_c.\n");
468 spline->num_splines = num_splines;
481 spline->x_grid = x_grid;
489 spline->y_grid = y_grid;
497 spline->x_stride = Ny*N;
498 spline->y_stride = N;
500#ifndef HAVE_POSIX_MEMALIGN
501 spline->coefs = (
complex_float*)malloc (2*
sizeof(
float)*Nx*Ny*N);
505 2*
sizeof(
float)*Nx*Ny*N);
512 if (!spline->coefs || !spline->lapl2) {
513 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_2d_c.\n");
539 BCtype_s xBC_r, xBC_i, yBC_r, yBC_i;
551 for (
int iy=0; iy<My; iy++) {
552 intptr_t doffset = (2*iy);
553 intptr_t coffset = (2*iy)*ys;
556 (
float*)coefs+coffset, (intptr_t)2*Ny*ys);
559 ((
float*)coefs)+coffset+1, (intptr_t)2*Ny*ys);
563 for (
int ix=0; ix<Nx; ix++) {
564 intptr_t doffset = (2*ix*Ny)*ys;
565 intptr_t coffset = (2*ix*Ny)*ys;
568 (intptr_t)2*ys, ((
float*)coefs)+coffset, (intptr_t)2*ys);
571 (intptr_t)2*ys, ((
float*)coefs)+coffset+1, (intptr_t)2*ys);
583 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_3d_c.\n");
591 spline->num_splines = num_splines;
594 int Mx = x_grid.
num;
int My = y_grid.
num;
int Mz = z_grid.
num;
603 spline->x_grid = x_grid;
611 spline->y_grid = y_grid;
619 spline->z_grid = z_grid;
621 int N = spline->num_splines;
627 spline->x_stride = Ny*Nz*N;
628 spline->y_stride = Nz*N;
629 spline->z_stride = N;
631#ifndef HAVE_POSIX_MEMALIGN
632 spline->coefs = (
complex_float*)malloc (2*
sizeof(
float)*Nx*Ny*Nz*N);
635 posix_memalign ((
void**)&spline->coefs, 64, 2*
sizeof(
float)*Nx*Ny*Nz*N);
641 if (!spline->coefs || !spline->lapl3) {
642 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_3d_c.\n");
671 BCtype_s xBC_r, xBC_i, yBC_r, yBC_i, zBC_r, zBC_i;
688 for (
int iy=0; iy<My; iy++)
689 for (
int iz=0; iz<Mz; iz++) {
690 intptr_t doffset = 2*(iy*Mz+iz);
691 intptr_t coffset = 2*(iy*Nz+iz)*zs;
694 ((
float*)data)+doffset, (intptr_t)2*My*Mz,
695 ((
float*)coefs)+coffset, (intptr_t)2*Ny*Nz*zs);
698 ((
float*)data)+doffset+1, (intptr_t)2*My*Mz,
699 ((
float*)coefs)+coffset+1, (intptr_t)2*Ny*Nz*zs);
703 for (
int ix=0; ix<Nx; ix++)
704 for (
int iz=0; iz<Nz; iz++) {
705 intptr_t doffset = 2*(ix*Ny*Nz + iz)*zs;
706 intptr_t coffset = 2*(ix*Ny*Nz + iz)*zs;
709 ((
float*)coefs)+doffset, (intptr_t)2*Nz*zs,
710 ((
float*)coefs)+coffset, (intptr_t)2*Nz*zs);
713 ((
float*)coefs)+doffset+1, (intptr_t)2*Nz*zs,
714 ((
float*)coefs)+coffset+1, (intptr_t)2*Nz*zs);
718 for (
int ix=0; ix<Nx; ix++)
719 for (
int iy=0; iy<Ny; iy++) {
720 intptr_t doffset = 2*((ix*Ny+iy)*Nz)*zs;
721 intptr_t coffset = 2*((ix*Ny+iy)*Nz)*zs;
724 ((
float*)coefs)+doffset, (intptr_t)2*zs,
725 ((
float*)coefs)+coffset, (intptr_t)2*zs);
728 ((
float*)coefs)+doffset+1, (intptr_t)2*zs,
729 ((
float*)coefs)+coffset+1, (intptr_t)2*zs);
762 double *data, intptr_t dstride,
763 double *coefs, intptr_t cstride);
771 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_1d_d.\n");
777 spline->num_splines = num_splines;
793 spline->x_grid = x_grid;
801 spline->x_stride = N;
803#ifndef HAVE_POSIX_MEMALIGN
804 spline->coefs = (
double*)malloc (
sizeof(
double)*Nx*N);
812 if (!spline->coefs) {
813 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_1d_d.\n");
823 double *coefs = spline->
coefs + num;
832 double *coefs = spline->
coefs + num;
845 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_2d_d.\n");
852 spline->num_splines = num_splines;
865 spline->x_grid = x_grid;
873 spline->y_grid = y_grid;
882 spline->x_stride = Ny*N;
883 spline->y_stride = N;
885#ifndef HAVE_POSIX_MEMALIGN
886 spline->coefs = (
double*)malloc (
sizeof(
double)*Nx*Ny*N);
888 posix_memalign ((
void**)&spline->coefs, 64, (
sizeof(
double)*Nx*Ny*N));
893 if (!spline->coefs) {
894 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_2d_d.\n");
907 double *coefs = spline->
coefs + num;
921 for (
int iy=0; iy<My; iy++) {
922 intptr_t doffset = iy;
923 intptr_t coffset = iy*ys;
925 data+doffset, (intptr_t)My,
926 coefs+coffset, (intptr_t)Ny*ys);
930 for (
int ix=0; ix<Nx; ix++) {
931 intptr_t doffset = ix*Ny*ys;
932 intptr_t coffset = ix*Ny*ys;
934 coefs+doffset, (intptr_t)ys,
935 coefs+coffset, (intptr_t)ys);
947#ifdef HAVE_POSIX_MEMALIGN
953 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_3d_d.\n");
961 spline->num_splines = num_splines;
964 int Mx = x_grid.
num;
int My = y_grid.
num;
int Mz = z_grid.
num;
973 spline->x_grid = x_grid;
981 spline->y_grid = y_grid;
989 spline->z_grid = z_grid;
993#if defined HAVE_SSE2 || defined HAVE_VSX
999 spline->x_stride = Ny*Nz*N;
1000 spline->y_stride = Nz*N;
1001 spline->z_stride = N;
1003#ifdef HAVE_POSIX_MEMALIGN
1004 posix_memalign ((
void**)&spline->coefs, 64, ((
size_t)
sizeof(
double)*Nx*Ny*Nz*N));
1006 spline->coefs =
new double[Nx*Ny*Nz*N];
1011 if (!spline->coefs) {
1012 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_3d_d.\n");
1040 double *coefs = spline->
coefs + num;
1044 for (
int iy=0; iy<My; iy++)
1045 for (
int iz=0; iz<Mz; iz++) {
1046 intptr_t doffset = iy*Mz+iz;
1047 intptr_t coffset = (iy*Nz+iz)*zs;
1049 data+doffset, (intptr_t)My*Mz,
1050 coefs+coffset, (intptr_t)Ny*Nz*zs);
1054 for (
int ix=0; ix<Nx; ix++)
1055 for (
int iz=0; iz<Nz; iz++) {
1056 intptr_t doffset = (ix*Ny*Nz + iz)*zs;
1057 intptr_t coffset = (ix*Ny*Nz + iz)*zs;
1059 coefs+doffset, (intptr_t)Nz*zs,
1060 coefs+coffset, (intptr_t)Nz*zs);
1064 for (
int ix=0; ix<Nx; ix++)
1065 for (
int iy=0; iy<Ny; iy++) {
1066 intptr_t doffset = (ix*Ny+iy)*Nz*zs;
1067 intptr_t coffset = (ix*Ny+iy)*Nz*zs;
1069 coefs+doffset, (intptr_t)zs,
1070 coefs+coffset, (intptr_t)zs);
1095 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_1d_z.\n");
1101 spline->num_splines = num_splines;
1104 int Mx = x_grid.
num;
1117 spline->x_grid = x_grid;
1118 spline->x_stride = num_splines;
1120#ifndef HAVE_POSIX_MEMALIGN
1121 spline->coefs = (
complex_double*)malloc (2*
sizeof(
double)*Nx*num_splines);
1123 posix_memalign ((
void**)&spline->coefs, 64, 2*
sizeof(
double)*Nx*num_splines);
1128 if (!spline->coefs) {
1129 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_1d_z.\n");
1158 (
double*)data, (intptr_t)2,
1159 ((
double*)coefs), (intptr_t)2*xs);
1162 ((
double*)data)+1, (intptr_t)2,
1163 ((
double*)coefs)+1, (intptr_t)2*xs);
1189 (
double*)data, (intptr_t)2,
1190 ((
double*)coefs), (intptr_t)2*xs);
1193 ((
double*)data)+1, (intptr_t)2,
1194 ((
double*)coefs)+1, (intptr_t)2*xs);
1205 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_2d_z.\n");
1212 spline->num_splines = num_splines;
1215 int Mx = x_grid.
num;
1216 int My = y_grid.
num;
1225 spline->x_grid = x_grid;
1233 spline->y_grid = y_grid;
1234 spline->x_stride = Ny*num_splines;
1235 spline->y_stride = num_splines;
1237#ifndef HAVE_POSIX_MEMALIGN
1238 spline->coefs = (
complex_double*)malloc (2*
sizeof(
double)*Nx*Ny*num_splines);
1239 spline->lapl2 = (
complex_double*)malloc (4*
sizeof(
double)*num_splines);
1241 posix_memalign ((
void**)&spline->coefs, 64, 2*
sizeof(
double)*Nx*Ny*num_splines);
1242 posix_memalign ((
void**)&spline->lapl2, 64, 4*
sizeof(
double)*num_splines);
1247 if (!spline->coefs || !spline->lapl2) {
1248 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_2d_z.\n");
1273 BCtype_d xBC_r, xBC_i, yBC_r, yBC_i;
1287 for (
int iy=0; iy<My; iy++) {
1288 intptr_t doffset = 2*iy;
1289 intptr_t coffset = 2*iy*ys;
1292 ((
double*)data+doffset), (intptr_t)2*My,
1293 (
double*)coefs+coffset, (intptr_t)2*Ny*ys);
1296 ((
double*)data)+doffset+1, (intptr_t)2*My,
1297 ((
double*)coefs)+coffset+1, (intptr_t)2*Ny*ys);
1301 for (
int ix=0; ix<Nx; ix++) {
1302 intptr_t doffset = 2*ix*Ny*ys;
1303 intptr_t coffset = 2*ix*Ny*ys;
1306 ((
double*)coefs)+doffset, (intptr_t)2*ys,
1307 (
double*)coefs+coffset, (intptr_t)2*ys);
1310 (
double*)coefs+doffset+1, (intptr_t)2*ys,
1311 ((
double*)coefs)+coffset+1, (intptr_t)2*ys);
1325 fprintf (stderr,
"Out of memory allocating spline in create_multi_UBspline_3d_z.\n");
1333 spline->num_splines = num_splines;
1336 int Mx = x_grid.
num;
int My = y_grid.
num;
int Mz = z_grid.
num;
1345 spline->x_grid = x_grid;
1353 spline->y_grid = y_grid;
1361 spline->z_grid = z_grid;
1363 int N = num_splines;
1369 spline->x_stride = (intptr_t)Ny*(intptr_t)Nz*N;
1370 spline->y_stride = Nz*N;
1371 spline->z_stride = N;
1373#ifndef HAVE_POSIX_MEMALIGN
1377 posix_memalign ((
void**)&spline->coefs, 64, (
size_t)2*
sizeof(
double)*Nx*Ny*Nz*N);
1384 if (!spline->coefs || !spline->lapl3) {
1385 fprintf (stderr,
"Out of memory allocating spline coefficients in create_multi_UBspline_3d_z.\n");
1414 BCtype_d xBC_r, xBC_i, yBC_r, yBC_i, zBC_r, zBC_i;
1434 for (
int iy=0; iy<My; iy++)
1435 for (
int iz=0; iz<Mz; iz++) {
1436 intptr_t doffset = 2*(iy*Mz+iz);
1437 intptr_t coffset = 2*(iy*Nz+iz)*zs;
1440 ((
double*)data)+doffset, (intptr_t)2*My*Mz,
1441 ((
double*)coefs)+coffset, (intptr_t)2*Ny*Nz*zs);
1444 ((
double*)data)+doffset+1, (intptr_t)2*My*Mz,
1445 ((
double*)coefs)+coffset+1, (intptr_t)2*Ny*Nz*zs);
1449 for (
int ix=0; ix<Nx; ix++)
1450 for (
int iz=0; iz<Nz; iz++) {
1451 intptr_t doffset = 2*(ix*Ny*Nz + iz)*zs;
1452 intptr_t coffset = 2*(ix*Ny*Nz + iz)*zs;
1455 ((
double*)coefs)+doffset, (intptr_t)2*Nz*zs,
1456 ((
double*)coefs)+coffset, (intptr_t)2*Nz*zs);
1459 ((
double*)coefs)+doffset+1, (intptr_t)2*Nz*zs,
1460 ((
double*)coefs)+coffset+1, (intptr_t)2*Nz*zs);
1464 for (
int ix=0; ix<Nx; ix++)
1465 for (
int iy=0; iy<Ny; iy++) {
1466 intptr_t doffset = 2*((ix*Ny+iy)*Nz)*zs;
1467 intptr_t coffset = 2*((ix*Ny+iy)*Nz)*zs;
1470 ((
double*)coefs)+doffset, (intptr_t)2*zs,
1471 ((
double*)coefs)+coffset, (intptr_t)2*zs);
1474 ((
double*)coefs)+doffset+1, (intptr_t)2*zs,
1475 ((
double*)coefs)+coffset+1, (intptr_t)2*zs);
1483 free(spline->
coefs);
complex float complex_float
complex double complex_double
void set_multi_UBspline_2d_z(multi_UBspline_2d_z *spline, int num, complex_double *data)
void find_coefs_1d_s(Ugrid grid, BCtype_s bc, float *data, intptr_t dstride, float *coefs, intptr_t cstride)
void set_multi_UBspline_3d_d(multi_UBspline_3d_d *spline, int num, double *data)
void set_multi_UBspline_1d_d(multi_UBspline_1d_d *spline, int num, double *data)
multi_UBspline_1d_c * create_multi_UBspline_1d_c(Ugrid x_grid, BCtype_c xBC, int num_splines)
multi_UBspline_2d_d * create_multi_UBspline_2d_d(Ugrid x_grid, Ugrid y_grid, BCtype_d xBC, BCtype_d yBC, int num_splines)
void set_multi_UBspline_2d_d(multi_UBspline_2d_d *spline, int num, double *data)
void set_multi_UBspline_1d_z_BC(multi_UBspline_1d_z *spline, int num, complex_double *data, BCtype_z xBC)
void set_multi_UBspline_2d_c(multi_UBspline_2d_c *spline, int num, complex_float *data)
void set_multi_UBspline_3d_s(multi_UBspline_3d_s *spline, int num, float *data)
multi_UBspline_3d_z * create_multi_UBspline_3d_z(Ugrid x_grid, Ugrid y_grid, Ugrid z_grid, BCtype_z xBC, BCtype_z yBC, BCtype_z zBC, int num_splines)
void solve_periodic_interp_1d_d(double bands[], double coefs[], int M, int cstride)
multi_UBspline_3d_d * create_multi_UBspline_3d_d(Ugrid x_grid, Ugrid y_grid, Ugrid z_grid, BCtype_d xBC, BCtype_d yBC, BCtype_d zBC, int num_splines)
void set_multi_UBspline_1d_c(multi_UBspline_1d_c *spline, int num, complex_float *data)
void solve_deriv_interp_1d_d(double bands[], double coefs[], int M, int cstride)
void solve_deriv_interp_1d_s(float bands[], float coefs[], int M, int cstride)
void set_multi_UBspline_3d_c(multi_UBspline_3d_c *spline, int num, complex_float *data)
multi_UBspline_2d_s * create_multi_UBspline_2d_s(Ugrid x_grid, Ugrid y_grid, BCtype_s xBC, BCtype_s yBC, int num_splines)
void set_multi_UBspline_3d_z(multi_UBspline_3d_z *spline, int num, complex_double *data)
multi_UBspline_2d_z * create_multi_UBspline_2d_z(Ugrid x_grid, Ugrid y_grid, BCtype_z xBC, BCtype_z yBC, int num_splines)
multi_UBspline_1d_z * create_multi_UBspline_1d_z(Ugrid x_grid, BCtype_z xBC, int num_splines)
void solve_periodic_interp_1d_s(float bands[], float coefs[], int M, int cstride)
void find_coefs_1d_d(Ugrid grid, BCtype_d bc, double *data, intptr_t dstride, double *coefs, intptr_t cstride)
multi_UBspline_1d_d * create_multi_UBspline_1d_d(Ugrid x_grid, BCtype_d xBC, int num_splines)
void set_multi_UBspline_2d_s(multi_UBspline_2d_s *spline, int num, float *data)
multi_UBspline_3d_c * create_multi_UBspline_3d_c(Ugrid x_grid, Ugrid y_grid, Ugrid z_grid, BCtype_c xBC, BCtype_c yBC, BCtype_c zBC, int num_splines)
multi_UBspline_2d_c * create_multi_UBspline_2d_c(Ugrid x_grid, Ugrid y_grid, BCtype_c xBC, BCtype_c yBC, int num_splines)
void set_multi_UBspline_1d_d_BC(multi_UBspline_1d_d *spline, int num, double *data, BCtype_d xBC)
multi_UBspline_1d_s * create_multi_UBspline_1d_s(Ugrid x_grid, BCtype_s xBC, int num_splines)
multi_UBspline_3d_s * create_multi_UBspline_3d_s(Ugrid x_grid, Ugrid y_grid, Ugrid z_grid, BCtype_s xBC, BCtype_s yBC, BCtype_s zBC, int num_splines)
void set_multi_UBspline_1d_z(multi_UBspline_1d_z *spline, int num, complex_double *data)
int posix_memalign(void **memptr, size_t alignment, size_t size)
void destroy_multi_UBspline(Bspline *spline)
void set_multi_UBspline_1d_s(multi_UBspline_1d_s *spline, int num, float *data)
void solve_antiperiodic_interp_1d_s(float bands[], float coefs[], int M, int cstride)
complex_float *restrict coefs
complex_double *restrict coefs
complex_float *restrict coefs
complex_double *restrict coefs
complex_float *restrict coefs
complex_double *restrict coefs