Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

### Changed

- Remove the unnecessary and redundant `_laplacian_1neg_spectra(spec::SSpectra)` method from `src/laplacian_s_spectra.jl` (this method literally did nothing whatsoever; I left it in from a previous design approach) (#38).
- Changed `check_spectrum_integrality` to compute the real integer eigenvalues lazily (comparison was already lazy, but taking the real part and rounding was not) (#37).

## [0.1.0] - 2025-08-01
Expand Down
83 changes: 0 additions & 83 deletions src/laplacian_s_spectra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,96 +159,13 @@ end

"""
_laplacian_1neg_spectra(L) -> SSpectra
_laplacian_1neg_spectra(spec) -> SSpectra

[TODO: Write here]
"""
function _laplacian_1neg_spectra(L::AbstractMatrix{<:Integer})
return _classified_laplacian_1neg_spectra(classify_laplacian(L))
end

function _laplacian_1neg_spectra(spec::SSpectra)
if spec.S != (-1, 0, 1)
throw(
ArgumentError(
"Expected `{-1, 0, 1}`-spectra` to compute `{-1, 1}`-spectra, got $(spec.S)-spectra",
),
)
end

L = copy(spec.matrix)
n = size(L, 1)
S = (-1, 1)
multiplicities = copy(spec.multiplicities)

eigenspaces_01neg = spec.s_eigenspaces

#= If `n > 1` is odd, then all non-kernel eigenvectors must be orthogonal to the
all-ones vector and thus are precluded from having all entries from {-1, 1}. If `n = 1`,
then the kernel is the only eigenspace, so we need not handle that case separately. =#
if iseven(n)
s_eigenspaces = OrderedDict{Int,Matrix{Int}}()
s_eigenbases = OrderedDict{Int,Union{Nothing,Matrix{Int}}}()

for eigval in keys(multiplicities)
multi = multiplicities[eigval]
eigvecs = Iterators.filter(
col -> !any(iszero, col), eachcol(eigenspaces_01neg[eigval])
)

if isempty(eigvecs)
eigenspace = Matrix{Int}(undef, n, 0)
eigenbasis = nothing
else
eigenspace = stack(eigvecs)
pot_eigenbasis = _extract_independent_cols(eigenspace)

if size(pot_eigenbasis, 2) < multi
eigenbasis = nothing
else
eigenbasis = pot_eigenbasis
end
end

s_eigenspaces[eigval] = eigenspace
s_eigenbases[eigval] = eigenbasis
end
else
dim_kernel = multiplicities[0]
kernel_vecs = Iterators.filter(
col -> !any(iszero, col), eachcol(eigenspaces_01neg[0])
)

if isempty(kernel_vecs)
kernel = Matrix{Int}(undef, n, 0)
null_basis = nothing
else
kernel = stack(kernel_vecs)
pot_null_basis = _extract_independent_cols(kernel)

if size(pot_null_basis, 2) < dim_kernel
null_basis = nothing
else
null_basis = pot_null_basis
end
end

s_eigenspaces = OrderedDict(
eigval => Matrix{Int}(undef, n, 0) for eigval in keys(multiplicities)
)
s_eigenspaces[0] = kernel

s_eigenbases = OrderedDict{Int,Union{Nothing,Matrix{Int}}}(
eigval => nothing for eigval in keys(multiplicities)
)
s_eigenbases[0] = null_basis
end

s_diagonalizable = all(!isnothing, values(s_eigenbases))

return SSpectra(L, S, multiplicities, s_eigenspaces, s_eigenbases, s_diagonalizable)
end

"""
_classified_laplacian_01neg_spectra(CL) -> SSpectra

Expand Down