From 93b444cb2a7b423b3050d9fb170c35c033cf81bd Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Tue, 27 Jun 2023 08:39:21 +0200 Subject: [PATCH] Solve 1x1 factorization problem Closes #128 --- src/vectrick.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vectrick.jl b/src/vectrick.jl index a14bfc8..cf948b6 100644 --- a/src/vectrick.jl +++ b/src/vectrick.jl @@ -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 @@ -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