Skip to content

fix a bug when nblock<blockbandwidth #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2019
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
4 changes: 2 additions & 2 deletions src/coloring/high_level.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ function matrix_colors(A::BandedBlockBandedMatrix)
cols=[blocksize(A,(1,i))[2] for i in 1:nblock]
blockcolors=_cycle(1:blockwidth,nblock)
#the reserved number of colors of a block is the min of subblockwidth and the largest length of columns of blocks with the same block color
ncolors=[min(subblockwidth,maximum(cols[i:blockwidth:nblock])) for i in 1:blockwidth]
ncolors=[min(subblockwidth,maximum(cols[i:blockwidth:nblock])) for i in 1:min(blockwidth,nblock)]
endinds=cumsum(ncolors)
startinds=[endinds[i]-ncolors[i]+1 for i in 1:blockwidth]
startinds=[endinds[i]-ncolors[i]+1 for i in 1:min(blockwidth,nblock)]
colors=[_cycle(startinds[blockcolors[i]]:endinds[blockcolors[i]],cols[i]) for i in 1:nblock]
vcat(colors...)
end
2 changes: 2 additions & 0 deletions test/test_specialmatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ blockbanded1=BlockBandedMatrix(dense,([1,2,3,4],[4,3,2,1]),(1,0))
blockbanded2=BlockBandedMatrix(dense,([4,3,2,1],[1,2,3,4]),(1,1))
bandedblockbanded1=BandedBlockBandedMatrix(dense,([1,2,3,4],[4,3,2,1]),(1,0),(1,1))
bandedblockbanded2=BandedBlockBandedMatrix(dense,([4,3,2,1],[1,2,3,4]),(1,1),(1,0))
bandedblockbanded3 = BandedBlockBandedMatrix(Zeros(2 * 4 , 2 * 4), ([4, 4] ,[4, 4]), (1, 1), (1, 1))

@test matrix_colors(dense)==1:n
@test matrix_colors(uptri)==1:n
Expand All @@ -35,6 +36,7 @@ bandedblockbanded2=BandedBlockBandedMatrix(dense,([4,3,2,1],[1,2,3,4]),(1,1),(1,
@test matrix_colors(blockbanded2)==[1,5,6,7,8,9,1,2,3,4]
@test matrix_colors(bandedblockbanded1)==[1,2,3,1,4,5,6,1,2,4]
@test matrix_colors(bandedblockbanded2)==[1,3,4,5,6,5,1,2,1,2]
@test matrix_colors(bandedblockbanded3)==[1,2,3,1,4,5,6,4]

function _testvalidity(A)
colorvec=matrix_colors(A)
Expand Down