@@ -34,10 +34,6 @@ julia> adjoint(A)
34
34
"""
35
35
struct Adjoint{T,S} <: AbstractMatrix{T}
36
36
parent:: S
37
- function Adjoint {T,S} (A:: S ) where {T,S}
38
- checkeltype_adjoint (T, eltype (A))
39
- new (A)
40
- end
41
37
end
42
38
"""
43
39
Transpose
@@ -65,30 +61,6 @@ julia> transpose(A)
65
61
"""
66
62
struct Transpose{T,S} <: AbstractMatrix{T}
67
63
parent:: S
68
- function Transpose {T,S} (A:: S ) where {T,S}
69
- checkeltype_transpose (T, eltype (A))
70
- new (A)
71
- end
72
- end
73
-
74
- function checkeltype_adjoint (:: Type{ResultEltype} , :: Type{ParentEltype} ) where {ResultEltype,ParentEltype}
75
- Expected = Base. promote_op (adjoint, ParentEltype)
76
- ResultEltype === Expected || error (string (
77
- " Element type mismatch. Tried to create an `Adjoint{" , ResultEltype, " }` " ,
78
- " from an object with eltype `" , ParentEltype, " `, but the element type of " ,
79
- " the adjoint of an object with eltype `" , ParentEltype, " ` must be " ,
80
- " `" , Expected, " `." ))
81
- return nothing
82
- end
83
-
84
- function checkeltype_transpose (:: Type{ResultEltype} , :: Type{ParentEltype} ) where {ResultEltype, ParentEltype}
85
- Expected = Base. promote_op (transpose, ParentEltype)
86
- ResultEltype === Expected || error (string (
87
- " Element type mismatch. Tried to create a `Transpose{" , ResultEltype, " }` " ,
88
- " from an object with eltype `" , ParentEltype, " `, but the element type of " ,
89
- " the transpose of an object with eltype `" , ParentEltype, " ` must be " ,
90
- " `" , Expected, " `." ))
91
- return nothing
92
64
end
93
65
94
66
# basic outer constructors
@@ -203,8 +175,8 @@ axes(v::AdjOrTransAbsVec) = (Base.OneTo(1), axes(v.parent)...)
203
175
axes (A:: AdjOrTransAbsMat ) = reverse (axes (A. parent))
204
176
IndexStyle (:: Type{<:AdjOrTransAbsVec} ) = IndexLinear ()
205
177
IndexStyle (:: Type{<:AdjOrTransAbsMat} ) = IndexCartesian ()
206
- @propagate_inbounds getindex (v:: AdjOrTransAbsVec , i:: Int ) = wrapperop (v)(v. parent[i- 1 + first (axes (v. parent)[1 ])])
207
- @propagate_inbounds getindex (A:: AdjOrTransAbsMat , i:: Int , j:: Int ) = wrapperop (A)(A. parent[j, i])
178
+ @propagate_inbounds getindex (v:: AdjOrTransAbsVec{T} , i:: Int ) where {T} = wrapperop (v)(v. parent[i- 1 + first (axes (v. parent)[1 ])]):: T
179
+ @propagate_inbounds getindex (A:: AdjOrTransAbsMat{T} , i:: Int , j:: Int ) where {T} = wrapperop (A)(A. parent[j, i]):: T
208
180
@propagate_inbounds setindex! (v:: AdjOrTransAbsVec , x, i:: Int ) = (setindex! (v. parent, wrapperop (v)(x), i- 1 + first (axes (v. parent)[1 ])); v)
209
181
@propagate_inbounds setindex! (A:: AdjOrTransAbsMat , x, i:: Int , j:: Int ) = (setindex! (A. parent, wrapperop (A)(x), j, i); A)
210
182
# AbstractArray interface, additional definitions to retain wrapper over vectors where appropriate
0 commit comments