Skip to content

Commit 98e70b1

Browse files
committed
Remove blockdiag
1 parent ee0e564 commit 98e70b1

File tree

2 files changed

+35
-38
lines changed

2 files changed

+35
-38
lines changed

src/MOI_wrapper.jl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,41 @@ function Base.getindex(x::SDPBlock, i, j)
717717
end
718718
end
719719

720-
include("blockdiag.jl")
720+
abstract type AbstractBlockMatrix{T} <: AbstractMatrix{T} end
721+
722+
function nblocks end
723+
724+
function block end
725+
726+
function Base.size(bm::AbstractBlockMatrix)
727+
n = mapreduce(
728+
blk -> LinearAlgebra.checksquare(block(bm, blk)),
729+
+,
730+
1:nblocks(bm);
731+
init = 0,
732+
)
733+
return (n, n)
734+
end
735+
736+
function Base.getindex(bm::AbstractBlockMatrix, i::Integer, j::Integer)
737+
(i < 0 || j < 0) && throw(BoundsError(i, j))
738+
for k in 1:nblocks(bm)
739+
blk = block(bm, k)
740+
n = size(blk, 1)
741+
if i <= n && j <= n
742+
return blk[i, j]
743+
elseif i <= n || j <= n
744+
return 0
745+
else
746+
i -= n
747+
j -= n
748+
end
749+
end
750+
i, j = (i, j) .+ size(bm)
751+
throw(BoundsError(i, j))
752+
end
753+
754+
Base.getindex(A::AbstractBlockMatrix, I::Tuple) = getindex(A, I...)
721755

722756
abstract type BlockMat <: AbstractBlockMatrix{Cdouble} end
723757

src/blockdiag.jl

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)