Skip to content

Commit 6abe30e

Browse files
Merge pull request #33 from dlfivefifty/patch-1
Update for new BlockArrays
2 parents cceb14c + 9df418f commit 6abe30e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/ArrayInterface.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -427,20 +427,20 @@ function __init__()
427427
@require BlockBandedMatrices="ffab5731-97b5-5995-9138-79e8c1846df0" begin
428428
function findstructralnz(x::BlockBandedMatrices.BlockBandedMatrix)
429429
l,u=BlockBandedMatrices.blockbandwidths(x)
430-
nrowblock=BlockBandedMatrices.nblocks(x,1)
431-
ncolblock=BlockBandedMatrices.nblocks(x,2)
432-
rowsizes=[BlockBandedMatrices.blocksize(x,(i,1))[1] for i in 1:nrowblock]
433-
colsizes=[BlockBandedMatrices.blocksize(x,(1,i))[2] for i in 1:ncolblock]
430+
nrowblock=BlockBandedMatrices.blocksize(x,1)
431+
ncolblock=BlockBandedMatrices.blocksize(x,2)
432+
rowsizes=BlockBandedMatrices.blocklengths(axes(x,1))
433+
colsizes=BlockBandedMatrices.blocklengths(axes(x,2))
434434
BlockBandedMatrixIndex(nrowblock,ncolblock,rowsizes,colsizes,l,u)
435435
end
436436

437437
function findstructralnz(x::BlockBandedMatrices.BandedBlockBandedMatrix)
438438
l,u=BlockBandedMatrices.blockbandwidths(x)
439439
lambda,mu=BlockBandedMatrices.subblockbandwidths(x)
440-
nrowblock=BlockBandedMatrices.nblocks(x,1)
441-
ncolblock=BlockBandedMatrices.nblocks(x,2)
442-
rowsizes=[BlockBandedMatrices.blocksize(x,(i,1))[1] for i in 1:nrowblock]
443-
colsizes=[BlockBandedMatrices.blocksize(x,(1,i))[2] for i in 1:ncolblock]
440+
nrowblock=BlockBandedMatrices.blocksize(x,1)
441+
ncolblock=BlockBandedMatrices.blocksize(x,2)
442+
rowsizes=BlockBandedMatrices.blocklengths(axes(x,1))
443+
colsizes=BlockBandedMatrices.blocklengths(axes(x,2))
444444
BandedBlockBandedMatrixIndex(nrowblock,ncolblock,rowsizes,colsizes,l,u,lambda,mu)
445445
end
446446

@@ -454,8 +454,8 @@ function __init__()
454454
function matrix_colors(A::BlockBandedMatrices.BlockBandedMatrix)
455455
l,u=BlockBandedMatrices.blockbandwidths(A)
456456
blockwidth=l+u+1
457-
nblock=BlockBandedMatrices.nblocks(A,2)
458-
cols=[BlockBandedMatrices.blocksize(A,(1,i))[2] for i in 1:nblock]
457+
nblock=BlockBandedMatrices.blocksize(A,2)
458+
cols=blocklengths(axes(A,2))
459459
blockcolors=_cycle(1:blockwidth,nblock)
460460
#the reserved number of colors of a block is the maximum length of columns of blocks with the same block color
461461
ncolors=[maximum(cols[i:blockwidth:nblock]) for i in 1:blockwidth]
@@ -470,8 +470,8 @@ function __init__()
470470
lambda,mu=BlockBandedMatrices.subblockbandwidths(A)
471471
blockwidth=l+u+1
472472
subblockwidth=lambda+mu+1
473-
nblock=BlockBandedMatrices.nblocks(A,2)
474-
cols=[BlockBandedMatrices.blocksize(A,(1,i))[2] for i in 1:nblock]
473+
nblock=BlockBandedMatrices.blocksize(A,2)
474+
cols=blocklengths(axes(A,2))
475475
blockcolors=_cycle(1:blockwidth,nblock)
476476
#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
477477
ncolors=[min(subblockwidth,maximum(cols[i:blockwidth:nblock])) for i in 1:min(blockwidth,nblock)]

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ rowind,colind=findstructralnz(B)
6262
@test [B[rowind[i],colind[i]] for i in 1:length(rowind)]==[5,6,7,8,1,2,3,4]
6363

6464
using BlockBandedMatrices
65-
BB=BlockBandedMatrix(Ones(10,10),([1,2,3,4],[4,3,2,1]),(1,0))
65+
BB=BlockBandedMatrix(Ones(10,10),[1,2,3,4],[4,3,2,1],(1,0))
6666
BB[Block(1,1)].=[1 2 3 4]
6767
BB[Block(2,1)].=[5 6 7 8;9 10 11 12]
6868
rowind,colind=findstructralnz(BB)
@@ -76,7 +76,7 @@ dense=collect(Ones(8,8))
7676
for i in 1:8
7777
dense[:,i].=[1,2,3,4,5,6,7,8]
7878
end
79-
BBB=BandedBlockBandedMatrix(dense, ([4, 4] ,[4, 4]), (1, 1), (1, 1))
79+
BBB=BandedBlockBandedMatrix(dense, [4, 4] ,[4, 4], (1, 1), (1, 1))
8080
rowind,colind=findstructralnz(BBB)
8181
@test [BBB[rowind[i],colind[i]] for i in 1:length(rowind)]==
8282
[1,2,3,1,2,3,4,2,3,4,5,6,7,5,6,7,8,6,7,8,

0 commit comments

Comments
 (0)