qudit_expr/codegen/
mod.rs

1mod builder;
2mod builtins;
3#[allow(clippy::module_inception)]
4mod codegen;
5mod module;
6
7/// Function signature for a JIT-compiled expression
8///
9/// # Params
10///
11/// * (*const R): Pointer to input parameter vector
12/// * (*mut R): Pointer to output buffer
13/// * (*const u64): Pointer to parameter map
14/// * (*const u64): Pointer to output map
15/// * (u64): offset for each function unit (0*offset = function, 1*offset = first partial grad, ..)
16/// * (*const bool): Pointer to constant parameter map
17pub type WriteFunc<R> =
18    unsafe extern "C" fn(*const R, *mut R, *const u64, *const u64, u64, *const bool);
19
20fn process_name_for_gen(name: &str) -> String {
21    name.replace(" ", "_")
22        .replace("⊗", "t")
23        .replace("†", "d")
24        .replace("^", "p")
25        .replace("⋅", "x")
26}
27
28pub use builder::CompilableUnit;
29pub use builder::DifferentiationLevel;
30pub use builder::ModuleBuilder;
31pub use builder::{FUNCTION, GRADIENT, HESSIAN};
32pub use module::Module;
33
34pub use codegen::CodeGenerator;
35
36use qudit_core::RealScalar;
37
38pub struct WriteFuncWithLifeTime<'a, R: RealScalar> {
39    #[allow(dead_code)]
40    func: WriteFunc<R>,
41    _phantom: std::marker::PhantomData<&'a Module<R>>,
42}