Skip to content

Commit

Permalink
Merge pull request #129 from baggepinnen/patch-1
Browse files Browse the repository at this point in the history
Solve 1x1 factorization problem
  • Loading branch information
MichielStock authored Oct 24, 2023
2 parents a05cd80 + 93b444c commit 71a6996
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vectrick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ for TC in [:AbstractVector, :AbstractMatrix],
# factorization up to the user/Julia
factors = ntuple(length(matrices)) do i
m = matrices[i]
return (m isa Factorization) ? m : factorize(m)
return (m isa Factorization) ? m : unscalar(factorize(m))
end

if length(factors) == 2
Expand All @@ -190,6 +190,10 @@ for TC in [:AbstractVector, :AbstractMatrix],
end
end

# Utility function to handle factorize(one_by_one)::Number
unscalar(n::Number) = [n;;]
unscalar(x) = x

function Base.:*(K::GeneralizedKroneckerProduct, v::AbstractVector)
return mul!(Vector{promote_type(eltype(v), eltype(K))}(undef, first(size(K))), K, v)
end
Expand Down

0 comments on commit 71a6996

Please sign in to comment.