Skip to content

Commit 1cfa0c8

Browse files
authored
Merge pull request #17 from gridap/rmul
Added rmul! and fixed return value of fillstored!
2 parents 1a6a1d6 + 0080a7c commit 1cfa0c8

6 files changed

+34
-4
lines changed

NEWS.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.6.5] - 2021.10.20
8+
9+
### Fixed
10+
- Return value of `LinearAlbegra.fillstored!`.
11+
12+
### Added
13+
- Implemented `LinearAlbegra.rmul!`.
714

815
## [0.6.4] - 2021.10.20
916

1017
### Added
1118
- Implemented `LinearAlbegra.fillstored!`.
1219

13-
1420
*Previous releases are not included in this Changelog*

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseMatricesCSR"
22
uuid = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
33
authors = ["Víctor Sande <vsande@cimne.upc.edu>", "Francesc Verdugo <fverdugo@cimne.upc.edu>"]
4-
version = "0.6.4"
4+
version = "0.6.5"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/SparseMatrixCSR.jl

+6
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ _copy_and_increment(x) = copy(x) .+ 1
122122

123123
function LinearAlgebra.fillstored!(a::SparseMatrixCSR,v)
124124
fill!(a.nzval,v)
125+
a
126+
end
127+
128+
function LinearAlgebra.rmul!(a::SparseMatrixCSR,v::Number)
129+
rmul!(a.nzval,v)
130+
a
125131
end
126132

127133
function LinearAlgebra.lu(a::SparseMatrixCSR{0})

src/SymSparseMatrixCSR.jl

+6
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ count(S::SymSparseMatrixCSR) = count(i->true, S)
142142

143143
function LinearAlgebra.fillstored!(a::SymSparseMatrixCSR,v)
144144
LinearAlgebra.fillstored!(a.uppertrian,v)
145+
a
146+
end
147+
148+
function LinearAlgebra.rmul!(a::SymSparseMatrixCSR,v::Number)
149+
LinearAlgebra.rmul!(a.uppertrian,v)
150+
a
145151
end
146152

147153
function mul!(y::AbstractVector,A::SymSparseMatrixCSR,v::AbstractVector, α::Number, β::Number)

test/SparseMatrixCSR.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,18 @@ function test_csr(Bi,Tv,Ti)
8282
mul!(z,CSC,x,1,2)
8383
@test y z
8484

85-
LinearAlgebra.fillstored!(CSR,3.33)
85+
out = LinearAlgebra.fillstored!(CSR,3.33)
86+
@test out === CSR
8687
LinearAlgebra.fillstored!(CSC,3.33)
8788
mul!(y,CSR,x)
8889
mul!(z,CSC,x)
8990
@test y z
9091

92+
_CSR = copy(CSR)
93+
out = LinearAlgebra.rmul!(CSR,-1)
94+
@test out === CSR
95+
@test _CSR -1*CSR
96+
9197
end
9298

9399
function test_lu(Bi,I,J,V)

test/SymSparseMatrixCSR.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,18 @@ function test_csr(Bi,Tv,Ti)
7878

7979
@test CSR*x CSC*x
8080

81-
LinearAlgebra.fillstored!(CSR,3.33)
81+
out = LinearAlgebra.fillstored!(CSR,3.33)
82+
@test out === CSR
8283
LinearAlgebra.fillstored!(CSC,3.33)
8384
mul!(y,CSR,x)
8485
mul!(z,CSC,x)
8586
@test y z
8687

88+
_CSR = copy(CSR)
89+
out = LinearAlgebra.rmul!(CSR,-1)
90+
@test out === CSR
91+
@test _CSR -1*CSR
92+
8793
end
8894

8995
for Bi in (0,1)

0 commit comments

Comments
 (0)