diff --git a/engine-proto/gram-test/Engine.jl b/engine-proto/gram-test/Engine.jl index 1ab7272..44c5285 100644 --- a/engine-proto/gram-test/Engine.jl +++ b/engine-proto/gram-test/Engine.jl @@ -2,8 +2,23 @@ module Engine using LinearAlgebra using SparseArrays +using Random -export Q, DescentHistory, realize_gram +export rand_on_shell, Q, DescentHistory, realize_gram + +# === guessing === + +##[TO DO] write a test to confirm that the outputs are on the correct shells +##[TO DO] this can fail at generating spacelike vectors +function rand_on_shell(rng::AbstractRNG, shells::Array{T}) where T <: Number + space_parts = randn(rng, T, 4, size(shells, 1)) + space_self_prods = [dot(x, x) for x in eachcol(space_parts)] + return [space_parts; sqrt.(space_self_prods .- shells)'] +end + +rand_on_shell(shells::Array{<:Number}) = rand_on_shell(Random.default_rng(), shells) + +# === Gram matrix realization === # the Lorentz form Q = diagm([1, 1, 1, 1, -1])