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.
Files changed (64) hide show
  1. acoular/__init__.py +2 -2
  2. acoular/configuration.py +37 -1
  3. acoular/environments.py +15 -9
  4. acoular/fastFuncs.py +199 -472
  5. acoular/fbeamform.py +168 -109
  6. acoular/grids.py +33 -114
  7. acoular/sources.py +77 -3
  8. acoular/spectra.py +2 -2
  9. acoular/tbeamform.py +15 -8
  10. acoular/tests/reference_data/BeamformerBaseFalse1.npy +0 -0
  11. acoular/tests/reference_data/BeamformerBaseFalse2.npy +0 -0
  12. acoular/tests/reference_data/BeamformerBaseFalse3.npy +0 -0
  13. acoular/tests/reference_data/BeamformerBaseFalse4.npy +0 -0
  14. acoular/tests/reference_data/BeamformerBaseTrue1.npy +0 -0
  15. acoular/tests/reference_data/BeamformerBaseTrue2.npy +0 -0
  16. acoular/tests/reference_data/BeamformerBaseTrue3.npy +0 -0
  17. acoular/tests/reference_data/BeamformerBaseTrue4.npy +0 -0
  18. acoular/tests/reference_data/BeamformerCMFLassoLarsBIC.npy +0 -0
  19. acoular/tests/reference_data/BeamformerCMFNNLS.npy +0 -0
  20. acoular/tests/reference_data/BeamformerCleantSqTraj.npy +0 -0
  21. acoular/tests/reference_data/BeamformerCleantTraj.npy +0 -0
  22. acoular/tests/reference_data/BeamformerEigFalse1.npy +0 -0
  23. acoular/tests/reference_data/BeamformerEigFalse2.npy +0 -0
  24. acoular/tests/reference_data/BeamformerEigFalse3.npy +0 -0
  25. acoular/tests/reference_data/BeamformerEigFalse4.npy +0 -0
  26. acoular/tests/reference_data/BeamformerEigTrue1.npy +0 -0
  27. acoular/tests/reference_data/BeamformerEigTrue2.npy +0 -0
  28. acoular/tests/reference_data/BeamformerEigTrue3.npy +0 -0
  29. acoular/tests/reference_data/BeamformerEigTrue4.npy +0 -0
  30. acoular/tests/reference_data/BeamformerGIB.npy +0 -0
  31. acoular/tests/reference_data/BeamformerSODIX.npy +0 -0
  32. acoular/tests/reference_data/FiltFiltOctave__.npy +0 -0
  33. acoular/tests/reference_data/FiltFiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
  34. acoular/tests/reference_data/FiltFreqWeight_weight_A_.npy +0 -0
  35. acoular/tests/reference_data/FiltFreqWeight_weight_C_.npy +0 -0
  36. acoular/tests/reference_data/FiltFreqWeight_weight_Z_.npy +0 -0
  37. acoular/tests/reference_data/FiltOctave__.npy +0 -0
  38. acoular/tests/reference_data/FiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
  39. acoular/tests/reference_data/Filter__.npy +0 -0
  40. acoular/tests/reference_data/OctaveFilterBank__.npy +0 -0
  41. acoular/tests/reference_data/TimeAverage__.npy +0 -0
  42. acoular/tests/reference_data/TimeCumAverage__.npy +0 -0
  43. acoular/tests/reference_data/TimeExpAverage_weight_F_.npy +0 -0
  44. acoular/tests/reference_data/TimeExpAverage_weight_I_.npy +0 -0
  45. acoular/tests/reference_data/TimeExpAverage_weight_S_.npy +0 -0
  46. acoular/tests/reference_data/TimeInOut__.npy +0 -0
  47. acoular/tests/reference_data/TimePower__.npy +0 -0
  48. acoular/tests/reference_data/TimeReverse__.npy +0 -0
  49. acoular/tests/test_beamformer_results.py +39 -8
  50. acoular/tests/test_grid.py +92 -0
  51. acoular/tests/test_integrate.py +102 -0
  52. acoular/tests/test_tprocess.py +52 -0
  53. acoular/tests/test_traj_beamformer_results.py +2 -2
  54. acoular/tfastfuncs.py +24 -25
  55. acoular/tools.py +144 -2
  56. acoular/tprocess.py +91 -102
  57. acoular/version.py +2 -2
  58. acoular-24.3.dist-info/METADATA +181 -0
  59. {acoular-23.6.dist-info → acoular-24.3.dist-info}/RECORD +62 -25
  60. {acoular-23.6.dist-info → acoular-24.3.dist-info}/WHEEL +1 -1
  61. {acoular-23.6.dist-info → acoular-24.3.dist-info}/licenses/LICENSE +1 -1
  62. acoular/tests/reference_data/BeamformerCMF.npy +0 -0
  63. acoular-23.6.dist-info/METADATA +0 -82
  64. {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[:,:,:](nb.complex128[:,:,:], nb.complex128[:,:]),
20
- nb.complex64[:,:,:](nb.complex64[:,:,:], nb.complex64[:,:])], cache=cachedOption, parallel=True)
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, 'classic', False) : _freqBeamformer_Formulation1AkaClassic_FullCSM,
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
- coreFunc = beamformerDict[(boolIsEigValProb, steerVecType, boolRemovedDiagOfCSM)]
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#[0], inputTupleSteer[1], inputTupleSteer[2]
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
- coreFunc(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics, waveNumber, normFactor, result, normalHelp)
165
+ _freqBeamformer_EigValues(eigVal, np.ascontiguousarray(eigVec), distGridToArrayCenter, distGridToAllMics, waveNumber[0], normFactor,
166
+ boolRemovedDiagOfCSM, sth[steerVecType],
167
+ result, normalHelp)
191
168
  else:
192
- coreFunc(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, normFactor, result, normalHelp)
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
- #%% beamformers - steer * CSM * steer
199
- @nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
200
- '(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
201
- def _freqBeamformer_Formulation1AkaClassic_FullCSM(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
202
- # see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
203
- nMics = csm.shape[0]
204
- steerVec = np.zeros((nMics), np.complex128)
205
-
206
- # building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
207
- for cntMics in range(nMics):
208
- expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
209
- steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg))
210
-
211
- # performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq)
212
- scalarProd = 0.0
213
- for cntMics in range(nMics):
214
- leftVecMatrixProd = 0.0 + 0.0j
215
- for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
216
- leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
217
- scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
218
- scalarProd += (csm[cntMics, cntMics] * steerVec[cntMics].conjugate() * steerVec[cntMics]).real # include diagonal of csm
219
- normalizeFactor = nMics # specific normalization of steering vector formulation
220
- normalizeSteer[0] = 1.0 / nMics
221
- result[0] = scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
222
-
223
-
224
- @nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
225
- '(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
226
- def _freqBeamformer_Formulation1AkaClassic_CsmRemovedDiag(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
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
- steerVec = np.zeros((nMics), np.complex128)
282
-
283
- # building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
284
- helpNormalize = 0.0
285
- for cntMics in range(nMics):
286
- helpNormalize += distGridToAllMics[cntMics] * distGridToAllMics[cntMics]
287
- expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
288
- steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) * distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
289
-
290
- # performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq')
291
- scalarProd = 0.0
292
- for cntMics in range(nMics):
293
- leftVecMatrixProd = 0.0 + 0.0j
294
- for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
295
- leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
296
- scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
297
- normalizeFactor = nMics * distGridToArrayCenter[0] # specific normalization of steering vector formulation
298
- normalizeFactorSquared = normalizeFactor * normalizeFactor
299
- normalizeSteer[0] = helpNormalize / normalizeFactorSquared
300
- result[0] = scalarProd / normalizeFactorSquared * signalLossNormalization[0]
301
-
302
-
303
- @nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
304
- '(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
305
- def _freqBeamformer_Formulation3AkaTrueLevel_FullCSM(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
306
- # see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
307
- nMics = csm.shape[0]
308
- steerVec = np.zeros((nMics), np.complex128)
309
-
310
- # building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
311
- helpNormalize = 0.0
312
- for cntMics in range(nMics):
313
- helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
314
- expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
315
- steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
316
-
317
- # performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq')
318
- scalarProd = 0.0
319
- for cntMics in range(nMics):
320
- leftVecMatrixProd = 0.0 + 0.0j
321
- for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
322
- leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
323
- scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
324
- scalarProd += (csm[cntMics, cntMics] * steerVec[cntMics].conjugate() * steerVec[cntMics]).real # include diagonal of csm
325
- normalizeFactor = distGridToArrayCenter[0] * helpNormalize # specific normalization of steering vector formulation
326
- normalizeSteer[0] = 1.0 / (distGridToArrayCenter[0] * distGridToArrayCenter[0]) / helpNormalize
327
- result[0] = scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
328
-
329
-
330
- @nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
331
- '(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
332
- def _freqBeamformer_Formulation3AkaTrueLevel_CsmRemovedDiag(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
333
- # see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
334
- nMics = csm.shape[0]
335
- steerVec = np.zeros((nMics), np.complex128)
336
-
337
- # building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
338
- helpNormalize = 0.0
339
- for cntMics in range(nMics):
340
- helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
341
- expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
342
- steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
343
-
344
- # performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq')
345
- scalarProd = 0.0
346
- for cntMics in range(nMics):
347
- leftVecMatrixProd = 0.0 + 0.0j
348
- for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
349
- leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
350
- scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
351
- normalizeFactor = distGridToArrayCenter[0] * helpNormalize # specific normalization of steering vector formulation
352
- normalizeSteer[0] = 1.0 / (distGridToArrayCenter[0] * distGridToArrayCenter[0]) / helpNormalize
353
- result[0] = scalarProd / (normalizeFactor * normalizeFactor) * signalLossNormalization[0]
354
-
355
-
356
- @nb.guvectorize([(nb.complex128[:,:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:])],
357
- '(m,m),(),(m),(),()->(),()', nopython=True, target=parallelOption, cache=cachedOption, fastmath=fastOption)
358
- def _freqBeamformer_Formulation4AkaTrueLocation_FullCSM(csm, distGridToArrayCenter, distGridToAllMics, waveNumber, signalLossNormalization, result, normalizeSteer):
359
- # see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
360
- nMics = csm.shape[0]
361
- steerVec = np.zeros((nMics), np.complex128)
362
-
363
- # building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
364
- helpNormalize = 0.0
365
- for cntMics in range(nMics):
366
- helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
367
- expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
368
- steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
369
-
370
- # performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq')
371
- scalarProd = 0.0
372
- for cntMics in range(nMics):
373
- leftVecMatrixProd = 0.0 + 0.0j
374
- for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
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 = csm.shape[0]
388
- steerVec = np.zeros((nMics), np.complex128)
389
-
390
- # building steering vector: in order to save some operation -> some normalization steps are applied after mat-vec-multipl.
391
- helpNormalize = 0.0
392
- for cntMics in range(nMics):
393
- helpNormalize += 1.0 / (distGridToAllMics[cntMics] * distGridToAllMics[cntMics])
394
- expArg = np.float32(waveNumber[0] * distGridToAllMics[cntMics])
395
- steerVec[cntMics] = (np.cos(expArg) - 1j * np.sin(expArg)) / distGridToAllMics[cntMics] # r_{t,i}-normalization is handled here
396
-
397
- # performing matrix-vector-multiplication (see bottom of information header of 'beamformerFreq')
398
- scalarProd = 0.0
399
- for cntMics in range(nMics):
400
- leftVecMatrixProd = 0.0 + 0.0j
401
- for cntMics2 in range(cntMics): # calculate 'steer^H * CSM' of upper-triangular-part of csm (without diagonal)
402
- leftVecMatrixProd += csm[cntMics2, cntMics] * steerVec[cntMics2].conjugate()
403
- scalarProd += 2 * (leftVecMatrixProd * steerVec[cntMics]).real # use that csm is Hermitian (lower triangular of csm can be reduced to factor '2')
404
- normalizeFactor = nMics * helpNormalize # specific normalization of steering vector formulation
405
- normalizeSteer[0] = 1.0 / nMics
406
- result[0] = scalarProd / normalizeFactor * signalLossNormalization[0]
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):