JuliaLinearAlgebra / LinearMaps.jl

A Julia package for defining and working with linear maps, also known as linear transformations or linear operators acting on vectors. The only requirement for a LinearMap is that it can act on a vector (by multiplication) efficiently.
Other
303 stars 42 forks source link

Require `FunctionMap` to be passed functions #186

Closed JeffFessler closed 2 years ago

JeffFessler commented 2 years ago

Untested... Hopefully would address secondary issue buried within #185.

codecov[bot] commented 2 years ago

Codecov Report

Merging #186 (d507492) into master (99bbc0e) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #186   +/-   ##
=======================================
  Coverage   98.60%   98.60%           
=======================================
  Files          16       16           
  Lines        1365     1365           
=======================================
  Hits         1346     1346           
  Misses         19       19           
Impacted Files Coverage Δ
src/functionmap.jl 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 99bbc0e...d507492. Read the comment docs.

fredrikekre commented 2 years ago

This would disallow callable types, right? You would need to pass LinearMap(x -> A(x)) after this change.

JeffFessler commented 2 years ago

This would disallow callable types, right? You would need to pass LinearMap(x -> A(x)) after this change.

Right. Are there use-cases for that? (The CI doesn't test for them.) It's OK to close this little PR if the preference is to stay with duck typing.

dkarrasch commented 2 years ago

I'm not sure we want this. First, it's technically breaking, and by callable types, one can image, for instance, LinearMaps. They get special treatment and get wrapped, but other people could have

struct CumSum
    n::Int
end
CumSum(x::AbstractVector) = cumsum(x) # up to size checking

to adopt our favourite example from the tests. In fact, I should perhaps add such a callable type to the tests.

Second, the eltype parameter in curly brackets has important precedence in the Julia language, and its usage is very similar to ours:

x = Vector{Int}(undef, 10)

The reason is that T is the first type parameter, and those are always written in curly brackets after the constructor.

JeffFessler commented 2 years ago

ok