Engine prototype #13

Open
Vectornaut wants to merge 117 commits from engine-proto into main
Showing only changes of commit 7e94fef19e - Show all commits

View File

@ -8,14 +8,29 @@ export rand_on_shell, Q, DescentHistory, realize_gram
# === guessing === # === guessing ===
##[TO DO] write a test to confirm that the outputs are on the correct shells sconh(t, u) = 0.5*(exp(t) + u*exp(-t))
##[TO DO] this can fail at generating spacelike vectors
function rand_on_shell(rng::AbstractRNG, shells::Array{T}) where T <: Number function rand_on_sphere(rng::AbstractRNG, ::Type{T}, n) where T
space_parts = randn(rng, T, 4, size(shells, 1)) out = randn(rng, T, n)
space_self_prods = [dot(x, x) for x in eachcol(space_parts)] tries_left = 2
return [space_parts; sqrt.(space_self_prods .- shells)'] while dot(out, out) < 1e-6 && tries_left > 0
out = randn(rng, T, n)
tries_left -= 1
end
normalize(out)
end end
##[TO DO] write a test to confirm that the outputs are on the correct shells
function rand_on_shell(rng::AbstractRNG, shell::T) where T <: Number
space_part = rand_on_sphere(rng, T, 4)
rapidity = randn(rng, T)
sig = sign(shell)
[sconh(rapidity, sig)*space_part; sconh(rapidity, -sig)]
end
rand_on_shell(rng::AbstractRNG, shells::Array{T}) where T <: Number =
hcat([rand_on_shell(rng, sh) for sh in shells]...)
rand_on_shell(shells::Array{<:Number}) = rand_on_shell(Random.default_rng(), shells) rand_on_shell(shells::Array{<:Number}) = rand_on_shell(Random.default_rng(), shells)
# === Gram matrix realization === # === Gram matrix realization ===