Sketch random vector generator

This needs to be rewritten: it can fail at generating spacelike vectors.
This commit is contained in:
Aaron Fenyes 2024-07-02 17:16:31 -07:00
parent 17fefff61e
commit abc53b4705

View File

@ -2,8 +2,23 @@ module Engine
using LinearAlgebra using LinearAlgebra
using SparseArrays 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 # the Lorentz form
Q = diagm([1, 1, 1, 1, -1]) Q = diagm([1, 1, 1, 1, -1])