Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented Jan 28, 2023

Since

julia> Complex(false,false) === false*im
true

we may use the latter form, which is more concise. This makes the display of structured matrices easier to read.
On master:

julia> Diagonal(fill(im, 2))
2×2 Diagonal{Complex{Bool}, Vector{Complex{Bool}}}:
                   im                     
                                        im

This PR

julia> Diagonal(fill(im, 2))
2×2 Diagonal{Complex{Bool}, Vector{Complex{Bool}}}:
       im         
                im

@jishnub jishnub added display and printing Aesthetics and correctness of printed representations of objects. complex Complex numbers labels Jan 28, 2023
@KristofferC
Copy link
Member

2×2 Matrix{Complex{Bool}}:
                   im  Complex(false,false)
 Complex(false,false)                    im

looks kind of strange to me I must say

@simeonschaub
Copy link
Member

In case the eltype is concrete, we could just print this as 0

@StefanKarpinski
Copy link
Member

Agree, if the eltype is concrete as in these examples, print Complex(1, 0) as 1 + 0im, Complex(0, 0) as 0 + 0im, Complex(0, 1) as 0 + 1im and so on. If we don't have precise type information then we're in "scalar context" and I think printing as Complex{Bool}(0, 0) and so on might be clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complex Complex numbers display and printing Aesthetics and correctness of printed representations of objects.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants