-
Notifications
You must be signed in to change notification settings - Fork 41
WIP: review before version 3 #119
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 1 commit
2c58a40
b9036aa
04b923d
59312cd
e7bb9f5
b1208fb
f000f83
ba51f26
7d3300b
122baed
cb63bbc
025cd53
94bab04
10b2531
85e350e
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 |
---|---|---|
|
@@ -17,20 +17,26 @@ function FunctionMap{T}(f::F1, fc::F2, M::Int, N::Int; | |
end | ||
|
||
# additional constructors | ||
FunctionMap{T}(f, M::Int; kwargs...) where {T} = FunctionMap{T}(f, nothing, M, M; kwargs...) | ||
FunctionMap{T}(f, M::Int, N::Int; kwargs...) where {T} = FunctionMap{T}(f, nothing, M, N; kwargs...) | ||
FunctionMap{T}(f, fc, M::Int; kwargs...) where {T} = FunctionMap{T}(f, fc, M, M; kwargs...) | ||
FunctionMap{T}(f, M::Int; kwargs...) where {T} = | ||
FunctionMap{T}(f, nothing, M, M; kwargs...) | ||
FunctionMap{T}(f, M::Int, N::Int; kwargs...) where {T} = | ||
FunctionMap{T}(f, nothing, M, N; kwargs...) | ||
FunctionMap{T}(f, fc, M::Int; kwargs...) where {T} = | ||
FunctionMap{T}(f, fc, M, M; kwargs...) | ||
|
||
# properties | ||
Base.size(A::FunctionMap) = (A.M, A.N) | ||
Base.parent(A::FunctionMap) = (A.f, A.fc) | ||
Base.parent(A::FunctionMap) = (A.f, A.fc) # is this meanigful/useful? | ||
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. IIRC the reason for 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 any parent-like method would be most useful if it returned all the arguments needed to recreate the object. at a minimum that would include size too. maybe a named tuple would be more useful too. 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. From Base:
So I see this making sense for 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 think we use 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. Another decision to be made: what shall we do with |
||
LinearAlgebra.issymmetric(A::FunctionMap) = A._issymmetric | ||
LinearAlgebra.ishermitian(A::FunctionMap) = A._ishermitian | ||
LinearAlgebra.isposdef(A::FunctionMap) = A._isposdef | ||
ismutating(A::FunctionMap) = A._ismutating | ||
_ismutating(f) = first(methods(f)).nargs == 3 | ||
|
||
# multiplication with vector | ||
const TransposeFunctionMap = TransposeMap{<:Any, <:FunctionMap} | ||
const AdjointFunctionMap = AdjointMap{<:Any, <:FunctionMap} | ||
|
||
function Base.:(*)(A::FunctionMap, x::AbstractVector) | ||
length(x) == A.N || throw(DimensionMismatch()) | ||
if ismutating(A) | ||
|
@@ -41,7 +47,7 @@ function Base.:(*)(A::FunctionMap, x::AbstractVector) | |
end | ||
return y | ||
end | ||
function Base.:(*)(A::AdjointMap{<:Any,<:FunctionMap}, x::AbstractVector) | ||
function Base.:(*)(A::AdjointFunctionMap, x::AbstractVector) | ||
Afun = A.lmap | ||
ishermitian(Afun) && return Afun*x | ||
length(x) == size(A, 2) || throw(DimensionMismatch()) | ||
|
@@ -67,7 +73,7 @@ function Base.:(*)(A::AdjointMap{<:Any,<:FunctionMap}, x::AbstractVector) | |
error("adjoint not implemented for $(A.lmap)") | ||
end | ||
end | ||
function Base.:(*)(A::TransposeMap{<:Any,<:FunctionMap}, x::AbstractVector) | ||
function Base.:(*)(A::TransposeFunctionMap, x::AbstractVector) | ||
Afun = A.lmap | ||
(issymmetric(Afun) || (isreal(A) && ishermitian(Afun))) && return Afun*x | ||
length(x) == size(A, 2) || throw(DimensionMismatch()) | ||
|
@@ -105,7 +111,7 @@ function _unsafe_mul!(y::AbstractVecOrMat, A::FunctionMap, x::AbstractVector) | |
return y | ||
end | ||
|
||
function _unsafe_mul!(y::AbstractVecOrMat, At::TransposeMap{<:Any,<:FunctionMap}, x::AbstractVector) | ||
function _unsafe_mul!(y::AbstractVecOrMat, At::TransposeFunctionMap, x::AbstractVector) | ||
A = At.lmap | ||
(issymmetric(A) || (isreal(A) && ishermitian(A))) && return _unsafe_mul!(y, A, x) | ||
if A.fc !== nothing | ||
|
@@ -126,7 +132,7 @@ function _unsafe_mul!(y::AbstractVecOrMat, At::TransposeMap{<:Any,<:FunctionMap} | |
end | ||
end | ||
|
||
function _unsafe_mul!(y::AbstractVecOrMat, Ac::AdjointMap{<:Any,<:FunctionMap}, x::AbstractVector) | ||
function _unsafe_mul!(y::AbstractVecOrMat, Ac::AdjointFunctionMap, x::AbstractVector) | ||
A = Ac.lmap | ||
ishermitian(A) && return _unsafe_mul!(y, A, x) | ||
if A.fc !== nothing | ||
|
Uh oh!
There was an error while loading. Please reload this page.