Skip to main content

block_moments

Function block_moments 

Source
pub fn block_moments(
    apply: impl Fn(&[c64], &mut [c64]),
    starts: &[Vec<c64>],
    kernel: &[f64],
) -> Vec<c64> ⓘ
Expand description

Stochastic moments μ_n = kernel_n · mean_v ⟨r_v| T_n(H̃) |r_v⟩ for a block of start vectors. apply(x, y) sets y = H̃ x for the whole block stored interleaved (x[row·m + v], see interleave), e.g. SparseMatrix::apply_block.

Uses T_m T_n = (T_{m+n} + T_{|m−n|})/2, i.e. μ_{2n} = 2⟨T_n|T_n⟩ − μ_0 and μ_{2n+1} = 2⟨T_n|T_{n+1}⟩ − μ_1: ⌈M/2⌉ products with H̃ give M moments (half of moments). The vector work runs in parallel in fixed chunks, so the result does not depend on the number of threads.