acoular 23.6__py3-none-any.whl → 24.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- acoular/__init__.py +2 -2
- acoular/configuration.py +37 -1
- acoular/environments.py +15 -9
- acoular/fastFuncs.py +199 -472
- acoular/fbeamform.py +168 -109
- acoular/grids.py +33 -114
- acoular/sources.py +77 -3
- acoular/spectra.py +2 -2
- acoular/tbeamform.py +15 -8
- acoular/tests/reference_data/BeamformerBaseFalse1.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseFalse2.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseFalse3.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseFalse4.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue1.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue2.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue3.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue4.npy +0 -0
- acoular/tests/reference_data/BeamformerCMFLassoLarsBIC.npy +0 -0
- acoular/tests/reference_data/BeamformerCMFNNLS.npy +0 -0
- acoular/tests/reference_data/BeamformerCleantSqTraj.npy +0 -0
- acoular/tests/reference_data/BeamformerCleantTraj.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse1.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse2.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse3.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse4.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue1.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue2.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue3.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue4.npy +0 -0
- acoular/tests/reference_data/BeamformerGIB.npy +0 -0
- acoular/tests/reference_data/BeamformerSODIX.npy +0 -0
- acoular/tests/reference_data/FiltFiltOctave__.npy +0 -0
- acoular/tests/reference_data/FiltFiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
- acoular/tests/reference_data/FiltFreqWeight_weight_A_.npy +0 -0
- acoular/tests/reference_data/FiltFreqWeight_weight_C_.npy +0 -0
- acoular/tests/reference_data/FiltFreqWeight_weight_Z_.npy +0 -0
- acoular/tests/reference_data/FiltOctave__.npy +0 -0
- acoular/tests/reference_data/FiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
- acoular/tests/reference_data/Filter__.npy +0 -0
- acoular/tests/reference_data/OctaveFilterBank__.npy +0 -0
- acoular/tests/reference_data/TimeAverage__.npy +0 -0
- acoular/tests/reference_data/TimeCumAverage__.npy +0 -0
- acoular/tests/reference_data/TimeExpAverage_weight_F_.npy +0 -0
- acoular/tests/reference_data/TimeExpAverage_weight_I_.npy +0 -0
- acoular/tests/reference_data/TimeExpAverage_weight_S_.npy +0 -0
- acoular/tests/reference_data/TimeInOut__.npy +0 -0
- acoular/tests/reference_data/TimePower__.npy +0 -0
- acoular/tests/reference_data/TimeReverse__.npy +0 -0
- acoular/tests/test_beamformer_results.py +39 -8
- acoular/tests/test_grid.py +92 -0
- acoular/tests/test_integrate.py +102 -0
- acoular/tests/test_tprocess.py +52 -0
- acoular/tests/test_traj_beamformer_results.py +2 -2
- acoular/tfastfuncs.py +24 -25
- acoular/tools.py +144 -2
- acoular/tprocess.py +91 -102
- acoular/version.py +2 -2
- acoular-24.3.dist-info/METADATA +181 -0
- {acoular-23.6.dist-info → acoular-24.3.dist-info}/RECORD +62 -25
- {acoular-23.6.dist-info → acoular-24.3.dist-info}/WHEEL +1 -1
- {acoular-23.6.dist-info → acoular-24.3.dist-info}/licenses/LICENSE +1 -1
- acoular/tests/reference_data/BeamformerCMF.npy +0 -0
- acoular-23.6.dist-info/METADATA +0 -82
- {acoular-23.6.dist-info → acoular-24.3.dist-info}/licenses/AUTHORS.rst +0 -0
acoular/fastFuncs.py
CHANGED
|
@@ -16,8 +16,8 @@ fastOption = True # fastmath options
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
# Formerly known as 'faverage'
|
|
19
|
-
@nb.njit([nb.complex128[
|
|
20
|
-
nb.complex64[
|
|
19
|
+
@nb.njit([nb.complex128[:,:,::1](nb.complex128[:,:,::1], nb.complex128[:,::1]),
|
|
20
|
+
nb.complex64[:,:,::1](nb.complex64[:,:,::1], nb.complex64[:,::1])], cache=cachedOption, parallel=True, fastmath=fastOption)
|
|
21
21
|
def calcCSM(csm, SpecAllMics):
|
|
22
22
|
""" Adds a given spectrum to the Cross-Spectral-Matrix (CSM).
|
|
23
23
|
Here only the upper triangular matrix of the CSM is calculated. After
|
|
@@ -37,13 +37,6 @@ def calcCSM(csm, SpecAllMics):
|
|
|
37
37
|
-------
|
|
38
38
|
None : as the input csm gets overwritten.
|
|
39
39
|
"""
|
|
40
|
-
#==============================================================================
|
|
41
|
-
# It showed, that parallelizing brings no benefit when calling calcCSM once per
|
|
42
|
-
# ensemble (as its done at the moment). BUT it could be whorth, taking a closer
|
|
43
|
-
# look to parallelization, when averaging over all ensembles inside this numba
|
|
44
|
-
# optimized function. See "vglOptimierungFAverage.py" for some information on
|
|
45
|
-
# the various implementations and their limitations.
|
|
46
|
-
#==============================================================================
|
|
47
40
|
nFreqs = csm.shape[0]
|
|
48
41
|
nMics = csm.shape[1]
|
|
49
42
|
for cntFreq in nb.prange(nFreqs):
|
|
@@ -137,38 +130,19 @@ def beamformerFreq(steerVecType, boolRemovedDiagOfCSM, normFactor, inputTupleSte
|
|
|
137
130
|
"""
|
|
138
131
|
boolIsEigValProb = isinstance(inputTupleCsm, tuple)# len(inputTupleCsm) > 1
|
|
139
132
|
# get the beamformer type (key-tuple = (isEigValProblem, formulationOfSteeringVector, RemovalOfCSMDiag))
|
|
140
|
-
beamformerDict = {(False, '
|
|
141
|
-
(False, 'classic', True) : _freqBeamformer_Formulation1AkaClassic_CsmRemovedDiag,
|
|
142
|
-
(False, 'inverse', False) : _freqBeamformer_Formulation2AkaInverse_FullCSM,
|
|
143
|
-
(False, 'inverse', True) : _freqBeamformer_Formulation2AkaInverse_CsmRemovedDiag,
|
|
144
|
-
(False, 'true level', False) : _freqBeamformer_Formulation3AkaTrueLevel_FullCSM,
|
|
145
|
-
(False, 'true level', True) : _freqBeamformer_Formulation3AkaTrueLevel_CsmRemovedDiag,
|
|
146
|
-
(False, 'true location', False) : _freqBeamformer_Formulation4AkaTrueLocation_FullCSM,
|
|
147
|
-
(False, 'true location', True) : _freqBeamformer_Formulation4AkaTrueLocation_CsmRemovedDiag,
|
|
148
|
-
(False, 'custom', False) : _freqBeamformer_SpecificSteerVec_FullCSM,
|
|
133
|
+
beamformerDict = {(False, 'custom', False) : _freqBeamformer_SpecificSteerVec_FullCSM,
|
|
149
134
|
(False, 'custom', True) : _freqBeamformer_SpecificSteerVec_CsmRemovedDiag,
|
|
150
|
-
(True, 'classic', False) : _freqBeamformer_EigValProb_Formulation1AkaClassic_FullCSM,
|
|
151
|
-
(True, 'classic', True) : _freqBeamformer_EigValProb_Formulation1AkaClassic_CsmRemovedDiag,
|
|
152
|
-
(True, 'inverse', False) : _freqBeamformer_EigValProb_Formulation2AkaInverse_FullCSM,
|
|
153
|
-
(True, 'inverse', True) : _freqBeamformer_EigValProb_Formulation2AkaInverse_CsmRemovedDiag,
|
|
154
|
-
(True, 'true level', False) : _freqBeamformer_EigValProb_Formulation3AkaTrueLevel_FullCSM,
|
|
155
|
-
(True, 'true level', True) : _freqBeamformer_EigValProb_Formulation3AkaTrueLevel_CsmRemovedDiag,
|
|
156
|
-
(True, 'true location', False) : _freqBeamformer_EigValProb_Formulation4AkaTrueLocation_FullCSM,
|
|
157
|
-
(True, 'true location', True) : _freqBeamformer_EigValProb_Formulation4AkaTrueLocation_CsmRemovedDiag,
|
|
158
135
|
(True, 'custom', False) : _freqBeamformer_EigValProb_SpecificSteerVec_FullCSM,
|
|
159
136
|
(True, 'custom', True) : _freqBeamformer_EigValProb_SpecificSteerVec_CsmRemovedDiag}
|
|
160
|
-
|
|
161
|
-
|
|
137
|
+
sth = {'classic':1, 'inverse':2,'true level':3, 'true location':4}
|
|
162
138
|
|
|
163
139
|
# prepare Input
|
|
164
140
|
if steerVecType == 'custom': # beamformer with custom steering vector
|
|
165
141
|
steerVec = inputTupleSteer
|
|
166
|
-
#nFreqs, nGridPoints = steerVec.shape[0], steerVec.shape[1]
|
|
167
142
|
nGridPoints = steerVec.shape[0]
|
|
168
143
|
else: # predefined beamformers (Formulation I - IV)
|
|
169
|
-
distGridToArrayCenter, distGridToAllMics, waveNumber = inputTupleSteer
|
|
170
|
-
if not isinstance(waveNumber, np.ndarray): waveNumber = np.array([waveNumber])
|
|
171
|
-
#nFreqs, nGridPoints = waveNumber.shape[0], distGridToAllMics.shape[0]
|
|
144
|
+
distGridToArrayCenter, distGridToAllMics, waveNumber = inputTupleSteer
|
|
145
|
+
if not isinstance(waveNumber, np.ndarray): waveNumber = np.array([waveNumber]) #for backward compatibility
|
|
172
146
|
nGridPoints = distGridToAllMics.shape[0]
|
|
173
147
|
if boolIsEigValProb:
|
|
174
148
|
eigVal, eigVec = inputTupleCsm#[0], inputTupleCsm[1]
|
|
@@ -181,230 +155,213 @@ def beamformerFreq(steerVecType, boolRemovedDiagOfCSM, normFactor, inputTupleSte
|
|
|
181
155
|
result = np.zeros(nGridPoints, np.float64)
|
|
182
156
|
normalHelp = np.zeros_like(result)
|
|
183
157
|
if steerVecType == 'custom': # beamformer with custom steering vector
|
|
158
|
+
coreFunc = beamformerDict[(boolIsEigValProb, steerVecType, boolRemovedDiagOfCSM)]
|
|
184
159
|
if boolIsEigValProb:
|
|
185
160
|
coreFunc(eigVal, eigVec, steerVec, normFactor, result, normalHelp)
|
|
186
161
|
else:
|
|
187
162
|
coreFunc(csm, steerVec, normFactor, result, normalHelp)
|
|
188
163
|
else: # predefined beamformers (Formulation I - IV)
|
|
189
164
|
if boolIsEigValProb:
|
|
190
|
-
|
|
165
|
+
_freqBeamformer_EigValues(eigVal, np.ascontiguousarray(eigVec), distGridToArrayCenter, distGridToAllMics, waveNumber[0], normFactor,
|
|
166
|
+
boolRemovedDiagOfCSM, sth[steerVecType],
|
|
167
|
+
result, normalHelp)
|
|
191
168
|
else:
|
|
192
|
-
|
|
169
|
+
_freqBeamformer_FullCSM(csm, distGridToArrayCenter, distGridToAllMics, waveNumber[0], normFactor,
|
|
170
|
+
boolRemovedDiagOfCSM, sth[steerVecType],
|
|
171
|
+
result, normalHelp)
|
|
193
172
|
beamformOutput = result
|
|
194
173
|
steerNormalizeOutput = normalHelp
|
|
195
174
|
return beamformOutput, steerNormalizeOutput
|
|
196
175
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
228
|
-
nMics = csm.shape[0]
|
|
229
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
230
|
-
|
|
231
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
232
|
-
for cntMics in range(nMics):
|
|
233
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
234
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg))
|
|
235
|
-
|
|
236
|
-
# performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq')
|
|
237
|
-
scalarProd = 0.0
|
|
238
|
-
for cntMics in range(nMics):
|
|
239
|
-
leftVecMatrixProd = 0.0 + 0.0j
|
|
240
|
-
for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
|
|
241
|
-
leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
|
|
242
|
-
scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
|
|
243
|
-
normalizeFactor = nMics # specific normalization of steering vector formulation
|
|
244
|
-
normalizeSteer[0] = 1.0 / nMics
|
|
245
|
-
result[0] = scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
@nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
249
|
-
'(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
250
|
-
def _freqBeamformer_Formulation2AkaInverse_FullCSM(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
251
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
252
|
-
nMics = csm.shape[0]
|
|
253
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
254
|
-
|
|
255
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
256
|
-
helpNormalize = 0.0
|
|
257
|
-
for cntMics in range(nMics):
|
|
258
|
-
helpNormalize += distGridToAllMics[cntMics] * distGridToAllMics[cntMics]
|
|
259
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
260
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) * distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
|
|
261
|
-
|
|
262
|
-
# performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq')
|
|
263
|
-
scalarProd = 0.0
|
|
264
|
-
for cntMics in range(nMics):
|
|
265
|
-
leftVecMatrixProd = 0.0 + 0.0j
|
|
266
|
-
for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
|
|
267
|
-
leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
|
|
268
|
-
scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
|
|
269
|
-
scalarProd += (csm[cntMics, cntMics] * steerVec[cntMics].conjugate() * steerVec[cntMics]).real # include diagonal of csm
|
|
270
|
-
normalizeFactor = nMics * distGridToArrayCenter[0] # specific normalization of steering vector formulation
|
|
271
|
-
normalizeFactorSquared = normalizeFactor * normalizeFactor
|
|
272
|
-
normalizeSteer[0] = helpNormalize / normalizeFactorSquared
|
|
273
|
-
result[0] = scalarProd / normalizeFactorSquared * signalLossNormalization[0]
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
@nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
277
|
-
'(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
278
|
-
def _freqBeamformer_Formulation2AkaInverse_CsmRemovedDiag(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
176
|
+
# fast implementation of full matrix beamformers
|
|
177
|
+
@nb.njit(
|
|
178
|
+
[
|
|
179
|
+
(
|
|
180
|
+
nb.complex128[:, ::1],
|
|
181
|
+
nb.float64[::1],
|
|
182
|
+
nb.float64[:, ::1],
|
|
183
|
+
nb.float64,
|
|
184
|
+
nb.float64,
|
|
185
|
+
nb.boolean,
|
|
186
|
+
nb.int64,
|
|
187
|
+
nb.float64[::1],
|
|
188
|
+
nb.float64[::1],
|
|
189
|
+
)
|
|
190
|
+
],
|
|
191
|
+
cache=cachedOption,
|
|
192
|
+
parallel=True,
|
|
193
|
+
error_model="numpy"
|
|
194
|
+
)
|
|
195
|
+
def _freqBeamformer_FullCSM(
|
|
196
|
+
csm,
|
|
197
|
+
distGridToArrayCenter,
|
|
198
|
+
distGridToAllMics,
|
|
199
|
+
waveNumber,
|
|
200
|
+
signalLossNormalization,
|
|
201
|
+
r_diag,
|
|
202
|
+
steer_type,
|
|
203
|
+
result,
|
|
204
|
+
normalizeSteer,
|
|
205
|
+
):
|
|
279
206
|
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
280
207
|
nMics = csm.shape[0]
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
|
|
376
|
-
scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
|
|
377
|
-
scalarProd += (csm[cntMics, cntMics] * steerVec[cntMics].conjugate() * steerVec[cntMics]).real # include diagonal of csm
|
|
378
|
-
normalizeFactor = nMics * helpNormalize # specific normalization of steering vector formulation
|
|
379
|
-
normalizeSteer[0] = 1.0 / nMics
|
|
380
|
-
result[0] = scalarProd / normalizeFactor * signalLossNormalization[0]
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
@nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
384
|
-
'(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
385
|
-
def _freqBeamformer_Formulation4AkaTrueLocation_CsmRemovedDiag(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
208
|
+
st2 = (steer_type == 2)
|
|
209
|
+
st34 = (steer_type == 3 or steer_type == 4)
|
|
210
|
+
helpNormalize = 0.0 # just a hint for the compiler
|
|
211
|
+
for gi in nb.prange(distGridToArrayCenter.shape[0]):
|
|
212
|
+
steerVec = np.empty((nMics), np.complex128)
|
|
213
|
+
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
214
|
+
for cntMics in range(nMics):
|
|
215
|
+
expArg = np.float32(waveNumber * distGridToAllMics[gi, cntMics])
|
|
216
|
+
steerVec[cntMics] = np.cos(expArg) - 1j * np.sin(expArg)
|
|
217
|
+
if st2:
|
|
218
|
+
helpNormalize = 0.0
|
|
219
|
+
for cntMics in range(nMics):
|
|
220
|
+
helpNormalize += distGridToAllMics[gi,cntMics] * distGridToAllMics[gi,cntMics]
|
|
221
|
+
steerVec[cntMics] *= distGridToAllMics[gi,cntMics] # r_{t,i}-normalization is handled here
|
|
222
|
+
if st34:
|
|
223
|
+
helpNormalize = 0.0
|
|
224
|
+
for cntMics in range(nMics):
|
|
225
|
+
helpNormalize += 1.0 / (distGridToAllMics[gi,cntMics] * distGridToAllMics[gi,cntMics])
|
|
226
|
+
steerVec[cntMics] /= distGridToAllMics[gi,cntMics] # r_{t,i}-normalization is handled here
|
|
227
|
+
|
|
228
|
+
# performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq)
|
|
229
|
+
scalarProd = 0.0
|
|
230
|
+
for cntMics in range(nMics):
|
|
231
|
+
leftVecMatrixProd = 0.0 + 0.0j
|
|
232
|
+
for cntMics2 in range(
|
|
233
|
+
cntMics
|
|
234
|
+
): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
|
|
235
|
+
leftVecMatrixProd += (
|
|
236
|
+
csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
|
|
237
|
+
)
|
|
238
|
+
scalarProd += (
|
|
239
|
+
2 * (leftVecMatrixProd * steerVec[cntMics]).real
|
|
240
|
+
) # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
|
|
241
|
+
if not r_diag:
|
|
242
|
+
for cntMics in range(nMics):
|
|
243
|
+
scalarProd += (
|
|
244
|
+
csm[cntMics, cntMics]
|
|
245
|
+
* steerVec[cntMics].conjugate()
|
|
246
|
+
* steerVec[cntMics]
|
|
247
|
+
).real # include diagonal of csm
|
|
248
|
+
|
|
249
|
+
# specific normalzation for different steering vector formulations
|
|
250
|
+
if steer_type == 1:
|
|
251
|
+
normalizeFactor = nMics
|
|
252
|
+
normalizeSteer[gi] = 1.0 / nMics
|
|
253
|
+
result[gi] = (
|
|
254
|
+
scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization
|
|
255
|
+
)
|
|
256
|
+
elif steer_type == 2:
|
|
257
|
+
normalizeFactor = nMics * distGridToArrayCenter[gi]
|
|
258
|
+
normalizeFactorSquared = normalizeFactor * normalizeFactor
|
|
259
|
+
normalizeSteer[gi] = helpNormalize / normalizeFactorSquared
|
|
260
|
+
result[gi] = scalarProd / normalizeFactorSquared * signalLossNormalization
|
|
261
|
+
elif steer_type == 3:
|
|
262
|
+
normalizeFactor = distGridToArrayCenter[gi] * helpNormalize
|
|
263
|
+
normalizeSteer[gi] = 1.0 / (distGridToArrayCenter[gi] * distGridToArrayCenter[gi]) / helpNormalize
|
|
264
|
+
result[gi] = scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization
|
|
265
|
+
elif steer_type == 4:
|
|
266
|
+
normalizeFactor = nMics * helpNormalize
|
|
267
|
+
normalizeSteer[gi] = 1.0 / nMics
|
|
268
|
+
result[gi] = scalarProd / normalizeFactor * signalLossNormalization
|
|
269
|
+
|
|
270
|
+
# fast implementation of eigenvalue beamformers
|
|
271
|
+
@nb.njit(
|
|
272
|
+
[
|
|
273
|
+
(
|
|
274
|
+
nb.float64[::1],
|
|
275
|
+
nb.complex128[:, ::1],
|
|
276
|
+
nb.float64[::1],
|
|
277
|
+
nb.float64[:, ::1],
|
|
278
|
+
nb.float64,
|
|
279
|
+
nb.float64,
|
|
280
|
+
nb.boolean,
|
|
281
|
+
nb.int64,
|
|
282
|
+
nb.float64[::1],
|
|
283
|
+
nb.float64[::1],
|
|
284
|
+
)
|
|
285
|
+
],
|
|
286
|
+
cache=cachedOption,
|
|
287
|
+
parallel=True,
|
|
288
|
+
error_model="numpy"
|
|
289
|
+
)
|
|
290
|
+
def _freqBeamformer_EigValues(
|
|
291
|
+
eigVal,
|
|
292
|
+
eigVec,
|
|
293
|
+
distGridToArrayCenter,
|
|
294
|
+
distGridToAllMics,
|
|
295
|
+
waveNumber,
|
|
296
|
+
signalLossNormalization,
|
|
297
|
+
r_diag,
|
|
298
|
+
steer_type,
|
|
299
|
+
result,
|
|
300
|
+
normalizeSteer,
|
|
301
|
+
):
|
|
386
302
|
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
387
|
-
nMics =
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
helpNormalize = 0.0
|
|
392
|
-
for
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
303
|
+
nMics = eigVec.shape[0]
|
|
304
|
+
nEigs = len(eigVal)
|
|
305
|
+
st2 = (steer_type == 2)
|
|
306
|
+
st34 = (steer_type == 3 or steer_type == 4)
|
|
307
|
+
helpNormalize = 0.0 # just a hint for the compiler
|
|
308
|
+
for gi in nb.prange(distGridToArrayCenter.shape[0]):
|
|
309
|
+
steerVec = np.empty((nMics), np.complex128)
|
|
310
|
+
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
311
|
+
for cntMics in range(nMics):
|
|
312
|
+
expArg = np.float32(waveNumber * distGridToAllMics[gi, cntMics])
|
|
313
|
+
steerVec[cntMics] = np.cos(expArg) - 1j * np.sin(expArg)
|
|
314
|
+
if st2:
|
|
315
|
+
helpNormalize = 0.0
|
|
316
|
+
for cntMics in range(nMics):
|
|
317
|
+
helpNormalize += distGridToAllMics[gi,cntMics] * distGridToAllMics[gi,cntMics]
|
|
318
|
+
steerVec[cntMics] *= distGridToAllMics[gi,cntMics] # r_{t,i}-normalization is handled here
|
|
319
|
+
if st34:
|
|
320
|
+
helpNormalize = 0.0
|
|
321
|
+
for cntMics in range(nMics):
|
|
322
|
+
helpNormalize += 1.0 / (distGridToAllMics[gi,cntMics] * distGridToAllMics[gi,cntMics])
|
|
323
|
+
steerVec[cntMics] /= distGridToAllMics[gi,cntMics] # r_{t,i}-normalization is handled here
|
|
324
|
+
|
|
325
|
+
# eigenvalue beamforming
|
|
326
|
+
scalarProd = 0.0
|
|
327
|
+
if r_diag:
|
|
328
|
+
for cntEigVal in range(len(eigVal)):
|
|
329
|
+
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
330
|
+
scalarProdDiagCSMperEigVal = 0.0
|
|
331
|
+
for cntMics in range(nMics):
|
|
332
|
+
temp1 = eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics]
|
|
333
|
+
scalarProdFullCSMperEigVal += temp1
|
|
334
|
+
scalarProdDiagCSMperEigVal += (temp1 * temp1.conjugate()).real
|
|
335
|
+
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
336
|
+
scalarProd += (scalarProdFullCSMAbsSquared - scalarProdDiagCSMperEigVal) * eigVal[cntEigVal]
|
|
337
|
+
else:
|
|
338
|
+
for cntEigVal in range(nEigs):
|
|
339
|
+
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
340
|
+
for cntMics in range(nMics):
|
|
341
|
+
scalarProdFullCSMperEigVal += eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics]
|
|
342
|
+
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
343
|
+
scalarProd += scalarProdFullCSMAbsSquared * eigVal[cntEigVal]
|
|
344
|
+
|
|
345
|
+
# specific normalzation for different steering vector formulations
|
|
346
|
+
if steer_type == 1:
|
|
347
|
+
normalizeFactor = nMics
|
|
348
|
+
normalizeSteer[gi] = 1.0 / nMics
|
|
349
|
+
result[gi] = (
|
|
350
|
+
scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization
|
|
351
|
+
)
|
|
352
|
+
elif steer_type == 2:
|
|
353
|
+
normalizeFactor = nMics * distGridToArrayCenter[gi]
|
|
354
|
+
normalizeFactorSquared = normalizeFactor * normalizeFactor
|
|
355
|
+
normalizeSteer[gi] = helpNormalize / normalizeFactorSquared
|
|
356
|
+
result[gi] = scalarProd / normalizeFactorSquared * signalLossNormalization
|
|
357
|
+
elif steer_type == 3:
|
|
358
|
+
normalizeFactor = distGridToArrayCenter[gi] * helpNormalize
|
|
359
|
+
normalizeSteer[gi] = 1.0 / (distGridToArrayCenter[gi] * distGridToArrayCenter[gi]) / helpNormalize
|
|
360
|
+
result[gi] = scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization
|
|
361
|
+
elif steer_type == 4:
|
|
362
|
+
normalizeFactor = nMics * helpNormalize
|
|
363
|
+
normalizeSteer[gi] = 1.0 / nMics
|
|
364
|
+
result[gi] = scalarProd / normalizeFactor * signalLossNormalization
|
|
408
365
|
|
|
409
366
|
@nb.guvectorize([(nb.complex128[:,:], nb.complex128[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
410
367
|
'(m,m),(m),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
@@ -443,236 +400,6 @@ def _freqBeamformer_SpecificSteerVec_CsmRemovedDiag(csm, steerVec, signalLossNor
|
|
|
443
400
|
scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
|
|
444
401
|
normalizeSteer[0] = helpNormalize.real
|
|
445
402
|
result[0] = scalarProd * signalLossNormalization[0]
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
#%% beamformers - Eigenvalue Problem
|
|
449
|
-
|
|
450
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
451
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
452
|
-
def _freqBeamformer_EigValProb_Formulation1AkaClassic_FullCSM(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
453
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
454
|
-
nMics = distGridToAllMics.shape[0]
|
|
455
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
456
|
-
|
|
457
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
458
|
-
for cntMics in range(nMics):
|
|
459
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
460
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg))
|
|
461
|
-
|
|
462
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
463
|
-
scalarProdFullCSM = 0.0
|
|
464
|
-
for cntEigVal in range(len(eigVal)):
|
|
465
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
466
|
-
for cntMics in range(nMics):
|
|
467
|
-
scalarProdFullCSMperEigVal += eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics]
|
|
468
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
469
|
-
scalarProdFullCSM += scalarProdFullCSMAbsSquared * eigVal[cntEigVal]
|
|
470
|
-
normalizeFactor = nMics # specific normalization of steering vector formulation
|
|
471
|
-
normalizeSteer[0] = 1.0 / nMics
|
|
472
|
-
result[0] = scalarProdFullCSM / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
476
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
477
|
-
def _freqBeamformer_EigValProb_Formulation1AkaClassic_CsmRemovedDiag(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
478
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
479
|
-
nMics = distGridToAllMics.shape[0]
|
|
480
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
481
|
-
|
|
482
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
483
|
-
for cntMics in range(nMics):
|
|
484
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
485
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg))
|
|
486
|
-
|
|
487
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
488
|
-
scalarProdReducedCSM = 0.0
|
|
489
|
-
for cntEigVal in range(len(eigVal)):
|
|
490
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
491
|
-
scalarProdDiagCSMperEigVal = 0.0
|
|
492
|
-
for cntMics in range(nMics):
|
|
493
|
-
temp1 = eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics] # Dont call it 'expArg' like in steer-loop, because expArg is now a float (no double) which would cause errors of approx 1e-8
|
|
494
|
-
scalarProdFullCSMperEigVal += temp1
|
|
495
|
-
scalarProdDiagCSMperEigVal += (temp1 * temp1.conjugate()).real
|
|
496
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
497
|
-
scalarProdReducedCSM += (scalarProdFullCSMAbsSquared - scalarProdDiagCSMperEigVal) * eigVal[cntEigVal]
|
|
498
|
-
normalizeFactor = nMics # specific normalization of steering vector formulation
|
|
499
|
-
normalizeSteer[0] = 1.0 / nMics
|
|
500
|
-
result[0] = scalarProdReducedCSM / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
504
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
505
|
-
def _freqBeamformer_EigValProb_Formulation2AkaInverse_FullCSM(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
506
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
507
|
-
nMics = distGridToAllMics.shape[0]
|
|
508
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
509
|
-
|
|
510
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
511
|
-
helpNormalize = 0.0
|
|
512
|
-
for cntMics in range(nMics):
|
|
513
|
-
helpNormalize += distGridToAllMics[cntMics] * distGridToAllMics[cntMics]
|
|
514
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
515
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) * distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
|
|
516
|
-
|
|
517
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
518
|
-
scalarProdFullCSM = 0.0
|
|
519
|
-
for cntEigVal in range(len(eigVal)):
|
|
520
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
521
|
-
for cntMics in range(nMics):
|
|
522
|
-
scalarProdFullCSMperEigVal += eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics]
|
|
523
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
524
|
-
scalarProdFullCSM += scalarProdFullCSMAbsSquared * eigVal[cntEigVal]
|
|
525
|
-
normalizeFactor = nMics * distGridToArrayCenter[0] # specific normalization of steering vector formulation
|
|
526
|
-
normalizeFactorSquared = normalizeFactor * normalizeFactor
|
|
527
|
-
normalizeSteer[0] = helpNormalize / normalizeFactorSquared
|
|
528
|
-
result[0] = scalarProdFullCSM / normalizeFactorSquared * signalLossNormalization[0]
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
532
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
533
|
-
def _freqBeamformer_EigValProb_Formulation2AkaInverse_CsmRemovedDiag(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
534
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
535
|
-
nMics = distGridToAllMics.shape[0]
|
|
536
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
537
|
-
|
|
538
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
539
|
-
helpNormalize = 0.0
|
|
540
|
-
for cntMics in range(nMics):
|
|
541
|
-
helpNormalize += distGridToAllMics[cntMics] * distGridToAllMics[cntMics]
|
|
542
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
543
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) * distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
|
|
544
|
-
|
|
545
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
546
|
-
scalarProdReducedCSM = 0.0
|
|
547
|
-
for cntEigVal in range(len(eigVal)):
|
|
548
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
549
|
-
scalarProdDiagCSMperEigVal = 0.0
|
|
550
|
-
for cntMics in range(nMics):
|
|
551
|
-
temp1 = eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics] # Dont call it 'expArg' like in steer-loop, because expArg is now a float (no double) which would cause errors of approx 1e-8
|
|
552
|
-
scalarProdFullCSMperEigVal += temp1
|
|
553
|
-
scalarProdDiagCSMperEigVal += (temp1 * temp1.conjugate()).real
|
|
554
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
555
|
-
scalarProdReducedCSM += (scalarProdFullCSMAbsSquared - scalarProdDiagCSMperEigVal) * eigVal[cntEigVal]
|
|
556
|
-
normalizeFactor = nMics * distGridToArrayCenter[0] # specific normalization of steering vector formulation
|
|
557
|
-
normalizeFactorSquared = normalizeFactor * normalizeFactor
|
|
558
|
-
normalizeSteer[0] = helpNormalize / normalizeFactorSquared
|
|
559
|
-
result[0] = scalarProdReducedCSM / normalizeFactorSquared * signalLossNormalization[0]
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
563
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
564
|
-
def _freqBeamformer_EigValProb_Formulation3AkaTrueLevel_FullCSM(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
565
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
566
|
-
nMics = distGridToAllMics.shape[0]
|
|
567
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
568
|
-
|
|
569
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
570
|
-
helpNormalize = 0.0
|
|
571
|
-
for cntMics in range(nMics):
|
|
572
|
-
helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
|
|
573
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
574
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
|
|
575
|
-
|
|
576
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
577
|
-
scalarProdFullCSM = 0.0
|
|
578
|
-
for cntEigVal in range(len(eigVal)):
|
|
579
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
580
|
-
for cntMics in range(nMics):
|
|
581
|
-
scalarProdFullCSMperEigVal += eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics]
|
|
582
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
583
|
-
scalarProdFullCSM += scalarProdFullCSMAbsSquared * eigVal[cntEigVal]
|
|
584
|
-
normalizeFactor = distGridToArrayCenter[0] * helpNormalize # specific normalization of steering vector formulation
|
|
585
|
-
normalizeSteer[0] = 1.0 / (distGridToArrayCenter[0] * distGridToArrayCenter[0]) / helpNormalize
|
|
586
|
-
result[0] = scalarProdFullCSM / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
590
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
591
|
-
def _freqBeamformer_EigValProb_Formulation3AkaTrueLevel_CsmRemovedDiag(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
592
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
593
|
-
nMics = distGridToAllMics.shape[0]
|
|
594
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
595
|
-
|
|
596
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
597
|
-
helpNormalize = 0.0
|
|
598
|
-
for cntMics in range(nMics):
|
|
599
|
-
helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
|
|
600
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
601
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
|
|
602
|
-
|
|
603
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
604
|
-
scalarProdReducedCSM = 0.0
|
|
605
|
-
for cntEigVal in range(len(eigVal)):
|
|
606
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
607
|
-
scalarProdDiagCSMperEigVal = 0.0
|
|
608
|
-
for cntMics in range(nMics):
|
|
609
|
-
temp1 = eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics] # Dont call it 'expArg' like in steer-loop, because expArg is now a float (no double) which would cause errors of approx 1e-8
|
|
610
|
-
scalarProdFullCSMperEigVal += temp1
|
|
611
|
-
scalarProdDiagCSMperEigVal += (temp1 * temp1.conjugate()).real
|
|
612
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
613
|
-
scalarProdReducedCSM += (scalarProdFullCSMAbsSquared - scalarProdDiagCSMperEigVal) * eigVal[cntEigVal]
|
|
614
|
-
normalizeFactor = distGridToArrayCenter[0] * helpNormalize # specific normalization of steering vector formulation
|
|
615
|
-
normalizeSteer[0] = 1.0 / (distGridToArrayCenter[0] * distGridToArrayCenter[0]) / helpNormalize
|
|
616
|
-
result[0] = scalarProdReducedCSM / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
620
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
621
|
-
def _freqBeamformer_EigValProb_Formulation4AkaTrueLocation_FullCSM(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
622
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
623
|
-
nMics = distGridToAllMics.shape[0]
|
|
624
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
625
|
-
|
|
626
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
627
|
-
helpNormalize = 0.0
|
|
628
|
-
for cntMics in range(nMics):
|
|
629
|
-
helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
|
|
630
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
631
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
|
|
632
|
-
|
|
633
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
634
|
-
scalarProdFullCSM = 0.0
|
|
635
|
-
for cntEigVal in range(len(eigVal)):
|
|
636
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
637
|
-
for cntMics in range(nMics):
|
|
638
|
-
scalarProdFullCSMperEigVal += eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics]
|
|
639
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
640
|
-
scalarProdFullCSM += scalarProdFullCSMAbsSquared * eigVal[cntEigVal]
|
|
641
|
-
normalizeFactor = nMics * helpNormalize # specific normalization of steering vector formulation
|
|
642
|
-
normalizeSteer[0] = 1.0 / nMics
|
|
643
|
-
result[0] = scalarProdFullCSM / normalizeFactor * signalLossNormalization[0]
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
647
|
-
'(e),(m,e),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
648
|
-
def _freqBeamformer_EigValProb_Formulation4AkaTrueLocation_CsmRemovedDiag(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
|
|
649
|
-
# see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
|
|
650
|
-
nMics = distGridToAllMics.shape[0]
|
|
651
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
652
|
-
|
|
653
|
-
# building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
|
|
654
|
-
helpNormalize = 0.0
|
|
655
|
-
for cntMics in range(nMics):
|
|
656
|
-
helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
|
|
657
|
-
expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
|
|
658
|
-
steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
|
|
659
|
-
|
|
660
|
-
# performing matrix-vector-multplication via spectral decomp. (see bottom of information header of 'beamformerFreq')
|
|
661
|
-
scalarProdReducedCSM = 0.0
|
|
662
|
-
for cntEigVal in range(len(eigVal)):
|
|
663
|
-
scalarProdFullCSMperEigVal = 0.0 + 0.0j
|
|
664
|
-
scalarProdDiagCSMperEigVal = 0.0
|
|
665
|
-
for cntMics in range(nMics):
|
|
666
|
-
temp1 = eigVec[cntMics, cntEigVal].conjugate() * steerVec[cntMics] # Dont call it 'expArg' like in steer-loop, because expArg is now a float (no double) which would cause errors of approx 1e-8
|
|
667
|
-
scalarProdFullCSMperEigVal += temp1
|
|
668
|
-
scalarProdDiagCSMperEigVal += (temp1 * temp1.conjugate()).real
|
|
669
|
-
scalarProdFullCSMAbsSquared = (scalarProdFullCSMperEigVal * scalarProdFullCSMperEigVal.conjugate()).real
|
|
670
|
-
scalarProdReducedCSM += (scalarProdFullCSMAbsSquared - scalarProdDiagCSMperEigVal) * eigVal[cntEigVal]
|
|
671
|
-
normalizeFactor = nMics * helpNormalize # specific normalization of steering vector formulation
|
|
672
|
-
normalizeSteer[0] = 1.0 / nMics
|
|
673
|
-
result[0] = scalarProdReducedCSM / normalizeFactor * signalLossNormalization[0]
|
|
674
|
-
|
|
675
|
-
|
|
676
403
|
@nb.guvectorize([(nb.float64[:], nb.complex128[:,:], nb.complex128[:], nb.float64[:], nb.float64[:], nb.float64[:])],
|
|
677
404
|
'(e),(m,e),(m),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
|
|
678
405
|
def _freqBeamformer_EigValProb_SpecificSteerVec_FullCSM(eigVal, eigVec, steerVec, signalLossNormalization, result, normalizeSteer):
|