@@ -697,6 +697,42 @@ function LinearAlgebra.fillstored!(a::AbstractSplitMatrix,v)
697697 a
698698end
699699
700+ function Base.:* (a:: Number ,b:: AbstractSplitMatrix )
701+ own_own = a* b. blocks. own_own
702+ own_ghost = a* b. blocks. own_ghost
703+ ghost_own = a* b. blocks. ghost_own
704+ ghost_ghost = a* b. blocks. ghost_ghost
705+ blocks = split_matrix_blocks (own_own,own_ghost,ghost_own,ghost_ghost)
706+ split_matrix (blocks,b. row_permutation,b. col_permutation)
707+ end
708+
709+ function Base.:* (b:: AbstractSplitMatrix ,a:: Number )
710+ a* b
711+ end
712+
713+ for op in (:+ ,:- )
714+ @eval begin
715+ function Base. $op (a:: AbstractSplitMatrix )
716+ own_own = $ op (a. blocks. own_own)
717+ own_ghost = $ op (a. blocks. own_ghost)
718+ ghost_own = $ op (a. blocks. ghost_own)
719+ ghost_ghost = $ op (a. blocks. ghost_ghost)
720+ blocks = split_matrix_blocks (own_own,own_ghost,ghost_own,ghost_ghost)
721+ split_matrix (blocks,a. row_permutation,a. col_permutation)
722+ end
723+ function Base. $op (a:: AbstractSplitMatrix ,b:: AbstractSplitMatrix )
724+ @boundscheck @assert a. row_permutation == b. row_permutation
725+ @boundscheck @assert a. col_permutation == b. col_permutation
726+ own_own = $ op (a. blocks. own_own,b. blocks. own_own)
727+ own_ghost = $ op (a. blocks. own_ghost,b. blocks. own_ghost)
728+ ghost_own = $ op (a. blocks. ghost_own,b. blocks. ghost_own)
729+ ghost_ghost = $ op (a. blocks. ghost_ghost,b. blocks. ghost_ghost)
730+ blocks = split_matrix_blocks (own_own,own_ghost,ghost_own,ghost_ghost)
731+ split_matrix (blocks,b. row_permutation,b. col_permutation)
732+ end
733+ end
734+ end
735+
700736function split_format_locally (A,rows,cols)
701737 n_own_rows = own_length (rows)
702738 n_own_cols = own_length (cols)
@@ -1582,6 +1618,52 @@ function psparse_consitent_impl!(B,A,::Type{<:AbstractSplitMatrix},cache)
15821618 end
15831619end
15841620
1621+ function Base.:* (a:: PSparseMatrix ,b:: PVector )
1622+ Ta = eltype (a)
1623+ Tb = eltype (b)
1624+ T = typeof (zero (Ta)* zero (Tb)+ zero (Ta)* zero (Tb))
1625+ c = PVector {Vector{T}} (undef,partition (axes (a,1 )))
1626+ mul! (c,a,b)
1627+ c
1628+ end
1629+
1630+ function Base.:* (a:: Number ,b:: PSparseMatrix )
1631+ matrix_partition = map (partition (b)) do values
1632+ a* values
1633+ end
1634+ rows = partition (axes (b,1 ))
1635+ cols = partition (axes (b,2 ))
1636+ PSparseMatrix (matrix_partition,rows,cols,b. assembled)
1637+ end
1638+
1639+ function Base.:* (b:: PSparseMatrix ,a:: Number )
1640+ a* b
1641+ end
1642+
1643+ for op in (:+ ,:- )
1644+ @eval begin
1645+ function Base. $op (a:: PSparseMatrix )
1646+ matrix_partition = map (partition (a)) do a
1647+ $ op (a)
1648+ end
1649+ rows = partition (axes (a,1 ))
1650+ cols = partition (axes (a,2 ))
1651+ PSparseMatrix (matrix_partition,rows,cols,a. assembled)
1652+ end
1653+ function Base. $op (a:: PSparseMatrix ,b:: PSparseMatrix )
1654+ @boundscheck @assert matching_local_indices (axes (a,1 ),axes (b,1 ))
1655+ @boundscheck @assert matching_local_indices (axes (a,2 ),axes (b,2 ))
1656+ matrix_partition = map (partition (a),partition (b)) do a,b
1657+ $ op (a,b)
1658+ end
1659+ rows = partition (axes (b,1 ))
1660+ cols = partition (axes (b,2 ))
1661+ assembled = a. assembled && b. assembled
1662+ PSparseMatrix (matrix_partition,rows,cols,assembled)
1663+ end
1664+ end
1665+ end
1666+
15851667function LinearAlgebra. mul! (c:: PVector ,a:: PSparseMatrix ,b:: PVector ,α:: Number ,β:: Number )
15861668 @boundscheck @assert matching_own_indices (axes (c,1 ),axes (a,1 ))
15871669 @boundscheck @assert matching_own_indices (axes (a,2 ),axes (b,1 ))
0 commit comments