Skip to content

Commit

Permalink
Solve 1x1 factorization problem
Browse files Browse the repository at this point in the history
Closes #128
  • Loading branch information
baggepinnen authored Jun 27, 2023
1 parent a05cd80 commit 93b444c
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 93b444c

Please sign in to comment.