|
415 | 415 | end
|
416 | 416 | end
|
417 | 417 |
|
| 418 | +@testset "broadcast! where the destination is a structured matrix" begin |
| 419 | + # Where broadcast!'s destination is a structured matrix, broadcast! should fall back |
| 420 | + # to the generic AbstractArray broadcast! code (at least for now). |
| 421 | + N, p = 5, 0.4 |
| 422 | + A = sprand(N, N, p) |
| 423 | + sA = A + transpose(A) |
| 424 | + D = Diagonal(rand(N)) |
| 425 | + B = Bidiagonal(rand(N), rand(N - 1), true) |
| 426 | + T = Tridiagonal(rand(N - 1), rand(N), rand(N - 1)) |
| 427 | + S = SymTridiagonal(rand(N), rand(N - 1)) |
| 428 | + # why some of the tests below are broken: |
| 429 | + # Diagonal setindex! allows setting off-diagonal entries to zero. Subtypes of |
| 430 | + # AbstractTriangular allow analogs. But Bidiagonal, Tridiagonal, and SymTridiagonal |
| 431 | + # do not, which seems like a bug. setindex! behavior like that for Diagonal and |
| 432 | + # subtypes of AbstractTriangular is necessary for Bidiagonal, Tridiagonal, and |
| 433 | + # SymTridiagonal to be targets of the AbstractArray broadcast! methods, hence |
| 434 | + # the test failures below. |
| 435 | + @test broadcast!(sin, copy(D), D) == Diagonal(sin.(D)) |
| 436 | + @test_broken broadcast!(sin, copy(B), B) == Bidiagonal(sin.(B), true) |
| 437 | + @test_broken broadcast!(sin, copy(T), T) == Tridiagonal(sin.(T)) |
| 438 | + @test_broken broadcast!(sin, copy(S), S) == SymTridiagonal(sin.(S)) |
| 439 | + @test broadcast!(*, copy(D), D, A) == Diagonal(broadcast(*, D, A)) |
| 440 | + @test_broken broadcast!(*, copy(B), B, A) == Bidiagonal(broadcast(*, B, A), true) |
| 441 | + @test_broken broadcast!(*, copy(T), T, A) == Tridiagonal(broadcast(*, T, A)) |
| 442 | + @test_broken broadcast!(*, copy(S), T, sA) == SymTridiagonal(broadcast(*, T, sA)) |
| 443 | +end |
| 444 | + |
418 | 445 | @testset "map[!] over combinations of sparse and structured matrices" begin
|
419 | 446 | N, p = 10, 0.4
|
420 | 447 | A = sprand(N, N, p)
|
|
0 commit comments