Commit 775fa40a authored by Daniel Brown's avatar Daniel Brown
Browse files

adding in complex factor * vector fill function

parent 727aca76
......@@ -145,6 +145,9 @@ cdef class SubCCSView:
cdef void fill_negative_za_dd(self, complex_t a, double[::1] D)
cdef void fill_negative_zd_2(self, const complex_t* D, int s1) nogil
cdef void fill_negative_za_zd_2(self, complex_t a, const complex_t* D, int stride) nogil
cdef void fill_negative_za_zv(self, complex_t a, DenseZVector* V)
cdef void fill_negative_za_zm(self, complex_t a, complex_t[:,::1] M)
cdef void fill_negative_za_zm_2(self, complex_t a, DenseZMatrix* M)
cdef void fill_negative_za_zmc(self, complex_t a, const complex_t* M, int s1, int s2)
......
......@@ -689,6 +689,9 @@ cdef class SubCCSView:
cdef void fill_negative_za_zd_2(self, complex_t a, const complex_t* D, int stride) nogil:
raise NotImplementedError()
cdef void fill_negative_za_zv(self, complex_t a, DenseZVector*V):
raise NotImplementedError()
cdef void fill_negative_za_zm(self, complex_t a, complex_t[:,::1] M):
raise NotImplementedError()
......@@ -1038,6 +1041,28 @@ cdef class SubCCSMatrixView(SubCCSView):
cdef void fill_negative_za(self, complex_t a):
self.fill_za(-a)
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
cdef void fill_negative_za_zv(self, complex_t a, DenseZVector*V):
cdef int i, j
cdef Py_ssize_t stride
assert(self.size1 == 1 or self.size2 == 1) # this view must be a row/col vector
if self.size1 == V.size:
stride = self.stride1
elif self.size2 == V.size:
stride = self.stride2
else:
raise Exception(f"Wrong dimensions for vector fill in {self.name}")
a = -a # do negative fill
if self.conjugate_fill:
for i in range(self.size1):
self.ptr[i*stride] = conj(a * V.ptr[i*V.stride])
else:
for i in range(self.size1):
self.ptr[i*stride] = a * V.ptr[i*V.stride]
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
......
......@@ -157,7 +157,6 @@ cdef object c_laser_fill_signal(ConnectorWorkspace cws):
complex_t frq_sig
frequency_info_t *f
complex_t* car
DenseZVector c_p1_o
NodeBeamParam *q_P1o
double w
......@@ -167,28 +166,27 @@ cdef object c_laser_fill_signal(ConnectorWorkspace cws):
c_p1_o.size = ws.sim.model_data.num_HOMs
c_p1_o.stride = 1
for i in range(2):
for i in range(2): # Loop over each signal sideband
f = &ws.sim.signal.optical_frequencies.frequency_info[ws.fcar_sig_sb_idx[i]]
# NOTE shouldn't need multiplication by corresponding power_coeff
# factor as this was taken into account in DC computations
# Update this so that frequency rhs idx is store in workspace
j = ws.sim.carrier.field_fast(ws.node_car_id, f.audio_carrier_index, 0)
car = <complex_t*>&(ws.sim.carrier.out_view[j])
c_p1_o.ptr = car
c_p1_o.ptr = <complex_t*>&(ws.sim.carrier.out_view[j])
# TODO ddb - these are all assuming a single electronic frequency here, hence first 0 index
if conns.SIGAMP_P1o[0][f.index]:
(<SubCCSView>conns.SIGAMP_P1o[0][f.index]).fill_negative_za_zm_2(factor * 0.5 * 0.5, car, 1, 1)
(<SubCCSView>conns.SIGAMP_P1o[0][f.index]).fill_negative_za_zv(factor * 0.5 * 0.5, &c_p1_o)
if conns.SIGFRQ_P1o[0][f.index]:
frq_sig = 0.5 / ws.sim.model_data.fsig * sgn(f.audio_order)
(<SubCCSView>conns.SIGFRQ_P1o[0][f.index]).fill_negative_za_zm_2(factor * frq_sig, car, 1, 1)
(<SubCCSView>conns.SIGFRQ_P1o[0][f.index]).fill_negative_za_zv(factor * frq_sig, &c_p1_o)
if conns.SIGPHS_P1o[0][f.index]:
phs_sig = 1j * 0.5
(<SubCCSView>conns.SIGPHS_P1o[0][f.index]).fill_negative_za_zm_2(factor * phs_sig, car, 1, 1)
(<SubCCSView>conns.SIGPHS_P1o[0][f.index]).fill_negative_za_zv(factor * phs_sig, &c_p1_o)
if conns.dz_P1o[0][f.index]:
(<SubCCSView>conns.dz_P1o[0][f.index]).fill_negative_za_zm_2(0.5j * k * factor, car, 1, 1)
(<SubCCSView>conns.dz_P1o[0][f.index]).fill_negative_za_zv(0.5j * k * factor, &c_p1_o)
if conns.dx_P1o[0][f.index] or conns.xbeta_P1o[0][f.index]:
q_P1o = &ws.sim.trace[ws.P1o_id]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment