-
-
Notifications
You must be signed in to change notification settings - Fork 34
un-revert "Simplify some views of Adjoint matrices" #1122
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
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 |
---|---|---|
|
@@ -382,6 +382,20 @@ parent(A::AdjOrTrans) = A.parent | |
vec(v::TransposeAbsVec{<:Number}) = parent(v) | ||
vec(v::AdjointAbsVec{<:Real}) = parent(v) | ||
|
||
Base.reshape(v::TransposeAbsVec{<:Number}, ::Val{1}) = parent(v) | ||
Base.reshape(v::AdjointAbsVec{<:Real}, ::Val{1}) = parent(v) | ||
|
||
# these make eachrow(A') produce simpler views | ||
@inline Base.unsafe_view(A::Transpose{<:Number, <:AbstractMatrix}, i::Integer, j::AbstractArray) = | ||
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. Perhaps use the alias 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. IDK why it's written this way, it's possible I followed nearby code which writes e.g. |
||
Base.unsafe_view(parent(A), j, i) | ||
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. These should probably call 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. Can't we also do something similar for transposes of 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. I initially said the wrong thing, because I've forgotten how this all works, but in fact that case is already handled (and tested). It's why the I'm hesitant to start editing as I do not have the details fresh in my head, and do not wish to introduce fresh mistakes. The pervious PR reverted mine with no changes, this PR un-does the reversion. |
||
@inline Base.unsafe_view(A::Transpose{<:Number, <:AbstractMatrix}, i::AbstractArray, j::Integer) = | ||
Base.unsafe_view(parent(A), j, i) | ||
|
||
@inline Base.unsafe_view(A::Adjoint{<:Real, <:AbstractMatrix}, i::Integer, j::AbstractArray) = | ||
Base.unsafe_view(parent(A), j, i) | ||
@inline Base.unsafe_view(A::Adjoint{<:Real, <:AbstractMatrix}, i::AbstractArray, j::Integer) = | ||
Base.unsafe_view(parent(A), j, i) | ||
|
||
### concatenation | ||
# preserve Adjoint/Transpose wrapper around vectors | ||
# to retain the associated semantics post-concatenation | ||
|
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
reshape(v, ::Colon)
and such behave identically? Or is theVal(1)
reshaping used in the view below? E.g.:It might be a good idea to have these all return a range, but that may be a separate PR.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yea this PR is only about
view
. And some views call this (internal?) method withVal
.The "supported" way to do that reshape is:
The default definition is
vec(a::AbstractArray) = reshape(a,length(a))
, and at presentreshape(v', 4)
also has no shortcut.