diff --git a/Manifest.toml b/Manifest.toml index ab876d6..f976530 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.7.0" +julia_version = "1.7.2" manifest_format = "2.0" [[deps.Artifacts]] diff --git a/Project.toml b/Project.toml index 352fb95..7a8ee3f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BlockFactorizations" uuid = "5c499583-5bfe-4591-9b59-c1e192d48697" authors = ["Sebastian Ament "] -version = "1.1.0" +version = "1.2.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/block.jl b/src/block.jl index c0bbda0..50971ba 100644 --- a/src/block.jl +++ b/src/block.jl @@ -35,8 +35,9 @@ end function BlockFactorization(A::AbstractMatrix, di::Int, dj::Int = di) BlockFactorization(A, 1:di:di*size(A, 1)+1, 1:dj:dj*size(A, 2)+1) end + # strided = true assumes that A has strided block indices, i.e. every element has the same size -function BlockFactorization(A::AbstractMatrix, isstrided::Bool = false) +function BlockFactorization(A::AbstractMatrix; isstrided::Bool = false) if isstrided di, dj = size(A[1, 1]) nind, mind = 1:di:di*size(A, 1)+1, 1:dj:dj*size(A, 2)+1 diff --git a/test/block.jl b/test/block.jl index 4497aff..368e9e3 100644 --- a/test/block.jl +++ b/test/block.jl @@ -22,9 +22,8 @@ using Test # test general constructor di, dj = size(A[1]) n, m = size(A) - isstrided = true strided_factorizations = [BlockFactorization(A), - BlockFactorization(A, isstrided), + BlockFactorization(A, isstrided = true), BlockFactorization(A, di, dj)] # stride_matrices = [A, A, A, D, D, D] # matrices corresponding to strided_factorizations for F in strided_factorizations @@ -54,6 +53,9 @@ using Test @test length(diagF) == minimum(size(M)) @test diagF ≈ diag(M) end + allo_1 = @allocated BlockFactorization(A, isstrided = true) + allo_2 = @allocated BlockFactorization(A, isstrided = false) + @test allo_1 < allo_2 end # general, non-strided block matrix @@ -69,9 +71,8 @@ using Test matrices = [A, Diagonal(A)] for A in matrices - isstrided = false factorizations = [BlockFactorization(A), - BlockFactorization(A, isstrided), + BlockFactorization(A, isstrided = false), BlockFactorization(A, nindices, mindices) ] for F in factorizations @@ -116,7 +117,7 @@ using Test A11 = Diagonal(randn(elty_A, n)) A12 = randn(elty_A, n, n) A21 = UpperTriangular(randn(elty_A, n, n)) - A22 = cholesky(A21'A21) + A22 = cholesky(Hermitian(A21'A21)) A = reshape([A11, A12, A21, A22], 2, :) @test eltype(A) == Any B = BlockFactorization(A)