Skip to content

Commit

Permalink
Core code independent of linear algebra implementation (#4)
Browse files Browse the repository at this point in the history
* Initial work on abstract interface

* working code

* Move model definition to own file, make compute_stepsize more efficient

* Add tests

* Remove unused code
  • Loading branch information
mtanneau authored May 20, 2018
1 parent 99e35d4 commit e4647e6
Show file tree
Hide file tree
Showing 7 changed files with 487 additions and 235 deletions.
39 changes: 39 additions & 0 deletions src/Cholesky/Cholesky.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Cholesky

# export AbstractCholeskyFactor, SimpleDenseCholeskyFactor, SimpleSparseCholeskyFactor

"""
cholesky!(A, d, M)
Form the matrix S = A*Diag(d)*A' and computes its Cholesky factorization.
The factorization overwrites F.
"""
function cholesky!(A::AbstractMatrix{Ta}, d::AbstractVector{Td}, F::Factorization{Ta}) where{Ta<:Real, Td<:Real}
warn("cholesky! must be implemented for $(typeof(A))")
return F
end

function cholesky!(A::Matrix{Ta}, d::AbstractVector{Td}, F::Base.LinAlg.Cholesky{Ta,Matrix{Ta}}) where{Ta<:Real, Td<:Real}
F = cholfact!(F, A*Diagonal(d)*A')
return F
end

function cholesky!(A::SparseMatrixCSC{Ta, Int64}, d::AbstractVector{Td}, F::Base.SparseArrays.CHOLMOD.Factor{Ta}) where{Ta<:Real, Td<:Real}
# update CHolesky factor
F = cholfact!(F, Symmetric(A*spdiagm(d)*A'))
return F
end

"""
solve!(y, F, b)
Solves the system F*y = b and overwrites y.
"""
function solve!(y::AbstractVector{T1}, F::Factorization{T2}, b::AbstractVector{T3}) where {T1<:Real, T2<:Real, T3<:Real}
warn("Implement solve! for concrete type implementations!")
return y
end

# include("denseCholesky.jl")
# include("sparseCholesky.jl")


end # module
10 changes: 8 additions & 2 deletions src/Tulip.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
module Tulip

export Model, PrimalDualPoint, readmps

# Cholesky module
include("Cholesky/Cholesky.jl")

# package code goes here
include("./ipm.jl")
include("./readmps.jl")
include("model.jl")
include("ipm.jl")
include("readmps.jl")

end # module
Loading

0 comments on commit e4647e6

Please sign in to comment.