From f51c0f32e62748cd5b1c9a63bcbcf6c21d79256c Mon Sep 17 00:00:00 2001 From: Nuwan Yapa Date: Mon, 30 Dec 2024 18:21:45 -0500 Subject: [PATCH] Function for calculating rank --- helper.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helper.jl b/helper.jl index 6f52421..da9f150 100644 --- a/helper.jl +++ b/helper.jl @@ -71,3 +71,11 @@ function gram_schmidt(vecs, ws, precision=1e-10, verbose=false) end return vecs[mask] end + +"Rank of a basis set (pre-normalized) under c-product" +function c_rank(vecs, ws, threshold=1e-8) + basis = hcat(vecs...) + N = transpose(basis) * spdiagm(ws) * basis + abs_singular_values = eigvals(N) .|> abs .|> sqrt + return count(abs_singular_values .> threshold) +end \ No newline at end of file