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
7 changes: 2 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ authors = ["Tim Holy <tim.holy@gmail.com> and contributors"]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[weakdeps]
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[extensions]
MatrixCoversIpoptExt = ["Ipopt", "JuMP"]
MatrixCoversJuMPExt = ["HiGHS", "JuMP"]
MatrixCoversSparseArraysExt = "SparseArrays"
MatrixCoversSparseArraysUnitfulExt = ["SparseArrays", "Unitful"]
MatrixCoversUnitfulExt = "Unitful"

[compat]
Expand All @@ -46,11 +44,10 @@ HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Aqua", "ExplicitImports", "HiGHS", "Ipopt", "JuMP", "OffsetArrays", "SparseArrays", "StableRNGs", "Statistics", "Test", "Unitful"]
test = ["Aqua", "ExplicitImports", "HiGHS", "Ipopt", "JuMP", "OffsetArrays", "StableRNGs", "Statistics", "Test", "Unitful"]
35 changes: 0 additions & 35 deletions ext/MatrixCoversSparseArraysUnitfulExt.jl

This file was deleted.

21 changes: 20 additions & 1 deletion ext/MatrixCoversUnitfulExt.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module MatrixCoversUnitfulExt

using LinearAlgebra: LinearAlgebra
using LinearAlgebra: LinearAlgebra, Hermitian, Symmetric
using MatrixCovers
using MatrixCovers: AbsLog, AbsLinear
using SparseArrays: SparseMatrixCSC
using Unitful: Unitful, FreeUnits, Quantity, Unit, unit, ustrip

const MC = MatrixCovers
Expand Down Expand Up @@ -319,6 +320,24 @@ MC.soft_symcover_min!(a::QVector, A::QMatrix; kwargs...) = symstart!(MC.soft_sym
MC.soft_cover_min(A::QMatrix; kwargs...) = asym(MC.soft_cover_min, A; kwargs...)
MC.soft_cover_min!(a::QVector, b::QVector, A::QMatrix; kwargs...) = asymstart!(MC.soft_cover_min!, a, b, A; kwargs...)

# MatrixCovers types the matrix slot of its sparse refiners, where the methods above
# type the element: neither is more specific for a sparse matrix of quantities, so the
# two are ambiguous there. These methods resolve that pair. They are the only overlap --
# every other sparse method leaves its matrix slot untyped.
#
# Sparse storage synthesizes structural zeros with `zero(eltype)`, so the element type
# is concrete and every entry carries the same unit.
const QSparse = SparseMatrixCSC{<:Quantity}
const QSparseSym = Union{QSparse,
Symmetric{<:Quantity,<:SparseMatrixCSC},
Hermitian{<:Quantity,<:SparseMatrixCSC}}

MC.symcover_min!(ϕ::AbsLog{2}, a::QVector, A::QSparseSym; kwargs...) =
symstart!(MC.symcover_min!, a, A, ϕ; kwargs...)

MC.cover_min!(ϕ::AbsLog{2}, a::QVector, b::QVector, A::QSparse; kwargs...) =
asymstart!(MC.cover_min!, a, b, A, ϕ; kwargs...)

for P in PENALTIES
@eval begin
MC.soft_symcover(ϕ::$P, A::QMatrix; kwargs...) = sym(MC.soft_symcover, A, ϕ; kwargs...)
Expand Down
5 changes: 4 additions & 1 deletion src/MatrixCovers.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module MatrixCovers

using LinearAlgebra: LinearAlgebra, Adjoint, Bidiagonal, Diagonal, Hermitian,
SymTridiagonal, Symmetric, Transpose, Tridiagonal, dot, norm
SymTridiagonal, Symmetric, Transpose, Tridiagonal, cholesky,
dot, mul!, norm
using PrecompileTools: PrecompileTools, @compile_workload
using Random: Random, AbstractRNG, MersenneTwister
using SparseArrays: SparseArrays, SparseMatrixCSC, nonzeros, nzrange, rowvals, sparse

export AbsLog, AbsLinear
export cover_objective, iscover
Expand All @@ -27,6 +29,7 @@ include("gram_covers.jl") # symmetric covers of A'*W*A from an asymmetric cov
include("initializers.jl") # the start menu; consumed by both solver families below
include("soft_covers.jl")
include("minimal_covers.jl")
include("sparse_support.jl") # sparse traversal and the sparse solver defaults


# True only when a MethodError's argument types are consistent with the calling
Expand Down
Loading
Loading