@@ -597,3 +597,86 @@ function csrr_to_csc_step_2(
597
597
nothing
598
598
end
599
599
600
+ @inline function spmv! (b,A,x)
601
+ mul! (b,A,x)
602
+ end
603
+
604
+ @inline function spmtv! (b,A,x)
605
+ mul! (b,transpose (A),x)
606
+ end
607
+
608
+ function spmv! (b,A:: SparseMatrixCSR{1} ,x)
609
+ @boundscheck begin
610
+ @assert length (b) == size (A,1 )
611
+ @assert length (x) == size (A,2 )
612
+ end
613
+ spmv_csr! (b,x,A. rowptr,A. colval,A. nzval)
614
+ end
615
+
616
+ function spmtv! (b,A:: SparseMatrixCSR{1} ,x)
617
+ @boundscheck begin
618
+ @assert length (b) == size (A,2 )
619
+ @assert length (x) == size (A,1 )
620
+ end
621
+ spmv_csc! (b,x,A. rowptr,A. colval,A. nzval)
622
+ end
623
+
624
+ function spmv! (b,A:: SparseMatrixCSC ,x)
625
+ @boundscheck begin
626
+ @assert length (b) == size (A,1 )
627
+ @assert length (x) == size (A,2 )
628
+ end
629
+ spmv_csc! (b,x,A. colptr,A. rowval,A. nzval)
630
+ end
631
+
632
+ function spmtv! (b,A:: SparseMatrixCSC ,x)
633
+ @boundscheck begin
634
+ @assert length (b) == size (A,2 )
635
+ @assert length (x) == size (A,1 )
636
+ end
637
+ spmv_csr! (b,x,A. colptr,A. rowval,A. nzval)
638
+ end
639
+
640
+ function spmv_csr! (b,x,rowptr_A,colval_A,nzval_A)
641
+ ncols = length (x)
642
+ nrows = length (b)
643
+ u = one (eltype (rowptr_A))
644
+ z = zero (eltype (b))
645
+ @inbounds for row in 1 : nrows
646
+ pini = rowptr_A[row]
647
+ pend = rowptr_A[row+ 1 ]
648
+ bi = z
649
+ p = pini
650
+ while p < pend
651
+ aij = nzval_A[p]
652
+ col = colval_A[p]
653
+ xj = x[col]
654
+ bi += aij* xj
655
+ p += u
656
+ end
657
+ b[row] = bi
658
+ end
659
+ b
660
+ end
661
+
662
+ function spmv_csc! (b,x,colptr_A,rowval_A,nzval_A)
663
+ ncols = length (x)
664
+ nrows = length (b)
665
+ u = one (eltype (colptr_A))
666
+ z = zero (eltype (b))
667
+ fill! (b,z)
668
+ @inbounds for col in 1 : ncols
669
+ pini = colptr_A[col]
670
+ pend = colptr_A[col+ 1 ]
671
+ p = pini
672
+ xj = x[col]
673
+ while p < pend
674
+ aij = nzval_A[p]
675
+ row = rowval_A[p]
676
+ b[row] += aij* xj
677
+ p += u
678
+ end
679
+ end
680
+ b
681
+ end
682
+
0 commit comments