@@ -591,8 +591,12 @@ def calculate_noise_operators_from_scratch(
591
591
noise_operators = np .zeros ((len (omega ), len (n_opers ), d , d ), dtype = complex )
592
592
593
593
if cache_intermediates :
594
+ phase_factors_cache = np .empty ((len (dt ), len (omega )), dtype = complex )
595
+ int_cache = np .empty ((len (dt ), len (omega ), d , d ), dtype = complex )
594
596
sum_cache = np .empty ((len (dt ), len (omega ), len (n_opers ), d , d ), dtype = complex )
595
597
else :
598
+ phase_factors = np .empty ((len (omega ),), dtype = complex )
599
+ int_buf = np .empty ((len (omega ), d , d ), dtype = complex )
596
600
sum_buf = np .empty ((len (omega ), len (n_opers ), d , d ), dtype = complex )
597
601
598
602
# Set up reusable expressions
@@ -607,17 +611,22 @@ def calculate_noise_operators_from_scratch(
607
611
if cache_intermediates :
608
612
# Assign references to the locations in the cache for the quantities
609
613
# that should be stored
614
+ phase_factors = phase_factors_cache [g ]
615
+ int_buf = int_cache [g ]
610
616
sum_buf = sum_cache [g ]
611
617
618
+ phase_factors = util .cexp (omega * t [g ], out = phase_factors )
612
619
int_buf = _first_order_integral (omega , eigvals [g ], dt [g ], exp_buf , int_buf )
613
- sum_buf = expr_1 (n_opers_transformed [:, g ], util . cexp ( omega * t [ g ]) [:, None , None ]* int_buf ,
620
+ sum_buf = expr_1 (n_opers_transformed [:, g ], phase_factors [:, None , None ]* int_buf ,
614
621
out = sum_buf )
615
622
616
623
noise_operators += expr_2 (eigvecs_propagated [g ].conj (), sum_buf , eigvecs_propagated [g ],
617
624
out = sum_buf )
618
625
619
626
if cache_intermediates :
620
627
intermediates = dict (n_opers_transformed = n_opers_transformed ,
628
+ first_order_integral = int_cache ,
629
+ phase_factors = phase_factors_cache ,
621
630
noise_operators_step = sum_cache )
622
631
return noise_operators , intermediates
623
632
0 commit comments