@@ -3,52 +3,6 @@ Base.pointer(x::ComponentArray{T,N,<:DenseArray,Axes}) where {T,N,Axes} = pointe
33
44Base. unsafe_convert (:: Type{Ptr{T}} , x:: ComponentArray{T,N,<:DenseArray,Axes} ) where {T,N,Axes} = Base. unsafe_convert (Ptr{T}, getdata (x))
55
6- # Avoid slower fallback
7- for f in [:(* ), :(/ ), :(\ )]
8- @eval begin
9- # The normal stuff
10- Base.$ f (x:: ComponentArray , y:: AbstractArray ) = $ f (getdata (x), y)
11- Base.$ f (x:: AbstractArray , y:: ComponentArray ) = $ f (x, getdata (y))
12- Base.$ f (x:: ComponentArray , y:: ComponentArray ) = $ f (getdata (x), getdata (y))
13-
14- # A bunch of special cases to avoid ambiguous method errors
15- Base.$ f (x:: ComponentArray , y:: AbstractMatrix ) = $ f (getdata (x), y)
16- Base.$ f (x:: AbstractMatrix , y:: ComponentArray ) = $ f (x, getdata (y))
17-
18- Base.$ f (x:: ComponentArray , y:: AbstractVector ) = $ f (getdata (x), y)
19- Base.$ f (x:: AbstractVector , y:: ComponentArray ) = $ f (x, getdata (y))
20- end
21- end
22-
23- # Adjoint/transpose special cases
24- for f in [:(* ), :(/ )]
25- @eval begin
26- Base.$ f (x:: Adjoint , y:: ComponentArray ) = $ f (getdata (x), getdata (y))
27- Base.$ f (x:: Transpose , y:: ComponentArray ) = $ f (getdata (x), getdata (y))
28-
29- Base.$ f (x:: Adjoint{T,<:AbstractVector{T}} , y:: ComponentVector ) where T = $ f (x, getdata (y))
30- Base.$ f (x:: Transpose{T,<:AbstractVector{T}} , y:: ComponentVector ) where T = $ f (x, getdata (y))
31-
32- Base.$ f (x:: Adjoint{T,<:AbstractVector{T}} , y:: ComponentMatrix{T,A,Axes} ) where {T,A,Axes} = $ f (x, getdata (y))
33- Base.$ f (x:: Transpose{T,<:AbstractVector{T}} , y:: ComponentMatrix{T,A,Axes} ) where {T,A,Axes} = $ f (x, getdata (y))
34-
35- Base.$ f (x:: Adjoint{T,<:AbstractMatrix{T}} , y:: ComponentVector ) where {T} = $ f (x, getdata (y))
36- Base.$ f (x:: Transpose{T,<:AbstractMatrix{T}} , y:: ComponentVector ) where {T} = $ f (x, getdata (y))
37-
38- Base.$ f (x:: ComponentArray , y:: Adjoint{T,<:AbstractVector{T}} ) where T = $ f (getdata (x), y)
39- Base.$ f (x:: ComponentArray , y:: Transpose{T,<:AbstractVector{T}} ) where T = $ f (getdata (x), y)
40-
41- Base.$ f (x:: ComponentArray , y:: Adjoint{T,<:ComponentVector} ) where T = $ f (getdata (x), getdata (y))
42- Base.$ f (x:: ComponentArray , y:: Transpose{T,<:ComponentVector} ) where T = $ f (getdata (x), getdata (y))
43-
44- # There seems to be a new method in Julia > v.1.4 that specializes on this
45- Base.$ f (x:: Adjoint{T,<:AbstractVector{T}} , y:: ComponentVector{T,A,Axes} ) where {T<: Number ,A,Axes} = $ f (x, getdata (y))
46- Base.$ f (x:: Transpose{T,<:AbstractVector{T}} , y:: ComponentVector{T,A,Axes} ) where {T<: Number ,A,Axes} = $ f (x, getdata (y))
47-
48- Base.$ f (x:: Adjoint{T,<:AbstractVector{T}} , y:: ComponentVector{T,A,Axes} ) where {T<: Real ,A,Axes} = $ f (getdata (x), getdata (y))
49- Base.$ f (x:: Transpose{T,<:AbstractVector{T}} , y:: ComponentVector{T,A,Axes} ) where {T<: Real ,A,Axes} = $ f (getdata (x), getdata (y))
50- end
51- end
526
537# TODO : All this stuff
548LinearAlgebra. ldiv! (Y:: Union{AbstractMatrix, AbstractVector} , A:: Factorization , b:: Union{ComponentMatrix, ComponentVector} ) =
@@ -69,4 +23,56 @@ ArrayInterface.lu_instance(jac_prototype::ComponentArray) = ArrayInterface.lu_in
6923
7024# # Vector to matrix concatenation
7125Base. hcat (x:: ComponentVector... ) = ComponentArray (hcat (getdata .(x)... ), getaxes (x[1 ])[1 ], FlatAxis ())
72- Base. vcat (x:: AdjOrTransComponentArray... ) = ComponentArray (vcat (map (y-> getdata (y. parent)' , x)... ), getaxes (x[1 ]))
26+ Base. vcat (x:: AdjOrTransComponentArray... ) = ComponentArray (vcat (map (y-> getdata (y. parent)' , x)... ), getaxes (x[1 ]))
27+
28+
29+ # While there are some cases where these were faster, it is going to be almost impossible to
30+ # to keep up with method ambiguity errors due to other array types overloading *, /, and \.
31+ # Leaving these here and commented out for now, but will delete them later.
32+
33+ # # Avoid slower fallback
34+ # for f in [:(*), :(/), :(\)]
35+ # @eval begin
36+ # # The normal stuff
37+ # Base.$f(x::ComponentArray, y::AbstractArray) = $f(getdata(x), y)
38+ # Base.$f(x::AbstractArray, y::ComponentArray) = $f(x, getdata(y))
39+ # Base.$f(x::ComponentArray, y::ComponentArray) = $f(getdata(x), getdata(y))
40+
41+ # # A bunch of special cases to avoid ambiguous method errors
42+ # Base.$f(x::ComponentArray, y::AbstractMatrix) = $f(getdata(x), y)
43+ # Base.$f(x::AbstractMatrix, y::ComponentArray) = $f(x, getdata(y))
44+
45+ # Base.$f(x::ComponentArray, y::AbstractVector) = $f(getdata(x), y)
46+ # Base.$f(x::AbstractVector, y::ComponentArray) = $f(x, getdata(y))
47+ # end
48+ # end
49+
50+ # # Adjoint/transpose special cases
51+ # for f in [:(*), :(/)]
52+ # @eval begin
53+ # Base.$f(x::Adjoint, y::ComponentArray) = $f(getdata(x), getdata(y))
54+ # Base.$f(x::Transpose, y::ComponentArray) = $f(getdata(x), getdata(y))
55+
56+ # Base.$f(x::Adjoint{T,<:AbstractVector{T}}, y::ComponentVector) where T = $f(x, getdata(y))
57+ # Base.$f(x::Transpose{T,<:AbstractVector{T}}, y::ComponentVector) where T = $f(x, getdata(y))
58+
59+ # Base.$f(x::Adjoint{T,<:AbstractVector{T}}, y::ComponentMatrix{T,A,Axes}) where {T,A,Axes} = $f(x, getdata(y))
60+ # Base.$f(x::Transpose{T,<:AbstractVector{T}}, y::ComponentMatrix{T,A,Axes}) where {T,A,Axes} = $f(x, getdata(y))
61+
62+ # Base.$f(x::Adjoint{T,<:AbstractMatrix{T}}, y::ComponentVector) where {T} = $f(x, getdata(y))
63+ # Base.$f(x::Transpose{T,<:AbstractMatrix{T}}, y::ComponentVector) where {T} = $f(x, getdata(y))
64+
65+ # Base.$f(x::ComponentArray, y::Adjoint{T,<:AbstractVector{T}}) where T = $f(getdata(x), y)
66+ # Base.$f(x::ComponentArray, y::Transpose{T,<:AbstractVector{T}}) where T = $f(getdata(x), y)
67+
68+ # Base.$f(x::ComponentArray, y::Adjoint{T,<:ComponentVector}) where T = $f(getdata(x), getdata(y))
69+ # Base.$f(x::ComponentArray, y::Transpose{T,<:ComponentVector}) where T = $f(getdata(x), getdata(y))
70+
71+ # # There seems to be a new method in Julia > v.1.4 that specializes on this
72+ # Base.$f(x::Adjoint{T,<:AbstractVector{T}}, y::ComponentVector{T,A,Axes}) where {T<:Number,A,Axes} = $f(x, getdata(y))
73+ # Base.$f(x::Transpose{T,<:AbstractVector{T}}, y::ComponentVector{T,A,Axes}) where {T<:Number,A,Axes} = $f(x, getdata(y))
74+
75+ # Base.$f(x::Adjoint{T,<:AbstractVector{T}}, y::ComponentVector{T,A,Axes}) where {T<:Real,A,Axes} = $f(getdata(x), getdata(y))
76+ # Base.$f(x::Transpose{T,<:AbstractVector{T}}, y::ComponentVector{T,A,Axes}) where {T<:Real,A,Axes} = $f(getdata(x), getdata(y))
77+ # end
78+ # end
0 commit comments