-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from DanielKotik/develop
Merge `develop` into `master`
- Loading branch information
Showing
10 changed files
with
196 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from .helpers cimport Beam2d, _complex_quad | ||
|
||
# ----------------------------------------------------------------------------- | ||
# declare C functions as "cpdef" to export them to the module | ||
# ----------------------------------------------------------------------------- | ||
cdef extern from "math.h": | ||
cpdef double _exp "exp" (double x) nogil | ||
cpdef double _sqrt "sqrt" (double x) nogil | ||
|
||
cdef extern from "complex.h": | ||
cpdef double complex _cexp "cexp" (double complex z) nogil | ||
|
||
# ----------------------------------------------------------------------------- | ||
# function declarations | ||
# ----------------------------------------------------------------------------- | ||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
# class declarations | ||
# ----------------------------------------------------------------------------- | ||
cdef class Beam2dCartesian(Beam2d): | ||
cdef: | ||
double _ry, _rz | ||
|
||
cdef double complex spectrum(self, double k_y) nogil | ||
cdef double _phase(self, double k_y, double x, double y) nogil | ||
cdef double complex _integrand(self, double k_y) nogil | ||
|
||
cdef class Gauss2d(Beam2dCartesian): | ||
cdef: | ||
double _W_y | ||
double _norm | ||
|
||
cdef double _f_Gauss(self, double k_y, double W_y) nogil | ||
cdef double complex spectrum(self, double k_y) nogil | ||
|
||
cdef class IncAiry2d(Beam2dCartesian): | ||
cdef: | ||
double _W_y | ||
double _M | ||
double _W | ||
double xi | ||
|
||
cdef double _heaviside(self, double x) nogil | ||
cdef double complex _f_Airy(self, double k_y, double W_y, double M, double W) nogil | ||
cdef double complex spectrum(self, double k_y) nogil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cimport cython | ||
from cpython.pycapsule cimport PyCapsule_New | ||
from cpython cimport bool | ||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
# function declarations | ||
# ----------------------------------------------------------------------------- | ||
cdef double _imag_1d_func_c(int n, double *arr, void *func_ptr) | ||
cdef double _real_1d_func_c(int n, double *arr, void *func_ptr) | ||
|
||
@cython.locals(real=cython.double, imag=cython.double, real_tol=cython.double, | ||
imag_tol=cython.double) | ||
cpdef (double complex, double, double) _complex_quad(func, double a, double b, dict kwargs=*) | ||
|
||
# ----------------------------------------------------------------------------- | ||
# class declarations | ||
# ----------------------------------------------------------------------------- | ||
cdef class Beam2d: | ||
cdef: | ||
dict __dict__ | ||
double x, _k | ||
public bool called | ||
|
||
cdef double complex _integrand(self, double x) nogil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from .helpers cimport Beam3d, _complex_dblquad | ||
|
||
# ----------------------------------------------------------------------------- | ||
# declare C functions as "cpdef" to export them to the module | ||
# ----------------------------------------------------------------------------- | ||
# TODO: check why we use cpdef and not cdef | ||
cdef extern from "stdlib.h": | ||
cpdef int _abs "abs" (int n) nogil | ||
|
||
cdef extern from "math.h": | ||
cpdef double _sin "sin" (double x) nogil | ||
cpdef double _cos "cos" (double x) nogil | ||
cpdef double _exp "exp" (double x) nogil | ||
cpdef double _acos "acos" (double x) nogil | ||
cpdef double _atan2 "atan2" (double y, double x) nogil | ||
|
||
cdef extern from "complex.h": | ||
cpdef double complex _cexp "cexp" (double complex z) nogil | ||
cpdef double complex _csqrt "csqrt" (double complex z) nogil | ||
|
||
# ----------------------------------------------------------------------------- | ||
# function declarations | ||
# ----------------------------------------------------------------------------- | ||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
# class declarations | ||
# ----------------------------------------------------------------------------- | ||
cdef class Beam3dSpherical(Beam3d): | ||
cdef: | ||
double _ry, _rz | ||
|
||
cdef double _phase(self, double sin_theta, double cos_theta, double phi, | ||
double x, double y, double z) nogil | ||
# TODO: check if next line is actually needed since we can declared in Beam3d | ||
cdef double complex spectrum(self, double sin_theta, double theta, double phi) nogil | ||
# TODO: check if next line is actually needed since it is declared in Beam3d | ||
cdef double complex _integrand(self, double theta, double phi) nogil | ||
|
||
cdef class Beam3dCartesian(Beam3d): | ||
cdef: | ||
double _ry, _rz | ||
|
||
cdef double _phase(self, double k_y, double k_z, double x, double y, double z) nogil | ||
cdef double complex spectrum(self, double k_y, double k_z) nogil | ||
cdef double complex _integrand(self, double k_y, double k_z) nogil | ||
|
||
cdef class LaguerreGauss3d(Beam3dSpherical): | ||
cdef: | ||
int _m | ||
double _W_y | ||
double _norm | ||
|
||
cdef double complex _f_Gauss_spherical(self, double sin_theta, double _W_y, double k) nogil | ||
cdef double complex _f_Laguerre_Gauss_spherical(self, double sin_theta, double theta, double phi, | ||
double _W_y, double k, int _m) nogil | ||
cdef double complex spectrum(self, double sin_theta, double theta, double phi) nogil | ||
|
||
cdef class LaguerreGauss3dCartesian(Beam3dCartesian): | ||
cdef: | ||
int _m | ||
double _W_y | ||
double _norm | ||
|
||
cdef double _phi(self, double k_y, double k_z) nogil | ||
cdef double _theta(self, double k_y, double k_z, double k) nogil | ||
cdef double complex _f_Gauss_cartesian(self, double k_y, double k_z, double _W_y) nogil | ||
cdef double complex _f_Laguerre_Gauss_cartesian(self, double k_y, double k_z, | ||
double _W_y, double k, int _m) nogil | ||
cdef double complex spectrum(self, double k_y, double k_z) nogil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
cimport cython | ||
from cpython.pycapsule cimport PyCapsule_New | ||
from cpython cimport bool | ||
|
||
# ----------------------------------------------------------------------------- | ||
# function declarations | ||
# ----------------------------------------------------------------------------- | ||
cdef double _imag_2d_func_c(int n, double *arr, void *func_ptr) | ||
cdef double _real_2d_func_c(int n, double *arr, void *func_ptr) | ||
|
||
@cython.locals(real=cython.double, imag=cython.double, real_tol=cython.double, | ||
imag_tol=cython.double) | ||
cpdef (double complex, double, double) _complex_dblquad(Beam3d func, | ||
double a, double b, | ||
double gfun, double hfun, | ||
dict kwargs=*) | ||
|
||
# ----------------------------------------------------------------------------- | ||
# class declarations | ||
# ----------------------------------------------------------------------------- | ||
cdef class Beam3d: | ||
cdef: | ||
dict __dict__ | ||
double x, _k | ||
public bool called | ||
|
||
cdef double complex _integrand(self, double x, double y) nogil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel", "Cython"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters