Skip to content

Commit

Permalink
Add StridedMatrix definition and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed May 19, 2016
1 parent d9aadd1 commit dc59cac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/sparse/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ Ac_ldiv_B(L::FactorComponent, B) = ctranspose(L)\B
(\){T}(L::Factor{T}, B::Dense{T}) = solve(CHOLMOD_A, L, B)
(\)(L::Factor{Float64}, B::VecOrMat{Complex{Float64}}) = L\real(B) + L\imag(B)
(\)(L::Factor, b::StridedVector) = Vector(L\convert(Dense{eltype(L)}, b))
(\)(L::Factor, B::Matrix) = Matrix(L\convert(Dense{eltype(L)}, B))
(\)(L::Factor, B::StridedMatrix) = Matrix(L\convert(Dense{eltype(L)}, B))
(\)(L::Factor, B::Sparse) = spsolve(CHOLMOD_A, L, B)
# When right hand side is sparse, we have to ensure that the rhs is not marked as symmetric.
(\)(L::Factor, B::SparseVecOrMat) = sparse(spsolve(CHOLMOD_A, L, Sparse(B, 0)))
Expand Down
7 changes: 7 additions & 0 deletions test/sparsedir/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -632,3 +632,10 @@ Fnew = deserialize(b)
@test_throws MethodError cholfact(speye(BigFloat, 5))
@test_throws MethodError cholfact(Symmetric(speye(BigFloat, 5)))
@test_throws MethodError cholfact(Hermitian(speye(Complex{BigFloat}, 5)))

# test \ for Factor and StridedVecOrMat
let x = rand(5)
A = cholfact(sparse(diagm(x.\1)))
@test_approx_eq A\sub(ones(10),1:2:10) x
@test_approx_eq A\slice(eye(5,5),:,:) diagm(x)
end

0 comments on commit dc59cac

Please sign in to comment.