Git Product home page Git Product logo

Comments (5)

dlfivefifty avatar dlfivefifty commented on September 27, 2024

Hmm, the IndexLinear stuff is a bit ill-defined for QuasiArrays.jl. So I'm wondering if this should just be removed as a concept?

Probably for now we just need to add an error_if_canonical_getindex overload

from continuumarrays.jl.

jagot avatar jagot commented on September 27, 2024

Actually, I'd be happy if I could just evaluate any function, however complicated, as long as it's defined on the Inclusion and returns a scalar. It feels I too often have to second-guess what QuasiBroadcastArray can handle.

For full context: to implement absorbing boundary conditions, I use a imaginary or complex potential at the far end of the box. It's a simple function that smoothly goes from zero to large imaginary part.

Here is a MWE (depends on Elliptic.jl):

using CompactBases
using IntervalSets
import Elliptic.Jacobi: cn

struct ComplexAbsorbingPotential{T,I}
    Emin::T
    kmin::T
    δ::T
    Δr::T
    interval::I
end

capx(cap::ComplexAbsorbingPotential) =
    r -> 2cap.δ*cap.kmin*r

capy(cap::ComplexAbsorbingPotential) =
    x -> -im*cap.Emin*√(cn(x/√2,1/2)^(-4) - 1)

R = StaggeredFiniteDifferences(100, 0.5)
cap = ComplexAbsorbingPotential(1.0, 2, 0.1, 9.27037338650686,
                                40.97962661349314..50.25)
r = axes(R,1)
i = cap.interval

a,b = i.left,i.right

# Translate cap to interval
x = capx(cap).(r .- a)
v = (a .< r .≤ b) .* capy(cap).(x)

R'*QuasiDiagonal(v)*R

which fails with an error similar to the above.

EDIT: Yet another example:

using IntervalSets
using QuasiArrays
using ContinuumArrays

x = Inclusion(0.0..20.0)
exp.(x)[2.0] # Works
exp.(-x)[2.0] # Crashes
exp.(x.^2)[2.0] # Crashes
exp.(-x.^2/(20/2))[2.0] # Crashes

from continuumarrays.jl.

jagot avatar jagot commented on September 27, 2024

Super, thanks! I was just about to push my own fix, but this looks better.

from continuumarrays.jl.

dlfivefifty avatar dlfivefifty commented on September 27, 2024

Can you see if that branch fixes all the issues?

from continuumarrays.jl.

jagot avatar jagot commented on September 27, 2024

Indeed, it works perfectly!

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.