Skip to content

Commit 90210b4

Browse files
author
Julian
committed
Added specialized solve for size(A)=(2or3, 2or3) and size(B) = (2or3, n)
1 parent 786b6f0 commit 90210b4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/solve.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ end
2626
(a[1,1]*a[2,2] - a[1,2]*a[2,1])*b[3]) / d )
2727
end
2828

29+
for Dim in 2:3 # no improvements for Dim = 1 and if no specialized solve is available
30+
@eval begin
31+
@inline function solve(::Size{($Dim,$Dim)}, ::Size{Sb}, a::StaticMatrix{<:Any, <:Any, Ta}, b::StaticMatrix{<:Any, <:Any, Tb}) where {Sb, Ta, Tb}
32+
d = det(a)
33+
T = typeof((one(Ta)*zero(Tb) + one(Ta)*zero(Tb))/d)
34+
c = similar(b, T)
35+
for col = 1:Sb[2]
36+
@inbounds c[:, col] = solve(Size($Dim,$Dim), Size($Dim,), a, b[:, col])
37+
end
38+
return c
39+
end
40+
end # @eval
41+
end
42+
43+
44+
2945
@generated function solve(::Size{Sa}, ::Size{Sb}, a::StaticMatrix{<:Any, <:Any, Ta}, b::StaticVecOrMat{Tb}) where {Sa, Sb, Ta, Tb}
3046
if Sa[end] != Sb[1]
3147
throw(DimensionMismatch("right hand side B needs first dimension of size $(Sa[end]), has size $Sb"))

0 commit comments

Comments
 (0)