Krita Source Code Documentation
Loading...
Searching...
No Matches
multi_bspline_create.cpp File Reference
#include "multi_bspline_create.h"
#include <stdlib.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define __USE_XOPEN2K
 
#define _XOPEN_SOURCE   600
 

Functions

multi_UBspline_1d_ccreate_multi_UBspline_1d_c (Ugrid x_grid, BCtype_c xBC, int num_splines)
 
multi_UBspline_1d_dcreate_multi_UBspline_1d_d (Ugrid x_grid, BCtype_d xBC, int num_splines)
 
multi_UBspline_1d_screate_multi_UBspline_1d_s (Ugrid x_grid, BCtype_s xBC, int num_splines)
 
multi_UBspline_1d_zcreate_multi_UBspline_1d_z (Ugrid x_grid, BCtype_z xBC, int num_splines)
 
multi_UBspline_2d_ccreate_multi_UBspline_2d_c (Ugrid x_grid, Ugrid y_grid, BCtype_c xBC, BCtype_c yBC, int num_splines)
 
multi_UBspline_2d_dcreate_multi_UBspline_2d_d (Ugrid x_grid, Ugrid y_grid, BCtype_d xBC, BCtype_d yBC, int num_splines)
 
multi_UBspline_2d_screate_multi_UBspline_2d_s (Ugrid x_grid, Ugrid y_grid, BCtype_s xBC, BCtype_s yBC, int num_splines)
 
multi_UBspline_2d_zcreate_multi_UBspline_2d_z (Ugrid x_grid, Ugrid y_grid, BCtype_z xBC, BCtype_z yBC, int num_splines)
 
multi_UBspline_3d_ccreate_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_3d_dcreate_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)
 
multi_UBspline_3d_screate_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)
 
multi_UBspline_3d_zcreate_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 destroy_multi_UBspline (Bspline *spline)
 
void find_coefs_1d_d (Ugrid grid, BCtype_d bc, double *data, intptr_t dstride, double *coefs, intptr_t cstride)
 
void find_coefs_1d_s (Ugrid grid, BCtype_s bc, float *data, intptr_t dstride, float *coefs, intptr_t cstride)
 
void init_sse_data ()
 
int posix_memalign (void **memptr, size_t alignment, size_t size)
 
void set_multi_UBspline_1d_c (multi_UBspline_1d_c *spline, int num, complex_float *data)
 
void set_multi_UBspline_1d_d (multi_UBspline_1d_d *spline, int num, double *data)
 
void set_multi_UBspline_1d_d_BC (multi_UBspline_1d_d *spline, int num, double *data, BCtype_d xBC)
 
void set_multi_UBspline_1d_s (multi_UBspline_1d_s *spline, int num, float *data)
 
void set_multi_UBspline_1d_z (multi_UBspline_1d_z *spline, int num, complex_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_2d_d (multi_UBspline_2d_d *spline, int num, double *data)
 
void set_multi_UBspline_2d_s (multi_UBspline_2d_s *spline, int num, float *data)
 
void set_multi_UBspline_2d_z (multi_UBspline_2d_z *spline, int num, complex_double *data)
 
void set_multi_UBspline_3d_c (multi_UBspline_3d_c *spline, int num, complex_float *data)
 
void set_multi_UBspline_3d_d (multi_UBspline_3d_d *spline, int num, double *data)
 
void set_multi_UBspline_3d_s (multi_UBspline_3d_s *spline, int num, float *data)
 
void set_multi_UBspline_3d_z (multi_UBspline_3d_z *spline, int num, complex_double *data)
 
void solve_antiperiodic_interp_1d_s (float bands[], float coefs[], int M, int cstride)
 
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 solve_periodic_interp_1d_d (double bands[], double coefs[], int M, int cstride)
 
void solve_periodic_interp_1d_s (float bands[], float coefs[], int M, int cstride)
 

Macro Definition Documentation

◆ __USE_XOPEN2K

#define __USE_XOPEN2K

Definition at line 26 of file multi_bspline_create.cpp.

◆ _XOPEN_SOURCE

#define _XOPEN_SOURCE   600

Definition at line 23 of file multi_bspline_create.cpp.

Function Documentation

◆ create_multi_UBspline_1d_c()

multi_UBspline_1d_c * create_multi_UBspline_1d_c ( Ugrid x_grid,
BCtype_c xBC,
int num_splines )

Definition at line 388 of file multi_bspline_create.cpp.

389{
390 // Create new spline
391 multi_UBspline_1d_c* restrict spline = static_cast<multi_UBspline_1d_c*>(malloc(sizeof(multi_UBspline_1d_c)));
392 if (!spline) {
393 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_1d_c.\n");
394 abort();
395 }
396 spline->spcode = MULTI_U1D;
397 spline->tcode = SINGLE_COMPLEX;
398 spline->xBC = xBC;
399 spline->num_splines = num_splines;
400 // Setup internal variables
401 int M = x_grid.num;
402 int N;
403
404 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC) {
405 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num);
406 N = M+3;
407 }
408 else {
409 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num-1);
410 N = M+2;
411 }
412
413 x_grid.delta_inv = 1.0/x_grid.delta;
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);
418#else
419 posix_memalign ((void**)&spline->coefs, 64, 2*sizeof(float)*N*num_splines);
420#endif
421#ifdef HAVE_SSE
422 init_sse_data();
423#endif
424 if (!spline->coefs) {
425 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_1d_c.\n");
426 abort();
427 }
428
429 return spline;
430}
complex float complex_float
@ SINGLE_COMPLEX
@ ANTIPERIODIC
@ PERIODIC
@ MULTI_U1D
#define restrict
void init_sse_data()
int posix_memalign(void **memptr, size_t alignment, size_t size)
bc_code lCode
double end
double delta
double start
double delta_inv
int num

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, Ugrid::end, init_sse_data(), BCtype_c::lCode, MULTI_U1D, Ugrid::num, PERIODIC, posix_memalign(), restrict, SINGLE_COMPLEX, and Ugrid::start.

◆ create_multi_UBspline_1d_d()

multi_UBspline_1d_d * create_multi_UBspline_1d_d ( Ugrid x_grid,
BCtype_d xBC,
int num_splines )

Definition at line 766 of file multi_bspline_create.cpp.

767{
768 // Create new spline
769 multi_UBspline_1d_d* restrict spline = static_cast<multi_UBspline_1d_d*>(malloc(sizeof(multi_UBspline_1d_d)));
770 if (!spline) {
771 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_1d_d.\n");
772 abort();
773 }
774 spline->spcode = MULTI_U1D;
775 spline->tcode = DOUBLE_REAL;
776 spline->xBC = xBC;
777 spline->num_splines = num_splines;
778
779 // Setup internal variables
780 int Mx = x_grid.num;
781 int Nx;
782
783 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC) {
784 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num);
785 Nx = Mx+3;
786 }
787 else {
788 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num-1);
789 Nx = Mx+2;
790 }
791
792 x_grid.delta_inv = 1.0/x_grid.delta;
793 spline->x_grid = x_grid;
794
795 int N = num_splines;
796#ifdef HAVE_SSE2
797 // We must pad to keep data aligned for SSE operations
798 if (N & 1)
799 N++;
800#endif
801 spline->x_stride = N;
802
803#ifndef HAVE_POSIX_MEMALIGN
804 spline->coefs = (double*)malloc (sizeof(double)*Nx*N);
805
806#else
807 posix_memalign ((void**)&spline->coefs, 64, sizeof(double)*Nx*N);
808#endif
809#ifdef HAVE_SSE2
811#endif
812 if (!spline->coefs) {
813 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_1d_d.\n");
814 abort();
815 }
816
817 return spline;
818}
@ DOUBLE_REAL
bc_code lCode

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, DOUBLE_REAL, Ugrid::end, init_sse_data(), BCtype_d::lCode, MULTI_U1D, Ugrid::num, PERIODIC, posix_memalign(), restrict, and Ugrid::start.

◆ create_multi_UBspline_1d_s()

multi_UBspline_1d_s * create_multi_UBspline_1d_s ( Ugrid x_grid,
BCtype_s xBC,
int num_splines )

Definition at line 87 of file multi_bspline_create.cpp.

88{
89 // Create new spline
90 multi_UBspline_1d_s* restrict spline = static_cast<multi_UBspline_1d_s*>(malloc(sizeof(multi_UBspline_1d_s)));
91 if (!spline) {
92 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_1d_s.\n");
93 abort();
94 }
95 spline->spcode = MULTI_U1D;
96 spline->tcode = SINGLE_REAL;
97 spline->xBC = xBC; spline->x_grid = x_grid;
98 spline->num_splines = num_splines;
99
100 // Setup internal variables
101 int Mx = x_grid.num;
102 int Nx;
103
104 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC) {
105 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num);
106 Nx = Mx+3;
107 }
108 else {
109 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num-1);
110 Nx = Mx+2;
111 }
112
113 int N = num_splines;
114#ifdef HAVE_SSE
115 if (N % 4)
116 N += 4 - (N % 4);
117#endif
118
119 spline->x_stride = N;
120 x_grid.delta_inv = 1.0/x_grid.delta;
121 spline->x_grid = x_grid;
122#ifndef HAVE_POSIX_MEMALIGN
123 spline->coefs = (float*)malloc (sizeof(float)*Nx*N);
124#else
125 posix_memalign ((void**)&spline->coefs, 64, (sizeof(float)*Nx*N));
126#endif
127#ifdef HAVE_SSE
128 init_sse_data();
129#endif
130 if (!spline->coefs) {
131 fprintf (stderr, "Out of memory allocating spline coefficient in create_multi_UBspline_1d_s.\n");
132 abort();
133 }
134
135
136 return spline;
137}
@ SINGLE_REAL
bc_code lCode

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, Ugrid::end, init_sse_data(), BCtype_s::lCode, MULTI_U1D, Ugrid::num, PERIODIC, posix_memalign(), restrict, SINGLE_REAL, and Ugrid::start.

◆ create_multi_UBspline_1d_z()

multi_UBspline_1d_z * create_multi_UBspline_1d_z ( Ugrid x_grid,
BCtype_z xBC,
int num_splines )

Definition at line 1090 of file multi_bspline_create.cpp.

1091{
1092 // Create new spline
1093 multi_UBspline_1d_z* restrict spline = static_cast<multi_UBspline_1d_z*>(malloc(sizeof(multi_UBspline_1d_z)));
1094 if (!spline) {
1095 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_1d_z.\n");
1096 abort();
1097 }
1098 spline->spcode = MULTI_U1D;
1099 spline->tcode = DOUBLE_COMPLEX;
1100 spline->xBC = xBC;
1101 spline->num_splines = num_splines;
1102
1103 // Setup internal variables
1104 int Mx = x_grid.num;
1105 int Nx;
1106
1107 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC) {
1108 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num);
1109 Nx = Mx+3;
1110 }
1111 else {
1112 x_grid.delta = (x_grid.end-x_grid.start)/(double)(x_grid.num-1);
1113 Nx = Mx+2;
1114 }
1115
1116 x_grid.delta_inv = 1.0/x_grid.delta;
1117 spline->x_grid = x_grid;
1118 spline->x_stride = num_splines;
1119
1120#ifndef HAVE_POSIX_MEMALIGN
1121 spline->coefs = (complex_double*)malloc (2*sizeof(double)*Nx*num_splines);
1122#else
1123 posix_memalign ((void**)&spline->coefs, 64, 2*sizeof(double)*Nx*num_splines);
1124#endif
1125#ifdef HAVE_SSE2
1126 init_sse_data();
1127#endif
1128 if (!spline->coefs) {
1129 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_1d_z.\n");
1130 abort();
1131 }
1132
1133 return spline;
1134}
@ DOUBLE_COMPLEX
complex double complex_double
bc_code lCode

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, DOUBLE_COMPLEX, Ugrid::end, init_sse_data(), BCtype_z::lCode, MULTI_U1D, Ugrid::num, PERIODIC, posix_memalign(), restrict, and Ugrid::start.

◆ create_multi_UBspline_2d_c()

multi_UBspline_2d_c * create_multi_UBspline_2d_c ( Ugrid x_grid,
Ugrid y_grid,
BCtype_c xBC,
BCtype_c yBC,
int num_splines )

Definition at line 455 of file multi_bspline_create.cpp.

457{
458 // Create new spline
459 multi_UBspline_2d_c* restrict spline = static_cast<multi_UBspline_2d_c*>(malloc(sizeof(multi_UBspline_2d_c)));
460 if (!spline) {
461 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_2d_c.\n");
462 abort();
463 }
464 spline->spcode = MULTI_U2D;
465 spline->tcode = SINGLE_COMPLEX;
466 spline->xBC = xBC;
467 spline->yBC = yBC;
468 spline->num_splines = num_splines;
469
470 // Setup internal variables
471 int Mx = x_grid.num;
472 int My = y_grid.num;
473 int Nx, Ny;
474
475 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
476 Nx = Mx+3;
477 else
478 Nx = Mx+2;
479 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
480 x_grid.delta_inv = 1.0/x_grid.delta;
481 spline->x_grid = x_grid;
482
483 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
484 Ny = My+3;
485 else
486 Ny = My+2;
487 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
488 y_grid.delta_inv = 1.0/y_grid.delta;
489 spline->y_grid = y_grid;
490
491 int N = num_splines;
492#ifdef HAVE_SSE
493 if (N % 2)
494 N++;
495#endif
496
497 spline->x_stride = Ny*N;
498 spline->y_stride = N;
499
500#ifndef HAVE_POSIX_MEMALIGN
501 spline->coefs = (complex_float*)malloc (2*sizeof(float)*Nx*Ny*N);
502 spline->lapl2 = (complex_float*)malloc (4*sizeof(float)*N);
503#else
504 posix_memalign ((void**)&spline->coefs, 64,
505 2*sizeof(float)*Nx*Ny*N);
506 posix_memalign ((void**)&spline->lapl2, 64,
507 4*sizeof(float)*N);
508#endif
509#ifdef HAVE_SSE
511#endif
512 if (!spline->coefs || !spline->lapl2) {
513 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_2d_c.\n");
514 abort();
515 }
516 return spline;
517}
@ MULTI_U2D

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, Ugrid::end, init_sse_data(), BCtype_c::lCode, MULTI_U2D, Ugrid::num, PERIODIC, posix_memalign(), restrict, SINGLE_COMPLEX, and Ugrid::start.

◆ create_multi_UBspline_2d_d()

multi_UBspline_2d_d * create_multi_UBspline_2d_d ( Ugrid x_grid,
Ugrid y_grid,
BCtype_d xBC,
BCtype_d yBC,
int num_splines )

Definition at line 839 of file multi_bspline_create.cpp.

841{
842 // Create new spline
843 multi_UBspline_2d_d* restrict spline = static_cast<multi_UBspline_2d_d*>(malloc(sizeof(multi_UBspline_2d_d)));
844 if (!spline) {
845 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_2d_d.\n");
846 abort();
847 }
848 spline->spcode = MULTI_U2D;
849 spline->tcode = DOUBLE_REAL;
850 spline->xBC = xBC;
851 spline->yBC = yBC;
852 spline->num_splines = num_splines;
853
854 // Setup internal variables
855 int Mx = x_grid.num;
856 int My = y_grid.num;
857 int Nx, Ny;
858
859 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
860 Nx = Mx+3;
861 else
862 Nx = Mx+2;
863 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
864 x_grid.delta_inv = 1.0/x_grid.delta;
865 spline->x_grid = x_grid;
866
867 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
868 Ny = My+3;
869 else
870 Ny = My+2;
871 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
872 y_grid.delta_inv = 1.0/y_grid.delta;
873 spline->y_grid = y_grid;
874
875 int N = num_splines;
876
877#ifdef HAVE_SSE2
878 // We must pad to keep data align for SSE operations
879 if (num_splines & 1)
880 N++;
881#endif
882 spline->x_stride = Ny*N;
883 spline->y_stride = N;
884
885#ifndef HAVE_POSIX_MEMALIGN
886 spline->coefs = (double*)malloc (sizeof(double)*Nx*Ny*N);
887#else
888 posix_memalign ((void**)&spline->coefs, 64, (sizeof(double)*Nx*Ny*N));
889#endif
890#ifdef HAVE_SSE2
892#endif
893 if (!spline->coefs) {
894 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_2d_d.\n");
895 abort();
896 }
897
898 return spline;
899}

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, DOUBLE_REAL, Ugrid::end, init_sse_data(), BCtype_d::lCode, MULTI_U2D, Ugrid::num, PERIODIC, posix_memalign(), restrict, and Ugrid::start.

◆ create_multi_UBspline_2d_s()

multi_UBspline_2d_s * create_multi_UBspline_2d_s ( Ugrid x_grid,
Ugrid y_grid,
BCtype_s xBC,
BCtype_s yBC,
int num_splines )

Definition at line 151 of file multi_bspline_create.cpp.

153{
154 // Create new spline
155 multi_UBspline_2d_s* restrict spline = static_cast<multi_UBspline_2d_s*>(malloc(sizeof(multi_UBspline_2d_s)));
156 if (!spline) {
157 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_2d_s.\n");
158 abort();
159 }
160 spline->spcode = MULTI_U2D;
161 spline->tcode = SINGLE_REAL;
162 spline->xBC = xBC;
163 spline->yBC = yBC;
164 spline->num_splines = num_splines;
165 // Setup internal variables
166 int Mx = x_grid.num;
167 int My = y_grid.num;
168 int Nx, Ny;
169
170 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
171 Nx = Mx+3;
172 else
173 Nx = Mx+2;
174 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
175
176 x_grid.delta_inv = 1.0/x_grid.delta;
177 spline->x_grid = x_grid;
178
179 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
180 Ny = My+3;
181 else
182 Ny = My+2;
183 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
184 y_grid.delta_inv = 1.0/y_grid.delta;
185 spline->y_grid = y_grid;
186
187 int N = num_splines;
188#ifdef HAVE_SSE
189 if (N % 4)
190 N += 4 - (N % 4);
191#endif
192
193
194 spline->x_stride = Ny*N;
195 spline->y_stride = N;
196
197#ifndef HAVE_POSIX_MEMALIGN
198 spline->coefs = (float*)malloc (sizeof(float)*Nx*Ny*N);
199#else
200 posix_memalign ((void**)&spline->coefs, 64,
201 sizeof(float)*Nx*Ny*N);
202#endif
203#ifdef HAVE_SSE
205#endif
206 if (!spline->coefs) {
207 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_2d_s.\n");
208 abort();
209 }
210
211 return spline;
212}

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, Ugrid::end, init_sse_data(), BCtype_s::lCode, MULTI_U2D, Ugrid::num, PERIODIC, posix_memalign(), restrict, SINGLE_REAL, and Ugrid::start.

◆ create_multi_UBspline_2d_z()

multi_UBspline_2d_z * create_multi_UBspline_2d_z ( Ugrid x_grid,
Ugrid y_grid,
BCtype_z xBC,
BCtype_z yBC,
int num_splines )

Definition at line 1199 of file multi_bspline_create.cpp.

1201{
1202 // Create new spline
1203 multi_UBspline_2d_z* restrict spline = static_cast<multi_UBspline_2d_z*>(malloc(sizeof(multi_UBspline_2d_z)));
1204 if (!spline) {
1205 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_2d_z.\n");
1206 abort();
1207 }
1208 spline->spcode = MULTI_U2D;
1209 spline->tcode = DOUBLE_COMPLEX;
1210 spline->xBC = xBC;
1211 spline->yBC = yBC;
1212 spline->num_splines = num_splines;
1213
1214 // Setup internal variables
1215 int Mx = x_grid.num;
1216 int My = y_grid.num;
1217 int Nx, Ny;
1218
1219 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
1220 Nx = Mx+3;
1221 else
1222 Nx = Mx+2;
1223 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
1224 x_grid.delta_inv = 1.0/x_grid.delta;
1225 spline->x_grid = x_grid;
1226
1227 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
1228 Ny = My+3;
1229 else
1230 Ny = My+2;
1231 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
1232 y_grid.delta_inv = 1.0/y_grid.delta;
1233 spline->y_grid = y_grid;
1234 spline->x_stride = Ny*num_splines;
1235 spline->y_stride = num_splines;
1236
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);
1240#else
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);
1243#endif
1244#ifdef HAVE_SSE2
1245 init_sse_data();
1246#endif
1247 if (!spline->coefs || !spline->lapl2) {
1248 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_2d_z.\n");
1249 abort();
1250 }
1251
1252 return spline;
1253}

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, DOUBLE_COMPLEX, Ugrid::end, init_sse_data(), BCtype_z::lCode, MULTI_U2D, Ugrid::num, PERIODIC, posix_memalign(), restrict, and Ugrid::start.

◆ create_multi_UBspline_3d_c()

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 )

Definition at line 576 of file multi_bspline_create.cpp.

579{
580 // Create new spline
581 multi_UBspline_3d_c* restrict spline = static_cast<multi_UBspline_3d_c*>(malloc(sizeof(multi_UBspline_3d_c)));
582 if (!spline) {
583 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_3d_c.\n");
584 abort();
585 }
586 spline->spcode = MULTI_U3D;
587 spline->tcode = SINGLE_COMPLEX;
588 spline->xBC = xBC;
589 spline->yBC = yBC;
590 spline->zBC = zBC;
591 spline->num_splines = num_splines;
592
593 // Setup internal variables
594 int Mx = x_grid.num; int My = y_grid.num; int Mz = z_grid.num;
595 int Nx, Ny, Nz;
596
597 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
598 Nx = Mx+3;
599 else
600 Nx = Mx+2;
601 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
602 x_grid.delta_inv = 1.0/x_grid.delta;
603 spline->x_grid = x_grid;
604
605 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
606 Ny = My+3;
607 else
608 Ny = My+2;
609 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
610 y_grid.delta_inv = 1.0/y_grid.delta;
611 spline->y_grid = y_grid;
612
613 if (zBC.lCode == PERIODIC || zBC.lCode == ANTIPERIODIC)
614 Nz = Mz+3;
615 else
616 Nz = Mz+2;
617 z_grid.delta = (z_grid.end - z_grid.start)/(double)(Nz-3);
618 z_grid.delta_inv = 1.0/z_grid.delta;
619 spline->z_grid = z_grid;
620
621 int N = spline->num_splines;
622#ifdef HAVE_SSE
623 if (N % 2)
624 N++;
625#endif
626
627 spline->x_stride = Ny*Nz*N;
628 spline->y_stride = Nz*N;
629 spline->z_stride = N;
630
631#ifndef HAVE_POSIX_MEMALIGN
632 spline->coefs = (complex_float*)malloc (2*sizeof(float)*Nx*Ny*Nz*N);
633 spline->lapl3 = (complex_float*)malloc (6*sizeof(float)*N);
634#else
635 posix_memalign ((void**)&spline->coefs, 64, 2*sizeof(float)*Nx*Ny*Nz*N);
636 posix_memalign ((void**)&spline->lapl3, 64, 6*sizeof(float)*N);
637#endif
638#ifdef HAVE_SSE
640#endif
641 if (!spline->coefs || !spline->lapl3) {
642 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_3d_c.\n");
643 abort();
644 }
645
646 return spline;
647}
@ MULTI_U3D

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, Ugrid::end, init_sse_data(), BCtype_c::lCode, MULTI_U3D, Ugrid::num, PERIODIC, posix_memalign(), restrict, SINGLE_COMPLEX, and Ugrid::start.

◆ create_multi_UBspline_3d_d()

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 )

Definition at line 941 of file multi_bspline_create.cpp.

944{
945 // Create new spline
947#ifdef HAVE_POSIX_MEMALIGN
948 posix_memalign ((void**)&spline, 64, (size_t)sizeof(multi_UBspline_3d_d));
949#else
950 spline = static_cast<multi_UBspline_3d_d*>(malloc(sizeof(multi_UBspline_3d_d)));
951#endif
952 if (!spline) {
953 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_3d_d.\n");
954 abort();
955 }
956 spline->spcode = MULTI_U3D;
957 spline->tcode = DOUBLE_REAL;
958 spline->xBC = xBC;
959 spline->yBC = yBC;
960 spline->zBC = zBC;
961 spline->num_splines = num_splines;
962
963 // Setup internal variables
964 int Mx = x_grid.num; int My = y_grid.num; int Mz = z_grid.num;
965 int Nx, Ny, Nz;
966
967 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
968 Nx = Mx+3;
969 else
970 Nx = Mx+2;
971 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
972 x_grid.delta_inv = 1.0/x_grid.delta;
973 spline->x_grid = x_grid;
974
975 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
976 Ny = My+3;
977 else
978 Ny = My+2;
979 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
980 y_grid.delta_inv = 1.0/y_grid.delta;
981 spline->y_grid = y_grid;
982
983 if (zBC.lCode == PERIODIC || zBC.lCode == ANTIPERIODIC)
984 Nz = Mz+3;
985 else
986 Nz = Mz+2;
987 z_grid.delta = (z_grid.end - z_grid.start)/(double)(Nz-3);
988 z_grid.delta_inv = 1.0/z_grid.delta;
989 spline->z_grid = z_grid;
990
991
992 int N = num_splines;
993#if defined HAVE_SSE2 || defined HAVE_VSX
994 // We must pad to keep data align for SSE operations
995 if (N & 1)
996 N++;
997#endif
998
999 spline->x_stride = Ny*Nz*N;
1000 spline->y_stride = Nz*N;
1001 spline->z_stride = N;
1002
1003#ifdef HAVE_POSIX_MEMALIGN
1004 posix_memalign ((void**)&spline->coefs, 64, ((size_t)sizeof(double)*Nx*Ny*Nz*N));
1005#else
1006 spline->coefs = new double[Nx*Ny*Nz*N];
1007#endif
1008#ifdef HAVE_SSE2
1009 init_sse_data();
1010#endif
1011 if (!spline->coefs) {
1012 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_3d_d.\n");
1013 abort();
1014 }
1015
1016 return spline;
1017}

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, DOUBLE_REAL, Ugrid::end, init_sse_data(), BCtype_d::lCode, MULTI_U3D, Ugrid::num, PERIODIC, posix_memalign(), restrict, and Ugrid::start.

◆ create_multi_UBspline_3d_s()

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 )

Definition at line 251 of file multi_bspline_create.cpp.

254{
255 // Create new spline
256 multi_UBspline_3d_s* restrict spline = static_cast<multi_UBspline_3d_s*>(malloc(sizeof(multi_UBspline_3d_s)));
257 if (!spline) {
258 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_3d_s.\n");
259 abort();
260 }
261 spline->spcode = MULTI_U3D;
262 spline->tcode = SINGLE_REAL;
263 spline->xBC = xBC;
264 spline->yBC = yBC;
265 spline->zBC = zBC;
266 spline->num_splines = num_splines;
267 // Setup internal variables
268 int Mx = x_grid.num; int My = y_grid.num; int Mz = z_grid.num;
269 int Nx, Ny, Nz;
270
271 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
272 Nx = Mx+3;
273 else
274 Nx = Mx+2;
275 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
276 x_grid.delta_inv = 1.0/x_grid.delta;
277 spline->x_grid = x_grid;
278
279 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
280 Ny = My+3;
281 else
282 Ny = My+2;
283 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
284 y_grid.delta_inv = 1.0/y_grid.delta;
285 spline->y_grid = y_grid;
286
287 if (zBC.lCode == PERIODIC || zBC.lCode == ANTIPERIODIC)
288 Nz = Mz+3;
289 else
290 Nz = Mz+2;
291 z_grid.delta = (z_grid.end - z_grid.start)/(double)(Nz-3);
292 z_grid.delta_inv = 1.0/z_grid.delta;
293 spline->z_grid = z_grid;
294
295 int N = num_splines;
296#ifdef HAVE_SSE
297 if (N % 4)
298 N += 4 - (N % 4);
299#endif
300
301 spline->x_stride = Ny*Nz*N;
302 spline->y_stride = Nz*N;
303 spline->z_stride = N;
304
305#ifndef HAVE_POSIX_MEMALIGN
306 spline->coefs = new float[Nx*Ny*Nz*N];
307#else
308 posix_memalign ((void**)&spline->coefs, 64,
309 (sizeof(float)*Nx*Ny*Nz*N));
310#endif
311#ifdef HAVE_SSE
313#endif
314 if (!spline->coefs) {
315 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_3d_s.\n");
316 abort();
317 }
318
319 return spline;
320}

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, Ugrid::end, init_sse_data(), BCtype_s::lCode, MULTI_U3D, Ugrid::num, PERIODIC, posix_memalign(), restrict, SINGLE_REAL, and Ugrid::start.

◆ create_multi_UBspline_3d_z()

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 )

Definition at line 1318 of file multi_bspline_create.cpp.

1321{
1322 // Create new spline
1323 multi_UBspline_3d_z* restrict spline = static_cast<multi_UBspline_3d_z*>(malloc(sizeof(multi_UBspline_3d_z)));
1324 if (!spline) {
1325 fprintf (stderr, "Out of memory allocating spline in create_multi_UBspline_3d_z.\n");
1326 abort();
1327 }
1328 spline->spcode = MULTI_U3D;
1329 spline->tcode = DOUBLE_COMPLEX;
1330 spline->xBC = xBC;
1331 spline->yBC = yBC;
1332 spline->zBC = zBC;
1333 spline->num_splines = num_splines;
1334
1335 // Setup internal variables
1336 int Mx = x_grid.num; int My = y_grid.num; int Mz = z_grid.num;
1337 int Nx, Ny, Nz;
1338
1339 if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
1340 Nx = Mx+3;
1341 else
1342 Nx = Mx+2;
1343 x_grid.delta = (x_grid.end - x_grid.start)/(double)(Nx-3);
1344 x_grid.delta_inv = 1.0/x_grid.delta;
1345 spline->x_grid = x_grid;
1346
1347 if (yBC.lCode == PERIODIC || yBC.lCode == ANTIPERIODIC)
1348 Ny = My+3;
1349 else
1350 Ny = My+2;
1351 y_grid.delta = (y_grid.end - y_grid.start)/(double)(Ny-3);
1352 y_grid.delta_inv = 1.0/y_grid.delta;
1353 spline->y_grid = y_grid;
1354
1355 if (zBC.lCode == PERIODIC || zBC.lCode == ANTIPERIODIC)
1356 Nz = Mz+3;
1357 else
1358 Nz = Mz+2;
1359 z_grid.delta = (z_grid.end - z_grid.start)/(double)(Nz-3);
1360 z_grid.delta_inv = 1.0/z_grid.delta;
1361 spline->z_grid = z_grid;
1362
1363 int N = num_splines;
1364#ifdef HAVE_SSE2
1365 if (N & 3)
1366 N += 4-(N & 3);
1367#endif
1368
1369 spline->x_stride = (intptr_t)Ny*(intptr_t)Nz*N;
1370 spline->y_stride = Nz*N;
1371 spline->z_stride = N;
1372
1373#ifndef HAVE_POSIX_MEMALIGN
1374 spline->coefs = new complex_double[Nx*Ny*Nz*N];
1375 spline->lapl3 = new complex_double[3*N];
1376#else
1377 posix_memalign ((void**)&spline->coefs, 64, (size_t)2*sizeof(double)*Nx*Ny*Nz*N);
1378 posix_memalign ((void**)&spline->lapl3, 64, 6*sizeof(double)*N);
1379#endif
1380
1381#ifdef HAVE_SSE2
1382 init_sse_data();
1383#endif
1384 if (!spline->coefs || !spline->lapl3) {
1385 fprintf (stderr, "Out of memory allocating spline coefficients in create_multi_UBspline_3d_z.\n");
1386 abort();
1387 }
1388
1389 return spline;
1390}

References ANTIPERIODIC, Ugrid::delta, Ugrid::delta_inv, DOUBLE_COMPLEX, Ugrid::end, init_sse_data(), BCtype_z::lCode, MULTI_U3D, Ugrid::num, PERIODIC, posix_memalign(), restrict, and Ugrid::start.

◆ destroy_multi_UBspline()

void destroy_multi_UBspline ( Bspline * spline)

Definition at line 1481 of file multi_bspline_create.cpp.

1482{
1483 free(spline->coefs);
1484 free(spline);
1485}
void *restrict coefs

References Bspline::coefs.

◆ find_coefs_1d_d()

void find_coefs_1d_d ( Ugrid grid,
BCtype_d bc,
double * data,
intptr_t dstride,
double * coefs,
intptr_t cstride )

Definition at line 1118 of file bspline_create.cpp.

1121{
1122 int M = grid.num;
1123 double basis[4] = {1.0/6.0, 2.0/3.0, 1.0/6.0, 0.0};
1124 if (bc.lCode == PERIODIC || bc.lCode == ANTIPERIODIC) {
1125#ifdef HAVE_C_VARARRAYS
1126 double bands[M*4];
1127#else
1128 double *bands = new double[4*M];
1129#endif
1130 for (int i=0; i<M; i++) {
1131 bands[4*i+0] = basis[0];
1132 bands[4*i+1] = basis[1];
1133 bands[4*i+2] = basis[2];
1134 bands[4*i+3] = data[i*dstride];
1135 }
1136 if (bc.lCode == ANTIPERIODIC)
1137 solve_antiperiodic_interp_1d_d (bands, coefs, M, cstride);
1138 else
1139 solve_periodic_interp_1d_d (bands, coefs, M, cstride);
1140
1141
1142#ifndef HAVE_C_VARARRAYS
1143 delete[] bands;
1144#endif
1145 }
1146 else {
1147 // Setup boundary conditions
1148 double abcd_left[4];
1149 double abcd_right[4];
1150 for (int i = 0; i < 4; i++) {
1151 abcd_left[i] = 0.0;
1152 abcd_right[i] = 0.0;
1153 }
1154 // Left boundary
1155 if (bc.lCode == FLAT || bc.lCode == NATURAL)
1156 bc.lVal = 0.0;
1157 if (bc.lCode == FLAT || bc.lCode == DERIV1) {
1158 abcd_left[0] = -0.5 * grid.delta_inv;
1159 abcd_left[1] = 0.0 * grid.delta_inv;
1160 abcd_left[2] = 0.5 * grid.delta_inv;
1161 abcd_left[3] = bc.lVal;
1162 }
1163 if (bc.lCode == NATURAL || bc.lCode == DERIV2) {
1164 abcd_left[0] = 1.0 * grid.delta_inv * grid.delta_inv;
1165 abcd_left[1] =-2.0 * grid.delta_inv * grid.delta_inv;
1166 abcd_left[2] = 1.0 * grid.delta_inv * grid.delta_inv;
1167 abcd_left[3] = bc.lVal;
1168 }
1169
1170 // Right boundary
1171 if (bc.rCode == FLAT || bc.rCode == NATURAL)
1172 bc.rVal = 0.0;
1173 if (bc.rCode == FLAT || bc.rCode == DERIV1) {
1174 abcd_right[0] = -0.5 * grid.delta_inv;
1175 abcd_right[1] = 0.0 * grid.delta_inv;
1176 abcd_right[2] = 0.5 * grid.delta_inv;
1177 abcd_right[3] = bc.rVal;
1178 }
1179 if (bc.rCode == NATURAL || bc.rCode == DERIV2) {
1180 abcd_right[0] = 1.0 *grid.delta_inv * grid.delta_inv;
1181 abcd_right[1] =-2.0 *grid.delta_inv * grid.delta_inv;
1182 abcd_right[2] = 1.0 *grid.delta_inv * grid.delta_inv;
1183 abcd_right[3] = bc.rVal;
1184 }
1185#ifdef HAVE_C_VARARRAYS
1186 double bands[(M+2)*4];
1187#else
1188 double *bands = new double[(M+2)*4];
1189#endif
1190 for (int i=0; i<4; i++) {
1191 bands[4*( 0 )+i] = abcd_left[i];
1192 bands[4*(M+1)+i] = abcd_right[i];
1193 }
1194 for (int i=0; i<M; i++) {
1195 for (int j=0; j<3; j++)
1196 bands[4*(i+1)+j] = basis[j];
1197 bands[4*(i+1)+3] = data[i*dstride];
1198 }
1199 // Now, solve for coefficients
1200 solve_deriv_interp_1d_d (bands, coefs, M, cstride);
1201#ifndef HAVE_C_VARARRAYS
1202 delete[] bands;
1203#endif
1204 }
1205}
@ FLAT
@ NATURAL
@ DERIV1
@ DERIV2
void solve_periodic_interp_1d_d(double bands[], double coefs[], int M, int cstride)
void solve_deriv_interp_1d_d(double bands[], double coefs[], int M, int cstride)
void solve_antiperiodic_interp_1d_d(double bands[], double coefs[], int M, int cstride)
double lVal
bc_code rCode
double rVal

References ANTIPERIODIC, Ugrid::delta_inv, DERIV1, DERIV2, FLAT, BCtype_d::lCode, BCtype_d::lVal, NATURAL, Ugrid::num, PERIODIC, BCtype_d::rCode, BCtype_d::rVal, solve_antiperiodic_interp_1d_d(), solve_deriv_interp_1d_d(), and solve_periodic_interp_1d_d().

◆ find_coefs_1d_s()

void find_coefs_1d_s ( Ugrid grid,
BCtype_s bc,
float * data,
intptr_t dstride,
float * coefs,
intptr_t cstride )

Definition at line 240 of file bspline_create.cpp.

243{
244 int M = grid.num;
245 float basis[4] = {1.0/6.0, 2.0/3.0, 1.0/6.0, 0.0};
246 if (bc.lCode == PERIODIC || bc.lCode == ANTIPERIODIC) {
247
248 float *bands = new float[4*M];
249
250 for (int i=0; i<M; i++) {
251 bands[4*i+0] = basis[0];
252 bands[4*i+1] = basis[1];
253 bands[4*i+2] = basis[2];
254 bands[4*i+3] = data[i*dstride];
255 }
256 if (bc.lCode == PERIODIC)
257 solve_periodic_interp_1d_s (bands, coefs, M, cstride);
258 else
259 solve_antiperiodic_interp_1d_s (bands, coefs, M, cstride);
260
261 delete[] bands;
262 }
263 else {
264 // Setup boundary conditions
265 float abcd_left[4];
266 float abcd_right[4];
267 for (int i = 0; i < 4; i++) {
268 abcd_left[i] = 0.0;
269 abcd_right[i] = 0.0;
270 }
271
272 // Left boundary
273 if (bc.lCode == FLAT || bc.lCode == NATURAL)
274 bc.lVal = 0.0;
275 if (bc.lCode == FLAT || bc.lCode == DERIV1) {
276 abcd_left[0] = -0.5 * grid.delta_inv;
277 abcd_left[1] = 0.0 * grid.delta_inv;
278 abcd_left[2] = 0.5 * grid.delta_inv;
279 abcd_left[3] = bc.lVal;
280 }
281 if (bc.lCode == NATURAL || bc.lCode == DERIV2) {
282 abcd_left[0] = 1.0 * grid.delta_inv * grid.delta_inv;
283 abcd_left[1] =-2.0 * grid.delta_inv * grid.delta_inv;
284 abcd_left[2] = 1.0 * grid.delta_inv * grid.delta_inv;
285 abcd_left[3] = bc.lVal;
286 }
287
288 // Right boundary
289 if (bc.rCode == FLAT || bc.rCode == NATURAL)
290 bc.rVal = 0.0;
291 if (bc.rCode == FLAT || bc.rCode == DERIV1) {
292 abcd_right[0] = -0.5 * grid.delta_inv;
293 abcd_right[1] = 0.0 * grid.delta_inv;
294 abcd_right[2] = 0.5 * grid.delta_inv;
295 abcd_right[3] = bc.rVal;
296 }
297 if (bc.rCode == NATURAL || bc.rCode == DERIV2) {
298 abcd_right[0] = 1.0 *grid.delta_inv * grid.delta_inv;
299 abcd_right[1] =-2.0 *grid.delta_inv * grid.delta_inv;
300 abcd_right[2] = 1.0 *grid.delta_inv * grid.delta_inv;
301 abcd_right[3] = bc.rVal;
302 }
303
304 float *bands = new float[4*(M+2)];
305 for (int i=0; i<4; i++) {
306 bands[4*( 0 )+i] = abcd_left[i];
307 bands[4*(M+1)+i] = abcd_right[i];
308 }
309 for (int i=0; i<M; i++) {
310 for (int j=0; j<3; j++)
311 bands[4*(i+1)+j] = basis[j];
312 bands[4*(i+1)+3] = data[i*dstride];
313 }
314 // Now, solve for coefficients
315 solve_deriv_interp_1d_s (bands, coefs, M, cstride);
316 delete[] bands;
317 }
318}
void solve_deriv_interp_1d_s(float bands[], float coefs[], int M, int cstride)
void solve_periodic_interp_1d_s(float bands[], float coefs[], int M, int cstride)
void solve_antiperiodic_interp_1d_s(float bands[], float coefs[], int M, int cstride)
float lVal
float rVal
bc_code rCode

References ANTIPERIODIC, Ugrid::delta_inv, DERIV1, DERIV2, FLAT, BCtype_s::lCode, BCtype_s::lVal, NATURAL, Ugrid::num, PERIODIC, BCtype_s::rCode, BCtype_s::rVal, solve_antiperiodic_interp_1d_s(), solve_deriv_interp_1d_s(), and solve_periodic_interp_1d_s().

◆ init_sse_data()

void init_sse_data ( )

Definition at line 62 of file bspline_data.cpp.

63{
64#ifdef HAVE_SSE
65 if (A_s == 0) {
66 posix_memalign ((void**)&A_s, 16, (sizeof(__m128)*12));
67 A_s[0] = _mm_setr_ps ( 1.0/6.0, -3.0/6.0, 3.0/6.0, -1.0/6.0 );
68 A_s[0] = _mm_setr_ps ( 1.0/6.0, -3.0/6.0, 3.0/6.0, -1.0/6.0 );
69 A_s[1] = _mm_setr_ps ( 4.0/6.0, 0.0/6.0, -6.0/6.0, 3.0/6.0 );
70 A_s[2] = _mm_setr_ps ( 1.0/6.0, 3.0/6.0, 3.0/6.0, -3.0/6.0 );
71 A_s[3] = _mm_setr_ps ( 0.0/6.0, 0.0/6.0, 0.0/6.0, 1.0/6.0 );
72 A_s[4] = _mm_setr_ps ( -0.5, 1.0, -0.5, 0.0 );
73 A_s[5] = _mm_setr_ps ( 0.0, -2.0, 1.5, 0.0 );
74 A_s[6] = _mm_setr_ps ( 0.5, 1.0, -1.5, 0.0 );
75 A_s[7] = _mm_setr_ps ( 0.0, 0.0, 0.5, 0.0 );
76 A_s[8] = _mm_setr_ps ( 1.0, -1.0, 0.0, 0.0 );
77 A_s[9] = _mm_setr_ps ( -2.0, 3.0, 0.0, 0.0 );
78 A_s[10] = _mm_setr_ps ( 1.0, -3.0, 0.0, 0.0 );
79 A_s[11] = _mm_setr_ps ( 0.0, 1.0, 0.0, 0.0 );
80 }
81
82#endif
83#ifdef HAVE_SSE2
84 if (A_d == 0) {
85 posix_memalign ((void**)&A_d, 16, (sizeof(__m128d)*24));
86 A_d[ 0] = _mm_setr_pd ( 3.0/6.0, -1.0/6.0 );
87 A_d[ 1] = _mm_setr_pd ( 1.0/6.0, -3.0/6.0 );
88 A_d[ 2] = _mm_setr_pd ( -6.0/6.0, 3.0/6.0 );
89 A_d[ 3] = _mm_setr_pd ( 4.0/6.0, 0.0/6.0 );
90 A_d[ 4] = _mm_setr_pd ( 3.0/6.0, -3.0/6.0 );
91 A_d[ 5] = _mm_setr_pd ( 1.0/6.0, 3.0/6.0 );
92 A_d[ 6] = _mm_setr_pd ( 0.0/6.0, 1.0/6.0 );
93 A_d[ 7] = _mm_setr_pd ( 0.0/6.0, 0.0/6.0 );
94 A_d[ 8] = _mm_setr_pd ( -0.5, 0.0 );
95 A_d[ 9] = _mm_setr_pd ( -0.5, 1.0 );
96 A_d[10] = _mm_setr_pd ( 1.5, 0.0 );
97 A_d[11] = _mm_setr_pd ( 0.0, -2.0 );
98 A_d[12] = _mm_setr_pd ( -1.5, 0.0 );
99 A_d[13] = _mm_setr_pd ( 0.5, 1.0 );
100 A_d[14] = _mm_setr_pd ( 0.5, 0.0 );
101 A_d[15] = _mm_setr_pd ( 0.0, 0.0 );
102 A_d[16] = _mm_setr_pd ( 0.0, 0.0 );
103 A_d[17] = _mm_setr_pd ( 1.0, -1.0 );
104 A_d[18] = _mm_setr_pd ( 0.0, 0.0 );
105 A_d[19] = _mm_setr_pd ( -2.0, 3.0 );
106 A_d[20] = _mm_setr_pd ( 0.0, 0.0 );
107 A_d[21] = _mm_setr_pd ( 1.0, -3.0 );
108 A_d[22] = _mm_setr_pd ( 0.0, 0.0 );
109 A_d[23] = _mm_setr_pd ( 0.0, 1.0 );
110 }
111#endif
112}
int posix_memalign(void **memptr, size_t alignment, size_t size)

◆ posix_memalign()

int posix_memalign ( void ** memptr,
size_t alignment,
size_t size )

◆ set_multi_UBspline_1d_c()

void set_multi_UBspline_1d_c ( multi_UBspline_1d_c * spline,
int num,
complex_float * data )

Definition at line 433 of file multi_bspline_create.cpp.

434{
435 complex_float *coefs = spline->coefs + num;
436
437 BCtype_s xBC_r, xBC_i;
438 xBC_r.lCode = spline->xBC.lCode; xBC_r.rCode = spline->xBC.rCode;
439 xBC_r.lVal = spline->xBC.lVal_r; xBC_r.rVal = spline->xBC.rVal_r;
440 xBC_i.lCode = spline->xBC.lCode; xBC_i.rCode = spline->xBC.rCode;
441 xBC_i.lVal = spline->xBC.lVal_i; xBC_i.rVal = spline->xBC.rVal_i;
442
443 int xs = spline->x_stride;
444 // Real part
445 find_coefs_1d_s (spline->x_grid, xBC_r,
446 (float*)data, (intptr_t)2, (float*)coefs, (intptr_t)2*xs);
447 // Imaginarty part
448 find_coefs_1d_s (spline->x_grid, xBC_i,
449 ((float*)data)+1, (intptr_t)2, ((float*)coefs+1), (intptr_t)2*xs);
450}
void find_coefs_1d_s(Ugrid grid, BCtype_s bc, float *data, intptr_t dstride, float *coefs, intptr_t cstride)
bc_code rCode
float lVal_r
float rVal_r
float rVal_i
float lVal_i
complex_float *restrict coefs

References multi_UBspline_1d_c::coefs, find_coefs_1d_s(), BCtype_s::lCode, BCtype_c::lCode, BCtype_s::lVal, BCtype_c::lVal_i, BCtype_c::lVal_r, BCtype_s::rCode, BCtype_c::rCode, BCtype_s::rVal, BCtype_c::rVal_i, BCtype_c::rVal_r, multi_UBspline_1d_c::x_grid, multi_UBspline_1d_c::x_stride, and multi_UBspline_1d_c::xBC.

◆ set_multi_UBspline_1d_d()

void set_multi_UBspline_1d_d ( multi_UBspline_1d_d * spline,
int num,
double * data )

Definition at line 821 of file multi_bspline_create.cpp.

822{
823 double *coefs = spline->coefs + num;
824 int xs = spline->x_stride;
825 find_coefs_1d_d (spline->x_grid, spline->xBC, data, 1, coefs, xs);
826}
void find_coefs_1d_d(Ugrid grid, BCtype_d bc, double *data, intptr_t dstride, double *coefs, intptr_t cstride)

References multi_UBspline_1d_d::coefs, find_coefs_1d_d(), multi_UBspline_1d_d::x_grid, multi_UBspline_1d_d::x_stride, and multi_UBspline_1d_d::xBC.

◆ set_multi_UBspline_1d_d_BC()

void set_multi_UBspline_1d_d_BC ( multi_UBspline_1d_d * spline,
int num,
double * data,
BCtype_d xBC )

Definition at line 829 of file multi_bspline_create.cpp.

831{
832 double *coefs = spline->coefs + num;
833 int xs = spline->x_stride;
834 find_coefs_1d_d (spline->x_grid, xBC, data, 1, coefs, xs);
835}

References multi_UBspline_1d_d::coefs, find_coefs_1d_d(), multi_UBspline_1d_d::x_grid, and multi_UBspline_1d_d::x_stride.

◆ set_multi_UBspline_1d_s()

void set_multi_UBspline_1d_s ( multi_UBspline_1d_s * spline,
int num,
float * data )

Definition at line 140 of file multi_bspline_create.cpp.

142{
143 float *coefs = spline->coefs + num;
144 int xs = spline->x_stride;
145 find_coefs_1d_s (spline->x_grid, spline->xBC, data, 1,
146 coefs, xs);
147}

References multi_UBspline_1d_s::coefs, find_coefs_1d_s(), multi_UBspline_1d_s::x_grid, multi_UBspline_1d_s::x_stride, and multi_UBspline_1d_s::xBC.

◆ set_multi_UBspline_1d_z()

void set_multi_UBspline_1d_z ( multi_UBspline_1d_z * spline,
int num,
complex_double * data )

Definition at line 1137 of file multi_bspline_create.cpp.

1138{
1139// int Mx = spline->x_grid.num;
1140// Set but not used
1141// int Nx;
1142
1143 complex_double *coefs = spline->coefs + num;
1144
1145// if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
1146// Nx = Mx+3;
1147// else
1148// Nx = Mx+2;
1149
1150 BCtype_d xBC_r, xBC_i;
1151 xBC_r.lCode = spline->xBC.lCode; xBC_r.rCode = spline->xBC.rCode;
1152 xBC_r.lVal = spline->xBC.lVal_r; xBC_r.rVal = spline->xBC.rVal_r;
1153 xBC_i.lCode = spline->xBC.lCode; xBC_i.rCode = spline->xBC.rCode;
1154 xBC_i.lVal = spline->xBC.lVal_i; xBC_i.rVal = spline->xBC.rVal_i;
1155 int xs = spline->x_stride;
1156 // Real part
1157 find_coefs_1d_d (spline->x_grid, xBC_r,
1158 (double*)data, (intptr_t)2,
1159 ((double*)coefs), (intptr_t)2*xs);
1160 // Imaginary part
1161 find_coefs_1d_d (spline->x_grid, xBC_i,
1162 ((double*)data)+1, (intptr_t)2,
1163 ((double*)coefs)+1, (intptr_t)2*xs);
1164
1165}
double lVal_r
double lVal_i
double rVal_i
bc_code rCode
double rVal_r
complex_double *restrict coefs

References multi_UBspline_1d_z::coefs, find_coefs_1d_d(), BCtype_d::lCode, BCtype_z::lCode, BCtype_d::lVal, BCtype_z::lVal_i, BCtype_z::lVal_r, BCtype_d::rCode, BCtype_z::rCode, BCtype_d::rVal, BCtype_z::rVal_i, BCtype_z::rVal_r, multi_UBspline_1d_z::x_grid, multi_UBspline_1d_z::x_stride, and multi_UBspline_1d_z::xBC.

◆ set_multi_UBspline_1d_z_BC()

void set_multi_UBspline_1d_z_BC ( multi_UBspline_1d_z * spline,
int num,
complex_double * data,
BCtype_z xBC )

Definition at line 1168 of file multi_bspline_create.cpp.

1170{
1171// int Mx = spline->x_grid.num;
1172// int Nx;
1173
1174 complex_double *coefs = spline->coefs + num;
1175
1176// if (xBC.lCode == PERIODIC || xBC.lCode == ANTIPERIODIC)
1177// Nx = Mx+3;
1178// else
1179// Nx = Mx+2;
1180
1181 BCtype_d xBC_r, xBC_i;
1182 xBC_r.lCode = xBC.lCode; xBC_r.rCode = xBC.rCode;
1183 xBC_r.lVal = xBC.lVal_r; xBC_r.rVal = xBC.rVal_r;
1184 xBC_i.lCode = xBC.lCode; xBC_i.rCode = xBC.rCode;
1185 xBC_i.lVal = xBC.lVal_i; xBC_i.rVal = xBC.rVal_i;
1186 int xs = spline->x_stride;
1187 // Real part
1188 find_coefs_1d_d (spline->x_grid, xBC_r,
1189 (double*)data, (intptr_t)2,
1190 ((double*)coefs), (intptr_t)2*xs);
1191 // Imaginary part
1192 find_coefs_1d_d (spline->x_grid, xBC_i,
1193 ((double*)data)+1, (intptr_t)2,
1194 ((double*)coefs)+1, (intptr_t)2*xs);
1195}

References multi_UBspline_1d_z::coefs, find_coefs_1d_d(), BCtype_d::lCode, BCtype_z::lCode, BCtype_d::lVal, BCtype_z::lVal_i, BCtype_z::lVal_r, BCtype_d::rCode, BCtype_z::rCode, BCtype_d::rVal, BCtype_z::rVal_i, BCtype_z::rVal_r, multi_UBspline_1d_z::x_grid, and multi_UBspline_1d_z::x_stride.

◆ set_multi_UBspline_2d_c()

void set_multi_UBspline_2d_c ( multi_UBspline_2d_c * spline,
int num,
complex_float * data )

Definition at line 521 of file multi_bspline_create.cpp.

522{
523 // Setup internal variables
524 int Mx = spline->x_grid.num;
525 int My = spline->y_grid.num;
526 int Nx, Ny;
527
528 complex_float* coefs = spline->coefs + num;
529
530 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
531 Nx = Mx+3;
532 else
533 Nx = Mx+2;
534 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
535 Ny = My+3;
536 else
537 Ny = My+2;
538
539 BCtype_s xBC_r, xBC_i, yBC_r, yBC_i;
540 xBC_r.lCode = spline->xBC.lCode; xBC_r.rCode = spline->xBC.rCode;
541 xBC_r.lVal = spline->xBC.lVal_r; xBC_r.rVal = spline->xBC.rVal_r;
542 xBC_i.lCode = spline->xBC.lCode; xBC_i.rCode = spline->xBC.rCode;
543 xBC_i.lVal = spline->xBC.lVal_i; xBC_i.rVal = spline->xBC.rVal_i;
544 yBC_r.lCode = spline->yBC.lCode; yBC_r.rCode = spline->yBC.rCode;
545 yBC_r.lVal = spline->yBC.lVal_r; yBC_r.rVal = spline->yBC.rVal_r;
546 yBC_i.lCode = spline->yBC.lCode; yBC_i.rCode = spline->yBC.rCode;
547 yBC_i.lVal = spline->yBC.lVal_i; yBC_i.rVal = spline->yBC.rVal_i;
548
549 int ys = spline->y_stride;
550 // First, solve in the X-direction
551 for (int iy=0; iy<My; iy++) {
552 intptr_t doffset = (2*iy);
553 intptr_t coffset = (2*iy)*ys;
554 // Real part
555 find_coefs_1d_s (spline->x_grid, xBC_r, ((float*)data)+doffset, (intptr_t)2*My,
556 (float*)coefs+coffset, (intptr_t)2*Ny*ys);
557 // Imag part
558 find_coefs_1d_s (spline->x_grid, xBC_i, ((float*)data)+doffset+1, (intptr_t)2*My,
559 ((float*)coefs)+coffset+1, (intptr_t)2*Ny*ys);
560 }
561
562 // Now, solve in the Y-direction
563 for (int ix=0; ix<Nx; ix++) {
564 intptr_t doffset = (2*ix*Ny)*ys;
565 intptr_t coffset = (2*ix*Ny)*ys;
566 // Real part
567 find_coefs_1d_s (spline->y_grid, yBC_r, ((float*)coefs)+doffset,
568 (intptr_t)2*ys, ((float*)coefs)+coffset, (intptr_t)2*ys);
569 // Imag part
570 find_coefs_1d_s (spline->y_grid, yBC_i, ((float*)coefs)+doffset+1,
571 (intptr_t)2*ys, ((float*)coefs)+coffset+1, (intptr_t)2*ys);
572 }
573}
complex_float *restrict coefs

References ANTIPERIODIC, multi_UBspline_2d_c::coefs, find_coefs_1d_s(), BCtype_s::lCode, BCtype_c::lCode, BCtype_s::lVal, BCtype_c::lVal_i, BCtype_c::lVal_r, Ugrid::num, PERIODIC, BCtype_s::rCode, BCtype_c::rCode, BCtype_s::rVal, BCtype_c::rVal_i, BCtype_c::rVal_r, multi_UBspline_2d_c::x_grid, multi_UBspline_2d_c::xBC, multi_UBspline_2d_c::y_grid, multi_UBspline_2d_c::y_stride, and multi_UBspline_2d_c::yBC.

◆ set_multi_UBspline_2d_d()

void set_multi_UBspline_2d_d ( multi_UBspline_2d_d * spline,
int num,
double * data )

Definition at line 902 of file multi_bspline_create.cpp.

903{
904 int Mx = spline->x_grid.num;
905 int My = spline->y_grid.num;
906 int Nx, Ny;
907 double *coefs = spline->coefs + num;
908
909 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
910 Nx = Mx+3;
911 else
912 Nx = Mx+2;
913
914 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
915 Ny = My+3;
916 else
917 Ny = My+2;
918
919 int ys = spline->y_stride;
920 // First, solve in the X-direction
921 for (int iy=0; iy<My; iy++) {
922 intptr_t doffset = iy;
923 intptr_t coffset = iy*ys;
924 find_coefs_1d_d (spline->x_grid, spline->xBC,
925 data+doffset, (intptr_t)My,
926 coefs+coffset, (intptr_t)Ny*ys);
927 }
928
929 // Now, solve in the Y-direction
930 for (int ix=0; ix<Nx; ix++) {
931 intptr_t doffset = ix*Ny*ys;
932 intptr_t coffset = ix*Ny*ys;
933 find_coefs_1d_d (spline->y_grid, spline->yBC,
934 coefs+doffset, (intptr_t)ys,
935 coefs+coffset, (intptr_t)ys);
936 }
937}

References ANTIPERIODIC, multi_UBspline_2d_d::coefs, find_coefs_1d_d(), BCtype_d::lCode, Ugrid::num, PERIODIC, multi_UBspline_2d_d::x_grid, multi_UBspline_2d_d::xBC, multi_UBspline_2d_d::y_grid, multi_UBspline_2d_d::y_stride, and multi_UBspline_2d_d::yBC.

◆ set_multi_UBspline_2d_s()

void set_multi_UBspline_2d_s ( multi_UBspline_2d_s * spline,
int num,
float * data )

Definition at line 215 of file multi_bspline_create.cpp.

216{
217 int Mx = spline->x_grid.num;
218 int My = spline->y_grid.num;
219 int Nx, Ny;
220
221 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
222 Nx = Mx+3;
223 else
224 Nx = Mx+2;
225 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
226 Ny = My+3;
227 else
228 Ny = My+2;
229
230 float *coefs = spline->coefs + num;
231 int ys = spline->y_stride;
232 // First, solve in the X-direction
233 for (int iy=0; iy<My; iy++) {
234 intptr_t doffset = iy;
235 intptr_t coffset = iy*ys;
236 find_coefs_1d_s (spline->x_grid, spline->xBC, data+doffset, (intptr_t)My,
237 coefs+coffset, (intptr_t)Ny*ys);
238 }
239
240 // Now, solve in the Y-direction
241 for (int ix=0; ix<Nx; ix++) {
242 intptr_t doffset = ix*Ny*ys;
243 intptr_t coffset = ix*Ny*ys;
244 find_coefs_1d_s (spline->y_grid, spline->yBC, coefs+doffset, (intptr_t)ys,
245 coefs+coffset, (intptr_t)ys);
246 }
247}

References ANTIPERIODIC, multi_UBspline_2d_s::coefs, find_coefs_1d_s(), BCtype_s::lCode, Ugrid::num, PERIODIC, multi_UBspline_2d_s::x_grid, multi_UBspline_2d_s::xBC, multi_UBspline_2d_s::y_grid, multi_UBspline_2d_s::y_stride, and multi_UBspline_2d_s::yBC.

◆ set_multi_UBspline_2d_z()

void set_multi_UBspline_2d_z ( multi_UBspline_2d_z * spline,
int num,
complex_double * data )

Definition at line 1257 of file multi_bspline_create.cpp.

1259{
1260 int Mx = spline->x_grid.num;
1261 int My = spline->y_grid.num;
1262 int Nx, Ny;
1263
1264 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
1265 Nx = Mx+3;
1266 else
1267 Nx = Mx+2;
1268 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
1269 Ny = My+3;
1270 else
1271 Ny = My+2;
1272
1273 BCtype_d xBC_r, xBC_i, yBC_r, yBC_i;
1274 xBC_r.lCode = spline->xBC.lCode; xBC_r.rCode = spline->xBC.rCode;
1275 xBC_r.lVal = spline->xBC.lVal_r; xBC_r.rVal = spline->xBC.rVal_r;
1276 xBC_i.lCode = spline->xBC.lCode; xBC_i.rCode = spline->xBC.rCode;
1277 xBC_i.lVal = spline->xBC.lVal_i; xBC_i.rVal = spline->xBC.rVal_i;
1278 yBC_r.lCode = spline->yBC.lCode; yBC_r.rCode = spline->yBC.rCode;
1279 yBC_r.lVal = spline->yBC.lVal_r; yBC_r.rVal = spline->yBC.rVal_r;
1280 yBC_i.lCode = spline->yBC.lCode; yBC_i.rCode = spline->yBC.rCode;
1281 yBC_i.lVal = spline->yBC.lVal_i; yBC_i.rVal = spline->yBC.rVal_i;
1282
1283 complex_double *coefs = spline->coefs + num;
1284 int ys = spline->y_stride;
1285
1286 // First, solve in the X-direction
1287 for (int iy=0; iy<My; iy++) {
1288 intptr_t doffset = 2*iy;
1289 intptr_t coffset = 2*iy*ys;
1290 // Real part
1291 find_coefs_1d_d (spline->x_grid, xBC_r,
1292 ((double*)data+doffset), (intptr_t)2*My,
1293 (double*)coefs+coffset, (intptr_t)2*Ny*ys);
1294 // Imag part
1295 find_coefs_1d_d (spline->x_grid, xBC_i,
1296 ((double*)data)+doffset+1, (intptr_t)2*My,
1297 ((double*)coefs)+coffset+1, (intptr_t)2*Ny*ys);
1298 }
1299
1300 // Now, solve in the Y-direction
1301 for (int ix=0; ix<Nx; ix++) {
1302 intptr_t doffset = 2*ix*Ny*ys;
1303 intptr_t coffset = 2*ix*Ny*ys;
1304 // Real part
1305 find_coefs_1d_d (spline->y_grid, yBC_r,
1306 ((double*)coefs)+doffset, (intptr_t)2*ys,
1307 (double*)coefs+coffset, (intptr_t)2*ys);
1308 // Imag part
1309 find_coefs_1d_d (spline->y_grid, yBC_i,
1310 (double*)coefs+doffset+1, (intptr_t)2*ys,
1311 ((double*)coefs)+coffset+1, (intptr_t)2*ys);
1312 }
1313}
complex_double *restrict coefs

References ANTIPERIODIC, multi_UBspline_2d_z::coefs, find_coefs_1d_d(), BCtype_d::lCode, BCtype_z::lCode, BCtype_d::lVal, BCtype_z::lVal_i, BCtype_z::lVal_r, Ugrid::num, PERIODIC, BCtype_d::rCode, BCtype_z::rCode, BCtype_d::rVal, BCtype_z::rVal_i, BCtype_z::rVal_r, multi_UBspline_2d_z::x_grid, multi_UBspline_2d_z::xBC, multi_UBspline_2d_z::y_grid, multi_UBspline_2d_z::y_stride, and multi_UBspline_2d_z::yBC.

◆ set_multi_UBspline_3d_c()

void set_multi_UBspline_3d_c ( multi_UBspline_3d_c * spline,
int num,
complex_float * data )

Definition at line 650 of file multi_bspline_create.cpp.

651{
652 // Setup internal variables
653 int Mx = spline->x_grid.num;
654 int My = spline->y_grid.num;
655 int Mz = spline->z_grid.num;
656 int Nx, Ny, Nz;
657
658 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
659 Nx = Mx+3;
660 else
661 Nx = Mx+2;
662 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
663 Ny = My+3;
664 else
665 Ny = My+2;
666 if (spline->zBC.lCode == PERIODIC || spline->zBC.lCode == ANTIPERIODIC)
667 Nz = Mz+3;
668 else
669 Nz = Mz+2;
670
671 BCtype_s xBC_r, xBC_i, yBC_r, yBC_i, zBC_r, zBC_i;
672 xBC_r.lCode = spline->xBC.lCode; xBC_r.rCode = spline->xBC.rCode;
673 xBC_r.lVal = spline->xBC.lVal_r; xBC_r.rVal = spline->xBC.rVal_r;
674 xBC_i.lCode = spline->xBC.lCode; xBC_i.rCode = spline->xBC.rCode;
675 xBC_i.lVal = spline->xBC.lVal_i; xBC_i.rVal = spline->xBC.rVal_i;
676 yBC_r.lCode = spline->yBC.lCode; yBC_r.rCode = spline->yBC.rCode;
677 yBC_r.lVal = spline->yBC.lVal_r; yBC_r.rVal = spline->yBC.rVal_r;
678 yBC_i.lCode = spline->yBC.lCode; yBC_i.rCode = spline->yBC.rCode;
679 yBC_i.lVal = spline->yBC.lVal_i; yBC_i.rVal = spline->yBC.rVal_i;
680 zBC_r.lCode = spline->zBC.lCode; zBC_r.rCode = spline->zBC.rCode;
681 zBC_r.lVal = spline->zBC.lVal_r; zBC_r.rVal = spline->zBC.rVal_r;
682 zBC_i.lCode = spline->zBC.lCode; zBC_i.rCode = spline->zBC.rCode;
683 zBC_i.lVal = spline->zBC.lVal_i; zBC_i.rVal = spline->zBC.rVal_i;
684
685 complex_float *coefs = spline->coefs + num;
686 int zs = spline->z_stride;
687 // First, solve in the X-direction
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;
692 // Real part
693 find_coefs_1d_s (spline->x_grid, xBC_r,
694 ((float*)data)+doffset, (intptr_t)2*My*Mz,
695 ((float*)coefs)+coffset, (intptr_t)2*Ny*Nz*zs);
696 // Imag part
697 find_coefs_1d_s (spline->x_grid, xBC_i,
698 ((float*)data)+doffset+1, (intptr_t)2*My*Mz,
699 ((float*)coefs)+coffset+1, (intptr_t)2*Ny*Nz*zs);
700 }
701
702 // Now, solve in the Y-direction
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;
707 // Real part
708 find_coefs_1d_s (spline->y_grid, yBC_r,
709 ((float*)coefs)+doffset, (intptr_t)2*Nz*zs,
710 ((float*)coefs)+coffset, (intptr_t)2*Nz*zs);
711 // Imag part
712 find_coefs_1d_s (spline->y_grid, yBC_i,
713 ((float*)coefs)+doffset+1, (intptr_t)2*Nz*zs,
714 ((float*)coefs)+coffset+1, (intptr_t)2*Nz*zs);
715 }
716
717 // Now, solve in the Z-direction
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;
722 // Real part
723 find_coefs_1d_s (spline->z_grid, zBC_r,
724 ((float*)coefs)+doffset, (intptr_t)2*zs,
725 ((float*)coefs)+coffset, (intptr_t)2*zs);
726 // Imag part
727 find_coefs_1d_s (spline->z_grid, zBC_i,
728 ((float*)coefs)+doffset+1, (intptr_t)2*zs,
729 ((float*)coefs)+coffset+1, (intptr_t)2*zs);
730 }
731}
complex_float *restrict coefs

References ANTIPERIODIC, multi_UBspline_3d_c::coefs, find_coefs_1d_s(), BCtype_s::lCode, BCtype_c::lCode, BCtype_s::lVal, BCtype_c::lVal_i, BCtype_c::lVal_r, Ugrid::num, PERIODIC, BCtype_s::rCode, BCtype_c::rCode, BCtype_s::rVal, BCtype_c::rVal_i, BCtype_c::rVal_r, multi_UBspline_3d_c::x_grid, multi_UBspline_3d_c::xBC, multi_UBspline_3d_c::y_grid, multi_UBspline_3d_c::yBC, multi_UBspline_3d_c::z_grid, multi_UBspline_3d_c::z_stride, and multi_UBspline_3d_c::zBC.

◆ set_multi_UBspline_3d_d()

void set_multi_UBspline_3d_d ( multi_UBspline_3d_d * spline,
int num,
double * data )

Definition at line 1020 of file multi_bspline_create.cpp.

1021{
1022 int Mx = spline->x_grid.num;
1023 int My = spline->y_grid.num;
1024 int Mz = spline->z_grid.num;
1025 int Nx, Ny, Nz;
1026
1027 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
1028 Nx = Mx+3;
1029 else
1030 Nx = Mx+2;
1031 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
1032 Ny = My+3;
1033 else
1034 Ny = My+2;
1035 if (spline->zBC.lCode == PERIODIC || spline->zBC.lCode == ANTIPERIODIC)
1036 Nz = Mz+3;
1037 else
1038 Nz = Mz+2;
1039
1040 double *coefs = spline->coefs + num;
1041 intptr_t zs = spline->z_stride;
1042
1043 // First, solve in the X-direction
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;
1048 find_coefs_1d_d (spline->x_grid, spline->xBC,
1049 data+doffset, (intptr_t)My*Mz,
1050 coefs+coffset, (intptr_t)Ny*Nz*zs);
1051 }
1052
1053 // Now, solve in the Y-direction
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;
1058 find_coefs_1d_d (spline->y_grid, spline->yBC,
1059 coefs+doffset, (intptr_t)Nz*zs,
1060 coefs+coffset, (intptr_t)Nz*zs);
1061 }
1062
1063 // Now, solve in the Z-direction
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;
1068 find_coefs_1d_d (spline->z_grid, spline->zBC,
1069 coefs+doffset, (intptr_t)zs,
1070 coefs+coffset, (intptr_t)zs);
1071 }
1072}

References ANTIPERIODIC, multi_UBspline_3d_d::coefs, find_coefs_1d_d(), BCtype_d::lCode, Ugrid::num, PERIODIC, multi_UBspline_3d_d::x_grid, multi_UBspline_3d_d::xBC, multi_UBspline_3d_d::y_grid, multi_UBspline_3d_d::yBC, multi_UBspline_3d_d::z_grid, multi_UBspline_3d_d::z_stride, and multi_UBspline_3d_d::zBC.

◆ set_multi_UBspline_3d_s()

void set_multi_UBspline_3d_s ( multi_UBspline_3d_s * spline,
int num,
float * data )

Definition at line 323 of file multi_bspline_create.cpp.

324{
325 int Mx = spline->x_grid.num;
326 int My = spline->y_grid.num;
327 int Mz = spline->z_grid.num;
328 int Nx, Ny, Nz;
329
330 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
331 Nx = Mx+3;
332 else
333 Nx = Mx+2;
334 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
335 Ny = My+3;
336 else
337 Ny = My+2;
338 if (spline->zBC.lCode == PERIODIC || spline->zBC.lCode == ANTIPERIODIC)
339 Nz = Mz+3;
340 else
341 Nz = Mz+2;
342
343 float *coefs = spline->coefs + num;
344
345 int zs = spline->z_stride;
346 // First, solve in the X-direction
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;
351 find_coefs_1d_s (spline->x_grid, spline->xBC, data+doffset, (intptr_t)My*Mz,
352 coefs+coffset, (intptr_t)Ny*Nz*zs);
353 }
354
355 // Now, solve in the Y-direction
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;
360 find_coefs_1d_s (spline->y_grid, spline->yBC, coefs+doffset, (intptr_t)Nz*zs,
361 coefs+coffset, (intptr_t)Nz*zs);
362 }
363
364 // Now, solve in the Z-direction
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;
369 find_coefs_1d_s (spline->z_grid, spline->zBC, coefs+doffset,
370 (intptr_t)zs, coefs+coffset, (intptr_t)zs);
371 }
372}

References ANTIPERIODIC, multi_UBspline_3d_s::coefs, find_coefs_1d_s(), BCtype_s::lCode, Ugrid::num, PERIODIC, multi_UBspline_3d_s::x_grid, multi_UBspline_3d_s::xBC, multi_UBspline_3d_s::y_grid, multi_UBspline_3d_s::yBC, multi_UBspline_3d_s::z_grid, multi_UBspline_3d_s::z_stride, and multi_UBspline_3d_s::zBC.

◆ set_multi_UBspline_3d_z()

void set_multi_UBspline_3d_z ( multi_UBspline_3d_z * spline,
int num,
complex_double * data )

Definition at line 1393 of file multi_bspline_create.cpp.

1394{
1395 // Setup internal variables
1396 int Mx = spline->x_grid.num;
1397 int My = spline->y_grid.num;
1398 int Mz = spline->z_grid.num;
1399 int Nx, Ny, Nz;
1400
1401 if (spline->xBC.lCode == PERIODIC || spline->xBC.lCode == ANTIPERIODIC)
1402 Nx = Mx+3;
1403 else
1404 Nx = Mx+2;
1405 if (spline->yBC.lCode == PERIODIC || spline->yBC.lCode == ANTIPERIODIC)
1406 Ny = My+3;
1407 else
1408 Ny = My+2;
1409 if (spline->zBC.lCode == PERIODIC || spline->zBC.lCode == ANTIPERIODIC)
1410 Nz = Mz+3;
1411 else
1412 Nz = Mz+2;
1413
1414 BCtype_d xBC_r, xBC_i, yBC_r, yBC_i, zBC_r, zBC_i;
1415 xBC_r.lCode = spline->xBC.lCode; xBC_r.rCode = spline->xBC.rCode;
1416 xBC_r.lVal = spline->xBC.lVal_r; xBC_r.rVal = spline->xBC.rVal_r;
1417 xBC_i.lCode = spline->xBC.lCode; xBC_i.rCode = spline->xBC.rCode;
1418 xBC_i.lVal = spline->xBC.lVal_i; xBC_i.rVal = spline->xBC.rVal_i;
1419 yBC_r.lCode = spline->yBC.lCode; yBC_r.rCode = spline->yBC.rCode;
1420 yBC_r.lVal = spline->yBC.lVal_r; yBC_r.rVal = spline->yBC.rVal_r;
1421 yBC_i.lCode = spline->yBC.lCode; yBC_i.rCode = spline->yBC.rCode;
1422 yBC_i.lVal = spline->yBC.lVal_i; yBC_i.rVal = spline->yBC.rVal_i;
1423 zBC_r.lCode = spline->zBC.lCode; zBC_r.rCode = spline->zBC.rCode;
1424 zBC_r.lVal = spline->zBC.lVal_r; zBC_r.rVal = spline->zBC.rVal_r;
1425 zBC_i.lCode = spline->zBC.lCode; zBC_i.rCode = spline->zBC.rCode;
1426 zBC_i.lVal = spline->zBC.lVal_i; zBC_i.rVal = spline->zBC.rVal_i;
1427
1428 complex_double *coefs = spline->coefs + num;
1429
1430// unused variable
1431// int N = spline->num_splines;
1432 int zs = spline->z_stride;
1433 // First, solve in the X-direction
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;
1438 // Real part
1439 find_coefs_1d_d (spline->x_grid, xBC_r,
1440 ((double*)data)+doffset, (intptr_t)2*My*Mz,
1441 ((double*)coefs)+coffset, (intptr_t)2*Ny*Nz*zs);
1442 // Imag part
1443 find_coefs_1d_d (spline->x_grid, xBC_i,
1444 ((double*)data)+doffset+1, (intptr_t)2*My*Mz,
1445 ((double*)coefs)+coffset+1, (intptr_t)2*Ny*Nz*zs);
1446 }
1447
1448 // Now, solve in the Y-direction
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;
1453 // Real part
1454 find_coefs_1d_d (spline->y_grid, yBC_r,
1455 ((double*)coefs)+doffset, (intptr_t)2*Nz*zs,
1456 ((double*)coefs)+coffset, (intptr_t)2*Nz*zs);
1457 // Imag part
1458 find_coefs_1d_d (spline->y_grid, yBC_i,
1459 ((double*)coefs)+doffset+1, (intptr_t)2*Nz*zs,
1460 ((double*)coefs)+coffset+1, (intptr_t)2*Nz*zs);
1461 }
1462
1463 // Now, solve in the Z-direction
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;
1468 // Real part
1469 find_coefs_1d_d (spline->z_grid, zBC_r,
1470 ((double*)coefs)+doffset, (intptr_t)2*zs,
1471 ((double*)coefs)+coffset, (intptr_t)2*zs);
1472 // Imag part
1473 find_coefs_1d_d (spline->z_grid, zBC_i,
1474 ((double*)coefs)+doffset+1, (intptr_t)2*zs,
1475 ((double*)coefs)+coffset+1, (intptr_t)2*zs);
1476 }
1477}
complex_double *restrict coefs

References ANTIPERIODIC, multi_UBspline_3d_z::coefs, find_coefs_1d_d(), BCtype_d::lCode, BCtype_z::lCode, BCtype_d::lVal, BCtype_z::lVal_i, BCtype_z::lVal_r, Ugrid::num, PERIODIC, BCtype_d::rCode, BCtype_z::rCode, BCtype_d::rVal, BCtype_z::rVal_i, BCtype_z::rVal_r, multi_UBspline_3d_z::x_grid, multi_UBspline_3d_z::xBC, multi_UBspline_3d_z::y_grid, multi_UBspline_3d_z::yBC, multi_UBspline_3d_z::z_grid, multi_UBspline_3d_z::z_stride, and multi_UBspline_3d_z::zBC.

◆ solve_antiperiodic_interp_1d_s()

void solve_antiperiodic_interp_1d_s ( float bands[],
float coefs[],
int M,
int cstride )

Definition at line 156 of file bspline_create.cpp.

158{
159 bands[4*0+0] *= -1.0;
160 bands[4*(M-1)+2] *= -1.0;
161
162 std::vector<float> lastCol(M);
163
164 // Now solve:
165 // First and last rows are different
166 bands[4*(0)+2] /= bands[4*(0)+1];
167 bands[4*(0)+0] /= bands[4*(0)+1];
168 bands[4*(0)+3] /= bands[4*(0)+1];
169 bands[4*(0)+1] = 1.0;
170 bands[4*(M-1)+1] -= bands[4*(M-1)+2]*bands[4*(0)+0];
171 bands[4*(M-1)+3] -= bands[4*(M-1)+2]*bands[4*(0)+3];
172 bands[4*(M-1)+2] = -bands[4*(M-1)+2]*bands[4*(0)+2];
173 lastCol[0] = bands[4*(0)+0];
174
175 for (int row=1; row < (M-1); row++) {
176 bands[4*(row)+1] -= bands[4*(row)+0] * bands[4*(row-1)+2];
177 bands[4*(row)+3] -= bands[4*(row)+0] * bands[4*(row-1)+3];
178 lastCol[row] = -bands[4*(row)+0] * lastCol[row-1];
179 bands[4*(row)+0] = 0.0;
180 bands[4*(row)+2] /= bands[4*(row)+1];
181 bands[4*(row)+3] /= bands[4*(row)+1];
182 lastCol[row] /= bands[4*(row)+1];
183 bands[4*(row)+1] = 1.0;
184 if (row < (M-2)) {
185 bands[4*(M-1)+3] -= bands[4*(M-1)+2]*bands[4*(row)+3];
186 bands[4*(M-1)+1] -= bands[4*(M-1)+2]*lastCol[row];
187 bands[4*(M-1)+2] = -bands[4*(M-1)+2]*bands[4*(row)+2];
188 }
189 }
190
191 // Now do last row
192 // The [2] element and [0] element are now on top of each other
193 bands[4*(M-1)+0] += bands[4*(M-1)+2];
194 bands[4*(M-1)+1] -= bands[4*(M-1)+0] * (bands[4*(M-2)+2]+lastCol[M-2]);
195 bands[4*(M-1)+3] -= bands[4*(M-1)+0] * bands[4*(M-2)+3];
196 bands[4*(M-1)+3] /= bands[4*(M-1)+1];
197 coefs[M*cstride] = bands[4*(M-1)+3];
198 for (int row=M-2; row>=0; row--)
199 coefs[(row+1)*cstride] =
200 bands[4*(row)+3] - bands[4*(row)+2]*coefs[(row+2)*cstride] - lastCol[row]*coefs[M*cstride];
201
202 coefs[0*cstride] = -coefs[M*cstride];
203 coefs[(M+1)*cstride] = -coefs[1*cstride];
204 coefs[(M+2)*cstride] = -coefs[2*cstride];
205
206
207}

◆ solve_deriv_interp_1d_d()

void solve_deriv_interp_1d_d ( double bands[],
double coefs[],
int M,
int cstride )

Definition at line 959 of file bspline_create.cpp.

961{
962 // Solve interpolating equations
963 // First and last rows are different
964 bands[4*(0)+1] /= bands[4*(0)+0];
965 bands[4*(0)+2] /= bands[4*(0)+0];
966 bands[4*(0)+3] /= bands[4*(0)+0];
967 bands[4*(0)+0] = 1.0;
968 bands[4*(1)+1] -= bands[4*(1)+0]*bands[4*(0)+1];
969 bands[4*(1)+2] -= bands[4*(1)+0]*bands[4*(0)+2];
970 bands[4*(1)+3] -= bands[4*(1)+0]*bands[4*(0)+3];
971 bands[4*(0)+0] = 0.0;
972 bands[4*(1)+2] /= bands[4*(1)+1];
973 bands[4*(1)+3] /= bands[4*(1)+1];
974 bands[4*(1)+1] = 1.0;
975
976 // Now do rows 2 through M+1
977 for (int row=2; row < (M+1); row++) {
978 bands[4*(row)+1] -= bands[4*(row)+0]*bands[4*(row-1)+2];
979 bands[4*(row)+3] -= bands[4*(row)+0]*bands[4*(row-1)+3];
980 bands[4*(row)+2] /= bands[4*(row)+1];
981 bands[4*(row)+3] /= bands[4*(row)+1];
982 bands[4*(row)+0] = 0.0;
983 bands[4*(row)+1] = 1.0;
984 }
985
986 // Do last row
987 bands[4*(M+1)+1] -= bands[4*(M+1)+0]*bands[4*(M-1)+2];
988 bands[4*(M+1)+3] -= bands[4*(M+1)+0]*bands[4*(M-1)+3];
989 bands[4*(M+1)+2] -= bands[4*(M+1)+1]*bands[4*(M)+2];
990 bands[4*(M+1)+3] -= bands[4*(M+1)+1]*bands[4*(M)+3];
991 bands[4*(M+1)+3] /= bands[4*(M+1)+2];
992 bands[4*(M+1)+2] = 1.0;
993
994 coefs[(M+1)*cstride] = bands[4*(M+1)+3];
995 // Now back substitute up
996 for (int row=M; row>0; row--)
997 coefs[row*cstride] = bands[4*(row)+3] - bands[4*(row)+2]*coefs[cstride*(row+1)];
998
999 // Finish with first row
1000 coefs[0] = bands[4*(0)+3] - bands[4*(0)+1]*coefs[1*cstride] - bands[4*(0)+2]*coefs[2*cstride];
1001}

◆ solve_deriv_interp_1d_s()

void solve_deriv_interp_1d_s ( float bands[],
float coefs[],
int M,
int cstride )

Definition at line 47 of file bspline_create.cpp.

49{
50 // Solve interpolating equations
51 // First and last rows are different
52 bands[4*(0)+1] /= bands[4*(0)+0];
53 bands[4*(0)+2] /= bands[4*(0)+0];
54 bands[4*(0)+3] /= bands[4*(0)+0];
55 bands[4*(0)+0] = 1.0;
56 bands[4*(1)+1] -= bands[4*(1)+0]*bands[4*(0)+1];
57 bands[4*(1)+2] -= bands[4*(1)+0]*bands[4*(0)+2];
58 bands[4*(1)+3] -= bands[4*(1)+0]*bands[4*(0)+3];
59 bands[4*(0)+0] = 0.0;
60 bands[4*(1)+2] /= bands[4*(1)+1];
61 bands[4*(1)+3] /= bands[4*(1)+1];
62 bands[4*(1)+1] = 1.0;
63
64 // Now do rows 2 through M+1
65 for (int row=2; row < (M+1); row++) {
66 bands[4*(row)+1] -= bands[4*(row)+0]*bands[4*(row-1)+2];
67 bands[4*(row)+3] -= bands[4*(row)+0]*bands[4*(row-1)+3];
68 bands[4*(row)+2] /= bands[4*(row)+1];
69 bands[4*(row)+3] /= bands[4*(row)+1];
70 bands[4*(row)+0] = 0.0;
71 bands[4*(row)+1] = 1.0;
72 }
73
74 // Do last row
75 bands[4*(M+1)+1] -= bands[4*(M+1)+0]*bands[4*(M-1)+2];
76 bands[4*(M+1)+3] -= bands[4*(M+1)+0]*bands[4*(M-1)+3];
77 bands[4*(M+1)+2] -= bands[4*(M+1)+1]*bands[4*(M)+2];
78 bands[4*(M+1)+3] -= bands[4*(M+1)+1]*bands[4*(M)+3];
79 bands[4*(M+1)+3] /= bands[4*(M+1)+2];
80 bands[4*(M+1)+2] = 1.0;
81
82 coefs[(M+1)*cstride] = bands[4*(M+1)+3];
83 // Now back substitute up
84 for (int row=M; row>0; row--)
85 coefs[row*cstride] = bands[4*(row)+3] - bands[4*(row)+2]*coefs[cstride*(row+1)];
86
87 // Finish with first row
88 coefs[0] = bands[4*(0)+3] - bands[4*(0)+1]*coefs[1*cstride] - bands[4*(0)+2]*coefs[2*cstride];
89}

◆ solve_periodic_interp_1d_d()

void solve_periodic_interp_1d_d ( double bands[],
double coefs[],
int M,
int cstride )

Definition at line 1010 of file bspline_create.cpp.

1012{
1013 std::vector<double> lastCol(M);
1014
1015 // Now solve:
1016 // First and last rows are different
1017 bands[4*(0)+2] /= bands[4*(0)+1];
1018 bands[4*(0)+0] /= bands[4*(0)+1];
1019 bands[4*(0)+3] /= bands[4*(0)+1];
1020 bands[4*(0)+1] = 1.0;
1021 bands[4*(M-1)+1] -= bands[4*(M-1)+2]*bands[4*(0)+0];
1022 bands[4*(M-1)+3] -= bands[4*(M-1)+2]*bands[4*(0)+3];
1023 bands[4*(M-1)+2] = -bands[4*(M-1)+2]*bands[4*(0)+2];
1024 lastCol[0] = bands[4*(0)+0];
1025
1026 for (int row=1; row < (M-1); row++) {
1027 bands[4*(row)+1] -= bands[4*(row)+0] * bands[4*(row-1)+2];
1028 bands[4*(row)+3] -= bands[4*(row)+0] * bands[4*(row-1)+3];
1029 lastCol[row] = -bands[4*(row)+0] * lastCol[row-1];
1030 bands[4*(row)+0] = 0.0;
1031 bands[4*(row)+2] /= bands[4*(row)+1];
1032 bands[4*(row)+3] /= bands[4*(row)+1];
1033 lastCol[row] /= bands[4*(row)+1];
1034 bands[4*(row)+1] = 1.0;
1035 if (row < (M-2)) {
1036 bands[4*(M-1)+3] -= bands[4*(M-1)+2]*bands[4*(row)+3];
1037 bands[4*(M-1)+1] -= bands[4*(M-1)+2]*lastCol[row];
1038 bands[4*(M-1)+2] = -bands[4*(M-1)+2]*bands[4*(row)+2];
1039 }
1040 }
1041
1042 // Now do last row
1043 // The [2] element and [0] element are now on top of each other
1044 bands[4*(M-1)+0] += bands[4*(M-1)+2];
1045 bands[4*(M-1)+1] -= bands[4*(M-1)+0] * (bands[4*(M-2)+2]+lastCol[M-2]);
1046 bands[4*(M-1)+3] -= bands[4*(M-1)+0] * bands[4*(M-2)+3];
1047 bands[4*(M-1)+3] /= bands[4*(M-1)+1];
1048 coefs[M*cstride] = bands[4*(M-1)+3];
1049 for (int row=M-2; row>=0; row--)
1050 coefs[(row+1)*cstride] =
1051 bands[4*(row)+3] - bands[4*(row)+2]*coefs[(row+2)*cstride] - lastCol[row]*coefs[M*cstride];
1052
1053 coefs[0*cstride] = coefs[M*cstride];
1054 coefs[(M+1)*cstride] = coefs[1*cstride];
1055 coefs[(M+2)*cstride] = coefs[2*cstride];
1056}

◆ solve_periodic_interp_1d_s()

void solve_periodic_interp_1d_s ( float bands[],
float coefs[],
int M,
int cstride )

Definition at line 98 of file bspline_create.cpp.

100{
101 std::vector<float> lastCol(M);
102
103 // Now solve:
104 // First and last rows are different
105 bands[4*(0)+2] /= bands[4*(0)+1];
106 bands[4*(0)+0] /= bands[4*(0)+1];
107 bands[4*(0)+3] /= bands[4*(0)+1];
108 bands[4*(0)+1] = 1.0;
109 bands[4*(M-1)+1] -= bands[4*(M-1)+2]*bands[4*(0)+0];
110 bands[4*(M-1)+3] -= bands[4*(M-1)+2]*bands[4*(0)+3];
111 bands[4*(M-1)+2] = -bands[4*(M-1)+2]*bands[4*(0)+2];
112 lastCol[0] = bands[4*(0)+0];
113
114 for (int row=1; row < (M-1); row++) {
115 bands[4*(row)+1] -= bands[4*(row)+0] * bands[4*(row-1)+2];
116 bands[4*(row)+3] -= bands[4*(row)+0] * bands[4*(row-1)+3];
117 lastCol[row] = -bands[4*(row)+0] * lastCol[row-1];
118 bands[4*(row)+0] = 0.0;
119 bands[4*(row)+2] /= bands[4*(row)+1];
120 bands[4*(row)+3] /= bands[4*(row)+1];
121 lastCol[row] /= bands[4*(row)+1];
122 bands[4*(row)+1] = 1.0;
123 if (row < (M-2)) {
124 bands[4*(M-1)+3] -= bands[4*(M-1)+2]*bands[4*(row)+3];
125 bands[4*(M-1)+1] -= bands[4*(M-1)+2]*lastCol[row];
126 bands[4*(M-1)+2] = -bands[4*(M-1)+2]*bands[4*(row)+2];
127 }
128 }
129
130 // Now do last row
131 // The [2] element and [0] element are now on top of each other
132 bands[4*(M-1)+0] += bands[4*(M-1)+2];
133 bands[4*(M-1)+1] -= bands[4*(M-1)+0] * (bands[4*(M-2)+2]+lastCol[M-2]);
134 bands[4*(M-1)+3] -= bands[4*(M-1)+0] * bands[4*(M-2)+3];
135 bands[4*(M-1)+3] /= bands[4*(M-1)+1];
136 coefs[M*cstride] = bands[4*(M-1)+3];
137 for (int row=M-2; row>=0; row--)
138 coefs[(row+1)*cstride] =
139 bands[4*(row)+3] - bands[4*(row)+2]*coefs[(row+2)*cstride] - lastCol[row]*coefs[M*cstride];
140
141 coefs[0*cstride] = coefs[M*cstride];
142 coefs[(M+1)*cstride] = coefs[1*cstride];
143 coefs[(M+2)*cstride] = coefs[2*cstride];
144
145
146}