Helper functions in HadaMAG.jl
HadaMAG.build_tmp! — Method
build_tmp!(tmp1, tmp2, X)Compute tmp1 = real(X)+imag(X), tmp2 = imag(X)-real(X) in place. X is the complex state vector (length = 2^L).
HadaMAG.call_fht! — Method
call_fht!(vec::Vector{Float64}, L::Int32)In‐place fast Hadamard transform. After an optional call to use_fht_lib, this will call through your .so instead of the default JLL library.
HadaMAG.haar_random_unitary — Function
haar_random_unitary(q::Int, n_qudits::Integer, rng::AbstractRNG = Random.GLOBAL_RNG)Generate a Haar-distributed random unitary matrix of size q^nqudits × q^nqudits.
Arguments
q::Int: local dimension (2 for qubits, 3 for qutrits).n_qudits::Integer: number of qubits; the output U lives in U(2^n_qubits).rng::AbstractRNG: random number generator (defaults toGLOBAL_RNG).
HadaMAG.integrate_simpson_uniform — Method
integrate_simpson_uniform(x, y) -> Float64Simpson's rule on a uniform grid x. Requires an odd number of points.
HadaMAG.use_default_fht — Method
use_default_fht()Revert call_fht! back to the built-in FastHadamardStructuredTransforms_jll implementation.
HadaMAG.use_fht_lib — Method
use_fht_lib(path::String)Point at your own compiled .so that exports exactly the symbol :fht_double. After calling this, every call_fht! will invoke your library instead of the JLL one.