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

Fix nightly issue #36

Merged
merged 4 commits into from
Sep 25, 2023
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
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
SparseMatricesCOO = "fa32481b-f100-4b48-8dc8-c62f61b13870"

[compat]
Documenter = "1.0"
1 change: 0 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ makedocs(;
modules = [SparseMatricesCOO],
doctest = true,
linkcheck = false,
strict = true,
authors = "Dominique Orban <[email protected]> and contributors",
repo = "https://github.com/JuliaSmoothOptimizers/SparseMatricesCOO.jl/blob/{commit}{path}#{line}",
sitename = "SparseMatricesCOO.jl",
Expand Down
109 changes: 68 additions & 41 deletions src/coo_linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,30 @@ function coo_mul!(C::AbstractMatrix, Arows, Acols, Avals, B::AbstractMatrix, α,
end
end

function LinearAlgebra.mul!(
C::StridedVecOrMat,
A::AbstractSparseMatrixCOO,
B::SparseArrays.DenseInputVecOrMat,
α::Number,
β::Number,
for T in (
AbstractVector,
AbstractMatrix,
Union{Bidiagonal, SymTridiagonal, Tridiagonal},
Diagonal,
Transpose{<:Any, <:AbstractVecOrMat},
Adjoint{<:Any, <:AbstractVecOrMat},
)
size(A, 2) == size(B, 1) || throw(DimensionMismatch())
size(A, 1) == size(C, 1) || throw(DimensionMismatch())
size(B, 2) == size(C, 2) || throw(DimensionMismatch())
if β != 1
β != 0 ? rmul!(C, β) : fill!(C, zero(eltype(C)))
@eval function LinearAlgebra.mul!(
C::StridedVecOrMat,
A::AbstractSparseMatrixCOO,
B::$T,
α::Number,
β::Number,
)
size(A, 2) == size(B, 1) || throw(DimensionMismatch())
size(A, 1) == size(C, 1) || throw(DimensionMismatch())
size(B, 2) == size(C, 2) || throw(DimensionMismatch())
if β != 1
β != 0 ? rmul!(C, β) : fill!(C, zero(eltype(C)))
end
coo_mul!(C, A.rows, A.cols, A.vals, B, α, nnz(A))
C
end
coo_mul!(C, A.rows, A.cols, A.vals, B, α, nnz(A))
C
end

function coo_adjtrans_mul!(C::AbstractVector, Arows, Acols, Avals, B::AbstractVector, α, Annz, t)
Expand All @@ -44,22 +53,31 @@ function coo_adjtrans_mul!(C::AbstractMatrix, Arows, Acols, Avals, B::AbstractMa
end

for (T, t) in ((Adjoint, adjoint), (Transpose, transpose))
@eval function LinearAlgebra.mul!(
C::StridedVecOrMat,
xA::$T{<:Any, <:AbstractSparseMatrixCOO},
B::SparseArrays.DenseInputVecOrMat,
α::Number,
β::Number,
for Tb in (
AbstractVector,
AbstractMatrix,
Union{Bidiagonal, SymTridiagonal, Tridiagonal},
Diagonal,
Transpose{<:Any, <:AbstractVecOrMat},
Adjoint{<:Any, <:AbstractVecOrMat},
)
A = xA.parent
size(A, 2) == size(C, 1) || throw(DimensionMismatch())
size(A, 1) == size(B, 1) || throw(DimensionMismatch())
size(B, 2) == size(C, 2) || throw(DimensionMismatch())
if β != 1
β != 0 ? rmul!(C, β) : fill!(C, zero(eltype(C)))
@eval function LinearAlgebra.mul!(
C::StridedVecOrMat,
xA::$T{<:Any, <:AbstractSparseMatrixCOO},
B::$Tb,
α::Number,
β::Number,
)
A = xA.parent
size(A, 2) == size(C, 1) || throw(DimensionMismatch())
size(A, 1) == size(B, 1) || throw(DimensionMismatch())
size(B, 2) == size(C, 2) || throw(DimensionMismatch())
if β != 1
β != 0 ? rmul!(C, β) : fill!(C, zero(eltype(C)))
end
coo_adjtrans_mul!(C, A.rows, A.cols, A.vals, B, α, nnz(A), $t)
C
end
coo_adjtrans_mul!(C, A.rows, A.cols, A.vals, B, α, nnz(A), $t)
C
end
end

Expand All @@ -86,22 +104,31 @@ function coo_sym_mul!(C::AbstractMatrix, Arows, Acols, Avals, B::AbstractMatrix,
end

for (T, t) in ((Hermitian, adjoint), (Symmetric, transpose))
@eval function LinearAlgebra.mul!(
C::StridedVecOrMat,
xA::$T{<:Any, <:AbstractSparseMatrixCOO},
B::SparseArrays.DenseInputVecOrMat,
α::Number,
β::Number,
for Tb in (
AbstractVector,
AbstractMatrix,
Union{Bidiagonal, SymTridiagonal, Tridiagonal},
Diagonal,
Transpose{<:Any, <:AbstractVecOrMat},
Adjoint{<:Any, <:AbstractVecOrMat},
)
A = xA.data
size(A, 2) == size(B, 1) || throw(DimensionMismatch())
size(A, 1) == size(C, 1) || throw(DimensionMismatch())
size(B, 2) == size(C, 2) || throw(DimensionMismatch())
if β != 1
β != 0 ? rmul!(C, β) : fill!(C, zero(eltype(C)))
@eval function LinearAlgebra.mul!(
C::StridedVecOrMat,
xA::$T{<:Any, <:AbstractSparseMatrixCOO},
B::$Tb,
α::Number,
β::Number,
)
A = xA.data
size(A, 2) == size(B, 1) || throw(DimensionMismatch())
size(A, 1) == size(C, 1) || throw(DimensionMismatch())
size(B, 2) == size(C, 2) || throw(DimensionMismatch())
if β != 1
β != 0 ? rmul!(C, β) : fill!(C, zero(eltype(C)))
end
coo_sym_mul!(C, A.rows, A.cols, A.vals, B, α, nnz(A), $t, xA.uplo)
C
end
coo_sym_mul!(C, A.rows, A.cols, A.vals, B, α, nnz(A), $t, xA.uplo)
C
end
end

Expand Down
Loading