Git Product home page Git Product logo

Comments (10)

putianyi889 avatar putianyi889 commented on June 26, 2024

This may be related.
#17

It seems that only linear continuum indices is supported.

from continuumarrays.jl.

putianyi889 avatar putianyi889 commented on June 26, 2024

The getindex approach is a workaround.

julia> g=getindex.((f,),f)
getindex.(Tuple{QuasiArrays.BroadcastQuasiVector{Float64, typeof(Base.literal_pow), Tuple{Base.RefValue{typeof(^)}, Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, Base.RefValue{Val{2}}}}}, (Inclusion(0..1)) .^ 2)

julia> g[0.5]
0.0625

So we can do this:

julia> Base.getindex(A::AbstractQuasiArray,B::AbstractQuasiArray) = getindex.((A,),B);
       g=f[f];
       g[0.5]
0.0625

I'm not sure about the efficiency.

from continuumarrays.jl.

dlfivefifty avatar dlfivefifty commented on June 26, 2024

It looks like the issue is bounds-checking. That is, we want issubset(Inclusion(0..1).^2, Inclusion(0..1)) to return true.

We could probably do something like:

issubset(a::BroadcastQuasiVector{<:Any, typeof(Base.literal_pow), <:Tuple{Base.RefValue{typeof(^)}, Any, Base.RefValue{Val{2}}}}, b::Inclusion{<:Any,<:ClosedInterval}) = issubset(a.args[1], Inclusion(sqrt(max(0,first(b)), sqrt(max(0,last(b))))

from continuumarrays.jl.

putianyi889 avatar putianyi889 commented on June 26, 2024

Did that "affine transform" issue use the same workflow? If so, we may cover a few other basic functions.

from continuumarrays.jl.

dlfivefifty avatar dlfivefifty commented on June 26, 2024

Actually, we pass through a call to union, which is what we use to determine the "range":

Base.issubset(d::Map, b) = union(d) b

union(d::AbstractAffineQuasiVector) = Inclusion(minimum(d)..maximum(d))

from continuumarrays.jl.

putianyi889 avatar putianyi889 commented on June 26, 2024

Adding a subtype of Map should solve my problem. However I would like generic continuum indices to work as well. One reason is that the expression f[f] is easy to understand. Another reason is that creating and maintaining interfaces for all known maps is exhaustive.

from continuumarrays.jl.

dlfivefifty avatar dlfivefifty commented on June 26, 2024

Agreed. Try my suggestion?

from continuumarrays.jl.

putianyi889 avatar putianyi889 commented on June 26, 2024

Do you mean the issubset or the union?

For generic quasivector, the range is usually hard to tell. I prefer passing the responsibility of boundschecking to users.

Although an unknown interval which may exceed bounds makes the whole thing bad-defined, in practice, we always evaluate a finite number of values and all variables reduce to finite vectors which can be boundschecked as usual.

Checking bounds for the whole interval does reduce the cost of checking every value later. I agree we can have this feature for common functions.

My thought is to let issubset to return true as default and override it for specific cases. I guess unsafe_view on continuumarrays won't cause memory problems.

from continuumarrays.jl.

putianyi889 avatar putianyi889 commented on June 26, 2024

What's the disadvantage of unsafe_view?

from continuumarrays.jl.

dlfivefifty avatar dlfivefifty commented on June 26, 2024

Right, Base.unsafe_getindex or unsafe_view might be a good interface

from continuumarrays.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.