Skip to content
Merged
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
10 changes: 5 additions & 5 deletions src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ const WrapperMatrixTypes{T,MT} = Union{
Hermitian{T,MT},
}

function dot(A::Union{DenseMatrixUnion,WrapperMatrixTypes{<:Any,Union{DenseMatrixUnion,AbstractSparseMatrix}}}, B::AbstractSparseMatrixCSC)
function dot(A::Union{DenseMatrixUnion,WrapperMatrixTypes{<:Any,<:Union{DenseMatrixUnion,AbstractSparseMatrix}}}, B::AbstractSparseMatrixCSC)
T = promote_type(eltype(A), eltype(B))
(m, n) = size(A)
if (m, n) != size(B)
Expand All @@ -663,7 +663,7 @@ function dot(A::Union{DenseMatrixUnion,WrapperMatrixTypes{<:Any,Union{DenseMatri
return s
end

function dot(A::AbstractSparseMatrixCSC, B::Union{DenseMatrixUnion,WrapperMatrixTypes{<:Any,Union{DenseMatrixUnion,AbstractSparseMatrix}}})
function dot(A::AbstractSparseMatrixCSC, B::Union{DenseMatrixUnion,WrapperMatrixTypes{<:Any,<:Union{DenseMatrixUnion,AbstractSparseMatrix}}})
return conj(dot(B, A))
end

Expand Down Expand Up @@ -1210,7 +1210,7 @@ function nzrangelo(A, i, excl=false)
@inbounds r2 < r1 || rv[r1] >= i + excl ? r : (searchsortedfirst(view(rv, r1:r2), i + excl) + r1-1):r2
end

dot(x::AbstractVector, A::RealHermSymComplexHerm{<:Any,<:AbstractSparseMatrixCSC}, y::AbstractVector) =
dot(x::AbstractVector, A::RealHermSymComplexHerm{<:Real,<:AbstractSparseMatrixCSC}, y::AbstractVector) =
_dot(x, parent(A), y, A.uplo == 'U' ? nzrangeup : nzrangelo, A isa Symmetric ? identity : real, A isa Symmetric ? transpose : adjoint)
function _dot(x::AbstractVector, A::AbstractSparseMatrixCSC, y::AbstractVector, rangefun::Function, diagop::Function, odiagop::Function)
require_one_based_indexing(x, y)
Expand Down Expand Up @@ -1242,7 +1242,7 @@ function _dot(x::AbstractVector, A::AbstractSparseMatrixCSC, y::AbstractVector,
end
return r
end
dot(x::SparseVector, A::RealHermSymComplexHerm{<:Any,<:AbstractSparseMatrixCSC}, y::SparseVector) =
dot(x::SparseVector, A::RealHermSymComplexHerm{<:Real,<:AbstractSparseMatrixCSC}, y::SparseVector) =
_dot(x, parent(A), y, A.uplo == 'U' ? nzrangeup : nzrangelo, A isa Symmetric ? identity : real)
function _dot(x::SparseVector, A::AbstractSparseMatrixCSC, y::SparseVector, rangefun::Function, diagop::Function)
m, n = size(A)
Expand Down Expand Up @@ -1577,7 +1577,7 @@ function cond(A::AbstractSparseMatrixCSC, p::Real=2)
normA = opnorm(A, Inf)
return normA * normAinv
elseif p == 2
throw(ArgumentError("2-norm condition number is not implemented for sparse matrices, try cond(Array(A), 2) instead"))
throw(ArgumentError("only 1- and Inf-norm condition numbers are implemented for sparse matrices, for 2-norm try cond(Array(A), 2) instead"))
else
throw(ArgumentError("second argument must be either 1 or Inf, got $p"))
end
Expand Down
9 changes: 6 additions & 3 deletions src/readonly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ ReadOnly(x::ReadOnly) = x
Base.getproperty(x::ReadOnly, s::Symbol) = Base.getproperty(parent(x), s)
@inline Base.parent(x::ReadOnly) = getfield(x, :parent)

for i in [:length, :first, :last, :eachindex, :firstindex, :lastindex, :eltype]
for i in [:length, :first, :last, :axes, :size]
@eval Base.@propagate_inbounds @inline Base.$i(x::ReadOnly) = Base.$i(parent(x))
end
for i in [:iterate, :axes, :getindex, :size, :strides]
for i in [:iterate, :getindex, :strides]
@eval(Base.@propagate_inbounds @inline Base.$i(x::ReadOnly, y...) = Base.$i(parent(x), y...))
end

Base.eachindex(i::IndexLinear, x::ReadOnly) = eachindex(i, parent(x))
Base.eachindex(i::IndexCartesian, x::ReadOnly) = eachindex(i, parent(x))

Base.unsafe_convert(x::Type{Ptr{T}}, A::ReadOnly) where T = Base.unsafe_convert(x, parent(A))
Base.elsize(::Type{ReadOnly{T,N,V}}) where {T,N,V} = Base.elsize(V)
Base.@propagate_inbounds @inline Base.setindex!(x::ReadOnly, v, ind...) = if v == getindex(parent(x), ind...)
Base.@propagate_inbounds @inline Base.setindex!(x::ReadOnly, v, ind::Vararg{Integer}) = if v == getindex(parent(x), ind...)
v
else
error("Can't change $(typeof(x)).")
Expand Down
3 changes: 1 addition & 2 deletions src/solvers/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ end
size(F::Factor) = (size(F, 1), size(F, 2))
axes(A::Union{Dense,Sparse,Factor}) = map(Base.OneTo, size(A))

IndexStyle(::Dense) = IndexLinear()
IndexStyle(::Type{<:Dense}) = IndexLinear()

size(FC::FactorComponent, i::Integer) = size(FC.F, i)
size(FC::FactorComponent) = size(FC.F)
Expand All @@ -1370,7 +1370,6 @@ function getindex(A::Dense{T}, i::Integer) where {T<:VTypes}
unsafe_load(Ptr{T}(s.x), i)
end

IndexStyle(::Sparse) = IndexCartesian()
function getindex(A::Sparse{T}, i0::Integer, i1::Integer) where T
s = unsafe_load(typedpointer(A))
!(1 <= i0 <= s.nrow && 1 <= i1 <= s.ncol) && throw(BoundsError())
Expand Down
5 changes: 3 additions & 2 deletions test/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -919,11 +919,12 @@ end
@test dot(x, A, y) ≈ dot(x, Av, y)
end

for (T, trans) in ((Float64, Symmetric), (ComplexF64, Hermitian)), uplo in (:U, :L)
for (T, trans) in ((Float64, Symmetric), (ComplexF64, Symmetric), (ComplexF64, Hermitian)), uplo in (:U, :L)
B = sprandn(T, 10, 10, 0.2)
x = sprandn(T, 10, 0.4)
S = trans(B'B, uplo)
@test dot(x, S, x) ≈ dot(Vector(x), S, Vector(x)) ≈ dot(Vector(x), Matrix(S), Vector(x))
Sd = trans(Matrix(B'B), uplo)
@test dot(x, S, x) ≈ dot(x, Sd, x) ≈ dot(Vector(x), S, Vector(x)) ≈ dot(Vector(x), Sd, Vector(x))
end
end

Expand Down
Loading