Skip to content

Commit

Permalink
changed constructor syntax for isstrided flag
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianAment committed Apr 11, 2022
1 parent 3df0270 commit 924cfe2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
@@ -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]]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BlockFactorizations"
uuid = "5c499583-5bfe-4591-9b59-c1e192d48697"
authors = ["Sebastian Ament <sebastianeament@gmail.com>"]
version = "1.1.0"
version = "1.2.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
3 changes: 2 additions & 1 deletion src/block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions test/block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 924cfe2

Please sign in to comment.