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).

source
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.

source
HadaMAG.haar_random_unitaryFunction
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 to GLOBAL_RNG).
source
HadaMAG.use_default_fhtMethod
use_default_fht()

Revert call_fht! back to the built-in FastHadamardStructuredTransforms_jll implementation.

source
HadaMAG.use_fht_libMethod
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.

source