@@ -19,12 +19,12 @@ cdef extern from "_rTE.h" namespace "funcs":
1919 double * frequencies,
2020 double * lambdas,
2121 complex_t * sigmas,
22- double * mus,
22+ complex_t * mus,
2323 double * thicks,
2424 SIZE_t n_frequency,
2525 SIZE_t n_filter,
2626 SIZE_t n_layers
27- ) nogil
27+ ) noexcept nogil
2828
2929 void rTEgrad(
3030 complex_t * TE_dsigma,
@@ -33,12 +33,12 @@ cdef extern from "_rTE.h" namespace "funcs":
3333 double * frequencies,
3434 double * lambdas,
3535 complex_t * sigmas,
36- double * mus,
36+ complex_t * mus,
3737 double * h,
3838 SIZE_t n_frequency,
3939 SIZE_t n_filter,
4040 SIZE_t n_layers
41- ) nogil
41+ ) noexcept nogil
4242
4343def rTE_forward (frequencies , lamb , sigma , mu , thicknesses ):
4444 """ Compute reflection coefficients for Transverse Electric (TE) mode.
@@ -67,7 +67,7 @@ def rTE_forward(frequencies, lamb, sigma, mu, thicknesses):
6767 """
6868 # Sigma and mu must be fortran contiguous
6969 sigma = np.require(sigma, dtype = np.complex128, requirements = " F" )
70- mu = np.require(mu, dtype = np.float64 , requirements = " F" )
70+ mu = np.require(mu, dtype = np.complex128 , requirements = " F" )
7171
7272 # These just must be contiguous
7373 lamb = np.require(lamb, dtype = np.float64, requirements = " C" )
@@ -92,7 +92,7 @@ def rTE_forward(frequencies, lamb, sigma, mu, thicknesses):
9292 REAL_t[:] f = frequencies
9393 REAL_t[:] lam = lamb
9494 COMPLEX_t[:, :] sig = sigma
95- REAL_t [:, :] c_mu = mu
95+ COMPLEX_t [:, :] c_mu = mu
9696 REAL_t[:] hs = thicknesses
9797
9898 cdef:
@@ -109,12 +109,13 @@ def rTE_forward(frequencies, lamb, sigma, mu, thicknesses):
109109 # Types are same size and both pairs of numbers (r, i), so can cast one to the other
110110 complex_t * out_p = < complex_t * > & out[0 , 0 ]
111111 complex_t * sig_p = < complex_t * > & sig[0 , 0 ]
112+ complex_t * mu_p = < complex_t * > & c_mu[0 , 0 ]
112113 REAL_t * h_p = NULL
113114 if n_layers > 1 :
114115 h_p = & hs[0 ]
115116
116117 with nogil:
117- rTE(out_p, & f[0 ], & lam[0 ], sig_p, & c_mu[ 0 , 0 ] , h_p,
118+ rTE(out_p, & f[0 ], & lam[0 ], sig_p, mu_p , h_p,
118119 n_frequency, n_filter, n_layers)
119120
120121 return np.array(out)
@@ -153,7 +154,7 @@ def rTE_gradient(frequencies, lamb, sigma, mu, thicknesses):
153154 """
154155 # Require that they are all the same ordering as sigma
155156 sigma = np.require(sigma, dtype = np.complex128, requirements = " F" )
156- mu = np.require(mu, dtype = np.float64 , requirements = " F" )
157+ mu = np.require(mu, dtype = np.complex128 , requirements = " F" )
157158 lamb = np.require(lamb, dtype = np.float64, requirements = " C" )
158159 frequencies = np.require(frequencies, dtype = np.float64, requirements = " C" )
159160 thicknesses = np.require(thicknesses, dtype = np.float64, requirements = " C" )
@@ -176,7 +177,7 @@ def rTE_gradient(frequencies, lamb, sigma, mu, thicknesses):
176177 REAL_t[:] f = frequencies
177178 REAL_t[:] lam = lamb
178179 COMPLEX_t[:, :] sig = sigma
179- REAL_t [:, :] c_mu = mu
180+ COMPLEX_t [:, :] c_mu = mu
180181 REAL_t[:] hs = thicknesses
181182
182183 cdef:
@@ -194,6 +195,7 @@ def rTE_gradient(frequencies, lamb, sigma, mu, thicknesses):
194195 cdef:
195196 # Types are same size and both pairs of numbers (r, i), so can cast one to the other
196197 complex_t * sig_p = < complex_t * > & sig[0 , 0 ]
198+ complex_t * mu_p = < complex_t * > & c_mu[0 , 0 ]
197199 complex_t * gsig_p = < complex_t * > & gsig[0 , 0 , 0 ]
198200 complex_t * gmu_p = < complex_t * > & gmu[0 , 0 , 0 ]
199201 complex_t * gh_p = NULL
@@ -203,7 +205,7 @@ def rTE_gradient(frequencies, lamb, sigma, mu, thicknesses):
203205 gh_p = < complex_t * > & gh[0 , 0 , 0 ]
204206
205207 with nogil:
206- rTEgrad(gsig_p, gmu_p, gh_p, & f[0 ], & lam[0 ], sig_p, & c_mu[ 0 , 0 ] , h_p,
208+ rTEgrad(gsig_p, gmu_p, gh_p, & f[0 ], & lam[0 ], sig_p, mu_p , h_p,
207209 n_frequency, n_filter, n_layers)
208210
209211 return np.array(gsig), np.array(gh), np.array(gmu)
0 commit comments