Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports for Julia 1.5-RC1 (or beta2) #36098

Merged
merged 29 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a7c4fd3
fix #36031: Printf bug for BigInt (#36033)
simeonschaub May 28, 2020
91216bf
Update armv7l `-d16` -> `+d32` feature change for LLVM 9+
staticfloat May 28, 2020
53f0393
LibGit2: add resolve_url to RemoteCallbacksStruct for LibGit2 0.99.0 …
diabonas May 29, 2020
5e85387
update NEWS entry for popat!
rfourquet Jun 4, 2020
d01886d
Fix a bug with break/continue/return in at-testset begin end (#36046)
tkf Jun 1, 2020
c7476af
clarify `show` doc strings (#36076)
JeffBezanson Jun 1, 2020
99adb51
Revert "Use norm instead of abs in generic lu factorization (#34575)"…
andreasnoack Jun 2, 2020
3ccc916
rename pop!(vector, idx, [default]) to popat! (#36070)
rfourquet Jun 2, 2020
88b689b
fix #36116, diff(::AbstractRange) returns an Array (#36117)
mbauman Jun 3, 2020
539eab5
fix #36108, printing invalid numeric juxtapositions (#36122)
JeffBezanson Jun 3, 2020
633046e
Fix mkpath error handling (#36126)
simonbyrne Jun 3, 2020
360f5cc
fix #36104, assign global name during type definitions (#36121)
JeffBezanson Jun 4, 2020
fdd4547
Fix zero(::Type{<:TwicePrecision}) for dimensionful quantities (#36113)
sostock Jun 4, 2020
5c236b4
Fix equality for one-element ranges
sostock May 29, 2020
60bab00
fix ImmutableDict(pairs...) constructor (#36143)
rfourquet Jun 4, 2020
2f8eb20
inference: ignore badly behaving generated functions (#36115)
vtjnash Jun 3, 2020
62ea26d
Error when compiling invalid AddrSpacePtrs.
maleadt May 28, 2020
cf26388
Rename AddrSpacePtr to LLVMPtr.
maleadt May 28, 2020
bf34e0a
Mark Tuples with Bottom among their parameters as cacheable (#36152)
martinholters Jun 4, 2020
e4b83af
bump Pkg version
KristofferC Jun 5, 2020
3854131
bump Statistics version
KristofferC Jun 5, 2020
ea15599
Allow non-Function callables to be used in count(f, itr) (#36187)
tkf Jun 8, 2020
6c65ec8
fix #36272: Error with optional argument in anonymous function define…
simeonschaub Jun 15, 2020
8dec8f1
Fix Broadcasting of Bidiagonal (#35281)
ssikdar1 Jun 8, 2020
ee41310
Promote on Rational binary operations (#36279)
Liozou Jun 16, 2020
1cf4720
Remove `init` from `count!` docstring (#36305)
tkf Jun 16, 2020
e2cfc6f
deleteat! : check bounds for the first passed index (#36231)
rfourquet Jun 16, 2020
d3bc87f
Switch `httpbin` tests over to JuliaLang-hosted `httpbin` mock server…
staticfloat Jun 18, 2020
3e5174f
more precise inference of `splatnew` (#35976)
JeffBezanson May 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Broadcasting of Bidiagonal (#35281)
(cherry picked from commit 0e062e9)
  • Loading branch information
ssikdar1 authored and KristofferC committed Jun 16, 2020
commit 8dec8f10bd76518ae0bdc84eded25ce76139221e
20 changes: 14 additions & 6 deletions stdlib/LinearAlgebra/src/structuredbroadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@ structured_broadcast_alloc(bc, ::Type{<:Diagonal}, ::Type{ElType}, n) where {ElT
# Bidiagonal is tricky as we need to know if it's upper or lower. The promotion
# system will return Tridiagonal when there's more than one Bidiagonal, but when
# there's only one, we need to make figure out upper or lower
find_bidiagonal() = throw(ArgumentError("could not find Bidiagonal within broadcast expression"))
find_bidiagonal(a::Bidiagonal, rest...) = a
find_bidiagonal(bc::Broadcast.Broadcasted, rest...) = find_bidiagonal(find_bidiagonal(bc.args...), rest...)
find_bidiagonal(x, rest...) = find_bidiagonal(rest...)
merge_uplos(::Nothing, ::Nothing) = nothing
merge_uplos(a, ::Nothing) = a
merge_uplos(::Nothing, b) = b
merge_uplos(a, b) = a == b ? a : 'T'

find_uplo(a::Bidiagonal) = a.uplo
find_uplo(a) = nothing
find_uplo(bc::Broadcasted) = mapreduce(find_uplo, merge_uplos, bc.args, init=nothing)

function structured_broadcast_alloc(bc, ::Type{<:Bidiagonal}, ::Type{ElType}, n) where {ElType}
ex = find_bidiagonal(bc)
return Bidiagonal(Array{ElType}(undef, n),Array{ElType}(undef, n-1), ex.uplo)
uplo = find_uplo(bc)
if uplo == 'T'
return Tridiagonal(Array{ElType}(undef, n-1), Array{ElType}(undef, n), Array{ElType}(undef, n-1))
end
return Bidiagonal(Array{ElType}(undef, n),Array{ElType}(undef, n-1), uplo)
end
structured_broadcast_alloc(bc, ::Type{<:SymTridiagonal}, ::Type{ElType}, n) where {ElType} =
SymTridiagonal(Array{ElType}(undef, n),Array{ElType}(undef, n-1))
Expand Down
45 changes: 45 additions & 0 deletions stdlib/LinearAlgebra/test/structuredbroadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,49 @@ end
@test L .+ UnitL .+ UnitU .+ U .+ D == L + UnitL + UnitU + U + D
@test L .+ U .+ D .+ D .+ D .+ D == L + U + D + D + D + D
end
@testset "Broadcast Returned Types" begin
# Issue 35245
N = 3
dV = rand(N)
evu = rand(N-1)
evl = rand(N-1)

Bu = Bidiagonal(dV, evu, :U)
Bl = Bidiagonal(dV, evl, :L)
T = Tridiagonal(evl, dV * 2, evu)

@test typeof(Bu .+ Bl) <: Tridiagonal
@test typeof(Bl .+ Bu) <: Tridiagonal
@test typeof(Bu .+ Bu) <: Bidiagonal
@test typeof(Bl .+ Bl) <: Bidiagonal
@test Bu .+ Bl == T
@test Bl .+ Bu == T
@test Bu .+ Bu == Bidiagonal(dV * 2, evu * 2, :U)
@test Bl .+ Bl == Bidiagonal(dV * 2, evl * 2, :L)


@test typeof(Bu .* Bl) <: Tridiagonal
@test typeof(Bl .* Bu) <: Tridiagonal
@test typeof(Bu .* Bu) <: Bidiagonal
@test typeof(Bl .* Bl) <: Bidiagonal

@test Bu .* Bl == Tridiagonal(zeros(N-1), dV .* dV, zeros(N-1))
@test Bl .* Bu == Tridiagonal(zeros(N-1), dV .* dV, zeros(N-1))
@test Bu .* Bu == Bidiagonal(dV .* dV, evu .* evu, :U)
@test Bl .* Bl == Bidiagonal(dV .* dV, evl .* evl, :L)

Bu2 = Bu .* 2
@test typeof(Bu2) <: Bidiagonal && Bu2.uplo == 'U'
Bu2 = 2 .* Bu
@test typeof(Bu2) <: Bidiagonal && Bu2.uplo == 'U'
Bl2 = Bl .* 2
@test typeof(Bl2) <: Bidiagonal && Bl2.uplo == 'L'
Bu2 = 2 .* Bl
@test typeof(Bl2) <: Bidiagonal && Bl2.uplo == 'L'

# Example of Nested Brodacasts
tmp = (1 .* 2) .* (Bidiagonal(1:3, 1:2, 'U') .* (3 .* 4)) .* (5 .* Bidiagonal(1:3, 1:2, 'L'))
@test typeof(tmp) <: Tridiagonal

end
end