Skip to main content

ppvm_pauli_sum/config/
fxhash.rs

1// SPDX-FileCopyrightText: 2026 The PPVM Authors
2// SPDX-License-Identifier: Apache-2.0
3
4use std::collections::HashMap;
5use std::marker::PhantomData;
6
7use ppvm_pauli_word::word::PauliWord;
8use ppvm_traits::config::Config;
9use ppvm_traits::traits::{Coefficient, NoStrategy, PauliWordTrait, Strategy};
10
11/// `HashMap`-backed [`Config`] with `[u8; N]` storage and `FxHasher`.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
13pub struct Byte<
14    const N: usize,
15    C: Coefficient,
16    St: Strategy = NoStrategy,
17    W: PauliWordTrait = PauliWord<[u8; N], fxhash::FxBuildHasher>,
18>(PhantomData<(C, St, W)>);
19
20impl<const N: usize, C: Coefficient, St: Strategy, W: PauliWordTrait> Config for Byte<N, C, St, W> {
21    type Storage = [u8; N];
22    type Coeff = C;
23    type BuildHasher = fxhash::FxBuildHasher;
24    type PauliWordType = W;
25    type Map = HashMap<W, C, Self::BuildHasher>;
26    type Strategy = St;
27}
28
29/// [`Byte`] specialised to `f64` coefficients.
30pub type ByteF64<const N: usize, St = NoStrategy> = Byte<N, f64, St>;