@@ -229,24 +229,22 @@ end
229
229
# Note that while [1 2; 3 4]' isa Adjoint, we use ProjectTo{Adjoint} only to encode AdjointAbsVec.
230
230
# Transposed matrices are, like PermutedDimsArray, just a storage detail,
231
231
# but row vectors behave differently, for example [1,2,3]' * [1,2,3] isa Number
232
- (project:: ProjectTo{Adjoint} )(dx:: Adjoint ) = adjoint (project. parent (parent (dx)))
233
- (project:: ProjectTo{Adjoint} )(dx:: Transpose ) = adjoint (adjoint .(project. parent (parent (dx)))) # might copy twice?
232
+ (project:: ProjectTo{Adjoint} )(dx:: LinearAlgebra.AdjOrTransAbsVec ) = adjoint (project. parent (adjoint (dx)))
234
233
function (project:: ProjectTo{Adjoint} )(dx:: AbstractArray )
235
234
size (dx,1 ) == 1 && size (dx,2 ) == length (project. parent. axes[1 ]) || throw (_projection_mismatch ((1 : 1 , project. parent. axes... ), size (dx)))
236
- dy = project . parent ( adjoint (dx))
237
- return adjoint (dy )
235
+ dy = eltype (dx) <: Real ? vec (dx) : adjoint (dx )
236
+ return adjoint (project . parent (dy) )
238
237
end
239
238
240
239
function ProjectTo (x:: LinearAlgebra.TransposeAbsVec )
241
240
sub = ProjectTo (parent (x))
242
241
ProjectTo {Transpose} (; parent= sub)
243
242
end
244
- (project:: ProjectTo{Transpose} )(dx:: Transpose ) = transpose (project. parent (parent (dx)))
245
- (project:: ProjectTo{Transpose} )(dx:: Adjoint ) = transpose (adjoint .(project. parent (parent (dx))))
243
+ (project:: ProjectTo{Transpose} )(dx:: LinearAlgebra.AdjOrTransAbsVec ) = transpose (project. parent (transpose (dx)))
246
244
function (project:: ProjectTo{Transpose} )(dx:: AbstractArray )
247
245
size (dx,1 ) == 1 && size (dx,2 ) == length (project. parent. axes[1 ]) || throw (_projection_mismatch ((1 : 1 , project. parent. axes... ), size (dx)))
248
- dy = project . parent ( transpose (dx))
249
- return transpose (dy )
246
+ dy = eltype (dx) <: Number ? vec (dx) : transpose (dx )
247
+ return transpose (project . parent (dy) )
250
248
end
251
249
252
250
# Diagonal
0 commit comments