Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] SparseVector #11424

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export
BLAS,
LAPACK,
Serializer,
SparseMatrix,
Sparse,
Docs,
Markdown,

Expand Down Expand Up @@ -103,6 +103,7 @@ export
SharedArray,
SharedMatrix,
SharedVector,
SparseVector,
SparseMatrixCSC,
StatStruct,
StepRange,
Expand Down
12 changes: 12 additions & 0 deletions base/functors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ call(::OrFun, x, y) = x | y
immutable AddFun <: Func{2} end
call(::AddFun, x, y) = x + y

immutable SubFun <: Func{2} end
call(::SubFun, x, y) = x - y

immutable MulFun <: Func{2} end
call(::MulFun, x, y) = x * y

immutable DivFun <: Func{2} end
call(::DivFun, x, y) = x / y

immutable PowFun <: Func{2} end
call(::PowFun, x, y) = x ^ y

immutable MaxFun <: Func{2} end
call(::MaxFun, x, y) = scalarmax(x,y)

Expand Down Expand Up @@ -119,7 +128,10 @@ function specialized_unary(f::Function)
end
function specialized_binary(f::Function)
is(f, +) ? AddFun() :
is(f, -) ? SubFun() :
is(f, *) ? MulFun() :
is(f, /) ? DivFun() :
is(f, ^) ? PowFun() :
is(f, &) ? AndFun() :
is(f, |) ? OrFun() :
UnspecializedFun{2}(f)
Expand Down
8 changes: 5 additions & 3 deletions base/sparse.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

module SparseMatrix
module Sparse

using Base: Func, AddFun, OrFun, ConjFun, IdFun
using Base: Func, AddFun, SubFun, OrFun, ConjFun, IdFun
using Base.Sort: Forward
using Base.LinAlg: AbstractTriangular

Expand All @@ -12,12 +12,14 @@ import Base.promote_eltype
import Base.@get!
import Base.Broadcast.eltype_plus, Base.Broadcast.broadcast_shape

export AbstractSparseArray, AbstractSparseMatrix, AbstractSparseVector, SparseMatrixCSC,
export AbstractSparseArray, AbstractSparseMatrix, AbstractSparseVector,
SparseVector, SparseMatrixCSC,
blkdiag, dense, droptol!, dropzeros!, etree, issparse, nnz, nonzeros, nzrange,
rowvals, sparse, sparsevec, spdiagm, speye, spones, sprand, sprandbool, sprandn,
spzeros, symperm

include("sparse/abstractsparse.jl")
include("sparse/sparsevector.jl")
include("sparse/sparsematrix.jl")
include("sparse/csparse.jl")

Expand Down
4 changes: 2 additions & 2 deletions base/sparse/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import Base.LinAlg: (\), A_mul_Bc, A_mul_Bt, Ac_ldiv_B, Ac_mul_B, At_ldiv_B, At_
cholfact, det, diag, ishermitian, isposdef,
issym, ldltfact, logdet

import Base.SparseMatrix: sparse, nnz
import Base.Sparse: sparse, nnz

export
Dense,
Factor,
Sparse

using Base.SparseMatrix: AbstractSparseMatrix, SparseMatrixCSC, increment, indtype
using Base.Sparse: AbstractSparseMatrix, SparseMatrixCSC, increment, indtype

#########
# Setup #
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function spmatmul{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, B::SparseMatrixCSC{Tv,Ti};

# The Gustavson algorithm does not guarantee the product to have sorted row indices.
Cunsorted = SparseMatrixCSC(mA, nB, colptrC, rowvalC, nzvalC)
C = Base.SparseMatrix.sortSparseMatrixCSC!(Cunsorted, sortindices=sortindices)
C = Base.Sparse.sortSparseMatrixCSC!(Cunsorted, sortindices=sortindices)
return C
end

Expand Down
Loading