Skip to content

Commit

Permalink
Format .jl files (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] authored Sep 24, 2020
1 parent 7bb6b86 commit 494c188
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ function inv(M::PermMatrix)
end

####### multiply ###########
*(A::IMatrix{N}, B::AbstractVector) where {N} = size(A, 2) == size(B, 1) ? B :
*(A::IMatrix{N}, B::AbstractVector) where {N} =
size(A, 2) == size(B, 1) ? B :
throw(DimensionMismatch("matrix A has dimensions $(size(A)), matrix B has dimensions $((size(B, 1), 1))"))

for MATTYPE in
[:AbstractMatrix, :StridedMatrix, :Diagonal, :SparseMatrixCSC, :Matrix, :PermMatrix]
@eval *(A::IMatrix{N}, B::$MATTYPE) where {N} = N == size(B, 1) ? B :
@eval *(A::IMatrix{N}, B::$MATTYPE) where {N} =
N == size(B, 1) ? B :
throw(DimensionMismatch("matrix A has dimensions $(size(A)), matrix B has dimensions $(size(B))"))

@eval *(A::$MATTYPE, B::IMatrix{N}) where {N} = size(A, 2) == N ? A :
@eval *(A::$MATTYPE, B::IMatrix{N}) where {N} =
size(A, 2) == N ? A :
throw(DimensionMismatch("matrix A has dimensions $(size(A)), matrix B has dimensions $(size(B))"))
end

*(A::Adjoint{T,<:AbstractVector{T}}, B::IMatrix) where {T} = size(A, 2) == size(B, 1) ? A :
*(A::Adjoint{T,<:AbstractVector{T}}, B::IMatrix) where {T} =
size(A, 2) == size(B, 1) ? A :
throw(DimensionMismatch("matrix A has dimensions $(size(A)), matrix B has dimensions $(size(B))"))

*(A::IMatrix, B::IMatrix) = size(A, 2) == size(B, 1) ? A :
*(A::IMatrix, B::IMatrix) =
size(A, 2) == size(B, 1) ? A :
throw(DimensionMismatch("matrix A has dimensions $(size(A)), matrix B has dimensions $(size(B))"))


Expand Down
4 changes: 2 additions & 2 deletions test/SparseMatrixCOO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ coo1 = SparseMatrixCOO(
@test coo1 == copy(coo1)
@test coo1 == copyto!(coo2, coo1)

@test Matrix(coo1) == [0.1 0 0 0; 0 0.4im 0 0; 0 0 0.3 0.5 + 0.5im; 0.2 0 0 0]
@test Matrix(coo1) == [0.1 0 0 0; 0 0.4im 0 0; 0 0 0.3 0.5+0.5im; 0.2 0 0 0]
@test sparse(coo1) == sparse(findnz(coo1)...)
@test isdense(coo1) == false

Expand All @@ -35,7 +35,7 @@ end
@test LuxurySparse.nonzeros(p1) == p1.vs
p1.vs[2] = 0
@test LuxurySparse.dropzeros!(p1) ==
[0.1 0 0 0; 0 0.4im 0 0; 0 0 0.3 0.5 + 0.5im; 0 0 0 0]
[0.1 0 0 0; 0 0.4im 0 0; 0 0 0.3 0.5+0.5im; 0 0 0 0]
end

@testset "basicmath" begin
Expand Down

0 comments on commit 494c188

Please sign in to comment.