From abc53b4705610cd06ed352954cd185bd121d771b Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Tue, 2 Jul 2024 17:16:31 -0700 Subject: [PATCH] Sketch random vector generator This needs to be rewritten: it can fail at generating spacelike vectors. --- engine-proto/gram-test/Engine.jl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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])