Skip to content

Commit

Permalink
Some more rearrangement
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Ferris committed Sep 14, 2017
1 parent e7914c3 commit dfee60c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 44 deletions.
42 changes: 42 additions & 0 deletions base/linalg/adjoint.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

adjoint(a::AbstractArray) = error("adjoint not defined for $(typeof(a)). Consider using `permutedims` for higher-dimensional arrays.")

## Matrix adjoint ##

"""
adjoint!(dest,src)
Conjugate transpose array `src` and store the result in the preallocated array `dest`, which
should have a size corresponding to `(size(src,2),size(src,1))`. No in-place transposition
is supported and unexpected results will happen if `src` and `dest` have overlapping memory
regions.
"""
adjoint!(B::AbstractMatrix, A::AbstractMatrix) = transpose_f!(adjoint, B, A)
function adjoint!(B::AbstractVector, A::AbstractMatrix)
indices(B,1) == indices(A,2) && indices(A,1) == 1:1 || throw(DimensionMismatch("transpose"))
adjointcopy!(B, A)
end
function adjoint!(B::AbstractMatrix, A::AbstractVector)
indices(B,2) == indices(A,1) && indices(B,1) == 1:1 || throw(DimensionMismatch("transpose"))
adjointcopy!(B, A)
end

function adjointcopy!(B, A)
RB, RA = eachindex(B), eachindex(A)
if RB == RA
for i = RB
B[i] = adjoint(A[i])
end
else
for (i,j) = zip(RB, RA)
B[i] = adjoint(A[j])
end
end
end

function adjoint(A::AbstractMatrix)
ind1, ind2 = indices(A)
B = similar(A, adjoint_type(eltype(A)), (ind2, ind1))
adjoint!(B, A)
end
3 changes: 1 addition & 2 deletions base/linalg/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ end


include("conjarray.jl")
include("transpose.jl")
include("adjoint.jl")
include("rowvector.jl")

include("exceptions.jl")
Expand Down Expand Up @@ -297,7 +297,6 @@ include("bitarray.jl")
include("ldlt.jl")
include("schur.jl")


include("arpack.jl")
include("arnoldi.jl")

Expand Down
42 changes: 0 additions & 42 deletions base/linalg/transpose.jl

This file was deleted.

0 comments on commit dfee60c

Please sign in to comment.