Skip to content

Commit

Permalink
fix transpose! for sparse
Browse files Browse the repository at this point in the history
  • Loading branch information
Jutho committed Nov 11, 2014
1 parent 23210fa commit ba1f731
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions base/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module SparseMatrix

importall Base
import Base.NonTupleType, Base.float, Base.Order, Base.Sort.Forward
import Base.transpose!, Base.ctranspose!

export SparseMatrixCSC,
blkdiag, dense, diag, diagm, droptol!, dropzeros!, etree, full,
Expand Down
8 changes: 4 additions & 4 deletions base/sparse/csparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end
# Based on Direct Methods for Sparse Linear Systems, T. A. Davis, SIAM, Philadelphia, Sept. 2006.
# Section 2.5: Transpose
# http://www.cise.ufl.edu/research/sparse/CSparse/
function transpose!{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti}, T::SparseMatrixCSC{Tv,Ti})
function transpose!{Tv,Ti}(T::SparseMatrixCSC{Tv,Ti}, S::SparseMatrixCSC{Tv,Ti})
(mS, nS) = size(S)
nnzS = nnz(S)
colptr_S = S.colptr
Expand Down Expand Up @@ -162,10 +162,10 @@ function transpose{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti})
nzval_T = Array(Tv, nnzS)

T = SparseMatrixCSC(mT, nT, colptr_T, rowval_T, nzval_T)
return transpose!(S, T)
return transpose!(T, S)
end

function ctranspose!{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti}, T::SparseMatrixCSC{Tv,Ti})
function ctranspose!{Tv,Ti}(T::SparseMatrixCSC{Tv,Ti}, S::SparseMatrixCSC{Tv,Ti})
(mS, nS) = size(S)
nnzS = nnz(S)
colptr_S = S.colptr
Expand Down Expand Up @@ -204,7 +204,7 @@ function ctranspose{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti})
nzval_T = Array(Tv, nnzS)

T = SparseMatrixCSC(mT, nT, colptr_T, rowval_T, nzval_T)
return ctranspose!(S, T)
return ctranspose!(T, S)
end

# Compute the elimination tree of A using triu(A) returning the parent vector.
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2067,8 +2067,8 @@ function sortSparseMatrixCSC!{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}; sortindices::Sym
if sortindices == :doubletranspose
nB, mB = size(A)
B = SparseMatrixCSC(mB, nB, Array(Ti, nB+1), similar(A.rowval), similar(A.nzval))
transpose!(A, B)
transpose!(B, A)
transpose!(A, B)
return A
end

Expand Down

0 comments on commit ba1f731

Please sign in to comment.