@@ -425,62 +425,63 @@ function __init__()
425
425
end
426
426
427
427
@require BlockBandedMatrices= " ffab5731-97b5-5995-9138-79e8c1846df0" begin
428
- function findstructralnz (x:: BlockBandedMatrices.BlockBandedMatrix )
429
- l,u= BlockBandedMatrices. blockbandwidths (x)
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 ))
434
- BlockBandedMatrixIndex (nrowblock,ncolblock,rowsizes,colsizes,l,u)
435
- end
428
+ @require BlockArrays= " 8e7c35d0-a365-5155-bbbb-fb81a777f24e" begin
429
+ function findstructralnz (x:: BlockBandedMatrices.BlockBandedMatrix )
430
+ l,u= BlockBandedMatrices. blockbandwidths (x)
431
+ nrowblock= BlockBandedMatrices. blocksize (x,1 )
432
+ ncolblock= BlockBandedMatrices. blocksize (x,2 )
433
+ rowsizes= BlockArrays. blocklengths (axes (x,1 ))
434
+ colsizes= BlockArrays. blocklengths (axes (x,2 ))
435
+ BlockBandedMatrixIndex (nrowblock,ncolblock,rowsizes,colsizes,l,u)
436
+ end
436
437
437
- function findstructralnz (x:: BlockBandedMatrices.BandedBlockBandedMatrix )
438
- l,u= BlockBandedMatrices. blockbandwidths (x)
439
- lambda,mu= BlockBandedMatrices. subblockbandwidths (x)
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 ))
444
- BandedBlockBandedMatrixIndex (nrowblock,ncolblock,rowsizes,colsizes,l,u,lambda,mu)
445
- end
438
+ function findstructralnz (x:: BlockBandedMatrices.BandedBlockBandedMatrix )
439
+ l,u= BlockBandedMatrices. blockbandwidths (x)
440
+ lambda,mu= BlockBandedMatrices. subblockbandwidths (x)
441
+ nrowblock= BlockBandedMatrices. blocksize (x,1 )
442
+ ncolblock= BlockBandedMatrices. blocksize (x,2 )
443
+ rowsizes= BlockArrays . blocklengths (axes (x,1 ))
444
+ colsizes= BlockArrays . blocklengths (axes (x,2 ))
445
+ BandedBlockBandedMatrixIndex (nrowblock,ncolblock,rowsizes,colsizes,l,u,lambda,mu)
446
+ end
446
447
447
- has_sparsestruct (:: Type{<:BlockBandedMatrices.BlockBandedMatrix} ) = true
448
- has_sparsestruct (:: Type{<:BlockBandedMatrices.BandedBlockBandedMatrix} ) = true
449
- is_structured (:: Type{<:BlockBandedMatrices.BlockBandedMatrix} ) = true
450
- is_structured (:: Type{<:BlockBandedMatrices.BandedBlockBandedMatrix} ) = true
451
- fast_matrix_colors (:: Type{<:BlockBandedMatrices.BlockBandedMatrix} ) = true
452
- fast_matrix_colors (:: Type{<:BlockBandedMatrices.BandedBlockBandedMatrix} ) = true
453
-
454
- function matrix_colors (A:: BlockBandedMatrices.BlockBandedMatrix )
455
- l,u= BlockBandedMatrices. blockbandwidths (A)
456
- blockwidth= l+ u+ 1
457
- nblock= BlockBandedMatrices. blocksize (A,2 )
458
- cols= blocklengths (axes (A,2 ))
459
- blockcolors= _cycle (1 : blockwidth,nblock)
460
- # the reserved number of colors of a block is the maximum length of columns of blocks with the same block color
461
- ncolors= [maximum (cols[i: blockwidth: nblock]) for i in 1 : blockwidth]
462
- endinds= cumsum (ncolors)
463
- startinds= [endinds[i]- ncolors[i]+ 1 for i in 1 : blockwidth]
464
- colors= [(startinds[blockcolors[i]]: endinds[blockcolors[i]])[1 : cols[i]] for i in 1 : nblock]
465
- vcat (colors... )
466
- end
448
+ has_sparsestruct (:: Type{<:BlockBandedMatrices.BlockBandedMatrix} ) = true
449
+ has_sparsestruct (:: Type{<:BlockBandedMatrices.BandedBlockBandedMatrix} ) = true
450
+ is_structured (:: Type{<:BlockBandedMatrices.BlockBandedMatrix} ) = true
451
+ is_structured (:: Type{<:BlockBandedMatrices.BandedBlockBandedMatrix} ) = true
452
+ fast_matrix_colors (:: Type{<:BlockBandedMatrices.BlockBandedMatrix} ) = true
453
+ fast_matrix_colors (:: Type{<:BlockBandedMatrices.BandedBlockBandedMatrix} ) = true
454
+
455
+ function matrix_colors (A:: BlockBandedMatrices.BlockBandedMatrix )
456
+ l,u= BlockBandedMatrices. blockbandwidths (A)
457
+ blockwidth= l+ u+ 1
458
+ nblock= BlockBandedMatrices. blocksize (A,2 )
459
+ cols= BlockArrays . blocklengths (axes (A,2 ))
460
+ blockcolors= _cycle (1 : blockwidth,nblock)
461
+ # the reserved number of colors of a block is the maximum length of columns of blocks with the same block color
462
+ ncolors= [maximum (cols[i: blockwidth: nblock]) for i in 1 : blockwidth]
463
+ endinds= cumsum (ncolors)
464
+ startinds= [endinds[i]- ncolors[i]+ 1 for i in 1 : blockwidth]
465
+ colors= [(startinds[blockcolors[i]]: endinds[blockcolors[i]])[1 : cols[i]] for i in 1 : nblock]
466
+ vcat (colors... )
467
+ end
467
468
468
- function matrix_colors (A:: BlockBandedMatrices.BandedBlockBandedMatrix )
469
- l,u= BlockBandedMatrices. blockbandwidths (A)
470
- lambda,mu= BlockBandedMatrices. subblockbandwidths (A)
471
- blockwidth= l+ u+ 1
472
- subblockwidth= lambda+ mu+ 1
473
- nblock= BlockBandedMatrices. blocksize (A,2 )
474
- cols= blocklengths (axes (A,2 ))
475
- blockcolors= _cycle (1 : blockwidth,nblock)
476
- # 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
477
- ncolors= [min (subblockwidth,maximum (cols[i: blockwidth: nblock])) for i in 1 : min (blockwidth,nblock)]
478
- endinds= cumsum (ncolors)
479
- startinds= [endinds[i]- ncolors[i]+ 1 for i in 1 : min (blockwidth,nblock)]
480
- colors= [_cycle (startinds[blockcolors[i]]: endinds[blockcolors[i]],cols[i]) for i in 1 : nblock]
481
- vcat (colors... )
469
+ function matrix_colors (A:: BlockBandedMatrices.BandedBlockBandedMatrix )
470
+ l,u= BlockBandedMatrices. blockbandwidths (A)
471
+ lambda,mu= BlockBandedMatrices. subblockbandwidths (A)
472
+ blockwidth= l+ u+ 1
473
+ subblockwidth= lambda+ mu+ 1
474
+ nblock= BlockBandedMatrices. blocksize (A,2 )
475
+ cols= BlockArrays. blocklengths (axes (A,2 ))
476
+ blockcolors= _cycle (1 : blockwidth,nblock)
477
+ # 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
478
+ ncolors= [min (subblockwidth,maximum (cols[i: blockwidth: nblock])) for i in 1 : min (blockwidth,nblock)]
479
+ endinds= cumsum (ncolors)
480
+ startinds= [endinds[i]- ncolors[i]+ 1 for i in 1 : min (blockwidth,nblock)]
481
+ colors= [_cycle (startinds[blockcolors[i]]: endinds[blockcolors[i]],cols[i]) for i in 1 : nblock]
482
+ vcat (colors... )
483
+ end
482
484
end
483
-
484
485
end
485
486
end
486
487
0 commit comments