@@ -387,7 +387,6 @@ def w_tilde_via_preload_from(w_tilde_preload, native_index_for_slim_index):
387387 return w_tilde_via_preload
388388
389389
390- @numba_util .jit ()
391390def data_vector_via_transformed_mapping_matrix_from (
392391 transformed_mapping_matrix : np .ndarray ,
393392 visibilities : np .ndarray ,
@@ -406,31 +405,24 @@ def data_vector_via_transformed_mapping_matrix_from(
406405 noise_map
407406 Flattened 1D array of the noise-map used by the inversion during the fit.
408407 """
408+ # Extract components
409+ vis_real = visibilities .real
410+ vis_imag = visibilities .imag
411+ f_real = transformed_mapping_matrix .real
412+ f_imag = transformed_mapping_matrix .imag
413+ noise_real = noise_map .real
414+ noise_imag = noise_map .imag
409415
410- data_vector = np .zeros (transformed_mapping_matrix .shape [1 ])
411-
412- visibilities_real = visibilities .real
413- visibilities_imag = visibilities .imag
414- transformed_mapping_matrix_real = transformed_mapping_matrix .real
415- transformed_mapping_matrix_imag = transformed_mapping_matrix .imag
416- noise_map_real = noise_map .real
417- noise_map_imag = noise_map .imag
418-
419- for vis_1d_index in range (transformed_mapping_matrix .shape [0 ]):
420- for pix_1d_index in range (transformed_mapping_matrix .shape [1 ]):
421- real_value = (
422- visibilities_real [vis_1d_index ]
423- * transformed_mapping_matrix_real [vis_1d_index , pix_1d_index ]
424- / (noise_map_real [vis_1d_index ] ** 2.0 )
425- )
426- imag_value = (
427- visibilities_imag [vis_1d_index ]
428- * transformed_mapping_matrix_imag [vis_1d_index , pix_1d_index ]
429- / (noise_map_imag [vis_1d_index ] ** 2.0 )
430- )
431- data_vector [pix_1d_index ] += real_value + imag_value
416+ # Square noise components
417+ inv_var_real = 1.0 / (noise_real ** 2 )
418+ inv_var_imag = 1.0 / (noise_imag ** 2 )
432419
433- return data_vector
420+ # Real and imaginary contributions
421+ weighted_real = (vis_real * inv_var_real )[:, None ] * f_real
422+ weighted_imag = (vis_imag * inv_var_imag )[:, None ] * f_imag
423+
424+ # Sum over visibilities
425+ return np .sum (weighted_real + weighted_imag , axis = 0 )
434426
435427
436428@numba_util .jit ()
@@ -512,7 +504,6 @@ def curvature_matrix_via_w_tilde_curvature_preload_interferometer_from(
512504 return curvature_matrix
513505
514506
515- @numba_util .jit ()
516507def mapped_reconstructed_visibilities_from (
517508 transformed_mapping_matrix : np .ndarray , reconstruction : np .ndarray
518509) -> np .ndarray :
@@ -525,20 +516,7 @@ def mapped_reconstructed_visibilities_from(
525516 The matrix representing the blurred mappings between sub-grid pixels and pixelization pixels.
526517
527518 """
528- mapped_reconstructed_visibilities = (0.0 + 0.0j ) * np .zeros (
529- transformed_mapping_matrix .shape [0 ]
530- )
531-
532- transformed_mapping_matrix_real = transformed_mapping_matrix .real
533- transformed_mapping_matrix_imag = transformed_mapping_matrix .imag
534-
535- for i in range (transformed_mapping_matrix .shape [0 ]):
536- for j in range (reconstruction .shape [0 ]):
537- mapped_reconstructed_visibilities [i ] += (
538- reconstruction [j ] * transformed_mapping_matrix_real [i , j ]
539- ) + 1.0j * (reconstruction [j ] * transformed_mapping_matrix_imag [i , j ])
540-
541- return mapped_reconstructed_visibilities
519+ return transformed_mapping_matrix @ reconstruction
542520
543521
544522"""
0 commit comments