We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e42270 commit dfe4fd8Copy full SHA for dfe4fd8
Project.toml
@@ -1,7 +1,7 @@
1
name = "SparseArraysBase"
2
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
3
authors = ["ITensor developers <[email protected]> and contributors"]
4
-version = "0.5.8"
+version = "0.5.9"
5
6
[deps]
7
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
src/abstractsparsearray.jl
@@ -152,3 +152,43 @@ function sparserand!(
152
A[I] = v
153
end
154
155
+
156
+# Catch some cases that aren't getting caught by the current
157
+# DerivableInterfaces.jl logic.
158
+# TODO: Make this more systematic once DerivableInterfaces.jl
159
+# is rewritten.
160
+using ArrayLayouts: ArrayLayouts, MemoryLayout
161
+using LinearAlgebra: LinearAlgebra, Adjoint
162
+function ArrayLayouts.MemoryLayout(::Type{Transpose{T,P}}) where {T,P<:AbstractSparseMatrix}
163
+ return MemoryLayout(P)
164
+end
165
+function ArrayLayouts.MemoryLayout(::Type{Adjoint{T,P}}) where {T,P<:AbstractSparseMatrix}
166
167
168
+function LinearAlgebra.mul!(
169
+ dest::AbstractMatrix,
170
+ A::Adjoint{<:Any,<:AbstractSparseMatrix},
171
+ B::AbstractSparseMatrix,
172
+ α::Number,
173
+ β::Number,
174
+)
175
+ return ArrayLayouts.mul!(dest, A, B, α, β)
176
177
178
179
+ A::AbstractSparseMatrix,
180
+ B::Adjoint{<:Any,<:AbstractSparseMatrix},
181
182
183
184
185
186
187
188
189
190
191
192
193
194
test/test_linalg.jl
@@ -16,13 +16,22 @@ const rng = StableRNG(123)
16
A = sparserand(rng, T, szA; density)
17
B = sparserand(rng, T, szB; density)
18
19
- check1 = mul!(Array(C), Array(A), Array(B))
20
- @test mul!(copy(C), A, B) ≈ check1
+ check = mul!(Array(C), Array(A), Array(B))
+ @test mul!(copy(C), A, B) ≈ check
21
22
+ check = mul!(Array(C), Array(A)', Array(B))
23
+ @test mul!(copy(C), A', B) ≈ check
24
25
+ check = mul!(Array(C), Array(A), Array(B)')
26
+ @test mul!(copy(C), A, B') ≈ check
27
28
+ check = mul!(Array(C), Array(A)', Array(B)')
29
+ @test mul!(copy(C), A', B') ≈ check
30
31
α = rand(rng, T)
32
β = rand(rng, T)
- check2 = mul!(Array(C), Array(A), Array(B), α, β)
- @test mul!(copy(C), A, B, α, β) ≈ check2
33
+ check = mul!(Array(C), Array(A), Array(B), α, β)
34
+ @test mul!(copy(C), A, B, α, β) ≈ check
35
36
37
# test empty matrix
0 commit comments