|
256 | 256 | B = Diagonal(b) |
257 | 257 | A = Diagonal(a) |
258 | 258 | mul!(C, A, B) |
259 | | - @test collect(C.diag) ≈ collect(A.diag) .* collect(B.diag) |
| 259 | + @test collect(C.diag) ≈ collect(A.diag) .* collect(B.diag) |
260 | 260 | a = AT(diagm(rand(elty, n))) |
261 | 261 | b = AT(diagm(rand(elty, n))) |
262 | 262 | C = Diagonal(d) |
263 | 263 | mul!(C, a, b) |
264 | | - @test collect(C) ≈ Diagonal(collect(a) * collect(b)) |
| 264 | + @test collect(C) ≈ Diagonal(collect(a) * collect(b)) |
265 | 265 | a = transpose(AT(diagm(rand(elty, n)))) |
266 | 266 | b = adjoint(AT(diagm(rand(elty, n)))) |
267 | 267 | C = Diagonal(d) |
268 | 268 | mul!(C, a, b) |
269 | | - @test collect(C) ≈ Diagonal(collect(a) * collect(b)) |
| 269 | + @test collect(C) ≈ Diagonal(collect(a) * collect(b)) |
270 | 270 | end |
271 | 271 | end |
272 | 272 |
|
|
303 | 303 | end |
304 | 304 | end |
305 | 305 |
|
| 306 | + @testset "mul! + UniformScaling" begin |
| 307 | + for elty in (Float32, ComplexF32) |
| 308 | + n = 128 |
| 309 | + s = rand(elty) |
| 310 | + I_s = UniformScaling(s) |
| 311 | + |
| 312 | + # Test vector operations |
| 313 | + a = AT(rand(elty, n)) |
| 314 | + b = AT(rand(elty, n)) |
| 315 | + b_copy = copy(b) |
| 316 | + |
| 317 | + # Test mul!(a, I*s, b) - should compute a = s * b |
| 318 | + mul!(a, I_s, b) |
| 319 | + @test collect(a) ≈ s .* collect(b_copy) |
| 320 | + |
| 321 | + # Test mul!(a, b, s) - should compute a = b * s |
| 322 | + a = AT(rand(elty, n)) |
| 323 | + mul!(a, b, s) |
| 324 | + @test collect(a) ≈ collect(b_copy) .* s |
| 325 | + |
| 326 | + # Test matrix operations |
| 327 | + A = AT(rand(elty, n, n)) |
| 328 | + B = AT(rand(elty, n, n)) |
| 329 | + B_copy = copy(B) |
| 330 | + |
| 331 | + # Test mul!(A, I*s, B) |
| 332 | + mul!(A, I_s, B) |
| 333 | + @test collect(A) ≈ s .* collect(B_copy) |
| 334 | + |
| 335 | + # Test mul!(A, B, s) |
| 336 | + A = AT(rand(elty, n, n)) |
| 337 | + mul!(A, B, s) |
| 338 | + @test collect(A) ≈ collect(B_copy) .* s |
| 339 | + end |
| 340 | + end |
| 341 | + |
306 | 342 | @testset "lmul! and rmul!" for (a,b) in [((3,4),(4,3)), ((3,), (1,3)), ((1,3), (3))], T in eltypes |
307 | 343 | @test compare(rmul!, AT, rand(T, a), Ref(rand(T))) |
308 | 344 | @test compare(lmul!, AT, Ref(rand(T)), rand(T, b)) |
|
0 commit comments