-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Compact printing for Adjoint
vectors, and Diagonal
#40722
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
Changes from all commits
3ed6764
1b512a9
5119028
373bd8e
1a3cff0
34376b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,6 +213,11 @@ end | |
function Base.replace_in_print_matrix(A::Diagonal,i::Integer,j::Integer,s::AbstractString) | ||
i==j ? s : Base.replace_with_centered_mark(s) | ||
end | ||
function Base.show(io::IO, A::Diagonal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add similar methods to the other banded matrix types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do, but maybe not this PR? For the more complicated ones, there are choices like whether to print In this PR, only Note also that not all Adjoint or Transpose objects are affected, only the simplest ones. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Xref #55347 for Bidiagonal. |
||
print(io, "Diagonal(") | ||
show(io, A.diag) | ||
print(io, ")") | ||
end | ||
|
||
parent(D::Diagonal) = D.diag | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this omits vectors of complex numbers... because I thought that printing
0 + 3im
when the element is in fact0 - 3im
here is worse than failing to note the container type:It also doesn't change how e.g. an array of matrices is printed, for the same reason -- printing
[1 2; 3 4]
which isn't==
the element seems confusing:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the choices here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add tests for the complex case, making it explicit that this was a design choice and not an oversight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the restrictions to
v::Adjoint{<:Real, <:AbstractVector}
andv::Transpose{<:Number, <:AbstractVector}
are fairly obviously deliberate.For the complex case, it would not be crazy to print
adjoint(conj([1 + 0im, 2 + 0im, 0 - 3im]))
as this also resolves to the right object (sinceconj
is eager). Maybe I'd rather not have explicit tests blocking that.