Giter Club home page Giter Club logo

Comments (7)

stevengj avatar stevengj commented on August 18, 2024 1

No, unfortunately, Julia doesn't have arrow types.

from cubature.jl.

stevengj avatar stevengj commented on August 18, 2024

I don't want a whole other set of cubature functions. I guess we could have a wrapper

complexfunc(f) = (x,v) -> let c = f(x); v[1] = real(c); v[2] = imag(c); end
vec2complex(v) = Complex(v[1],v[2])

So that they you could do e.g. vec2complex(hquadrature(2, complexfunc(f), ...)[1]).

from cubature.jl.

jondea avatar jondea commented on August 18, 2024

I suppose there is no way to do a clever dispatch based on what f returns (or even the type of arguments it takes).

from cubature.jl.

jondea avatar jondea commented on August 18, 2024

That's very neat, I have never seen the concept expressed like that, thank you. Also on an off topic note, I must thank you for your online maths resources, which I have found useful on several occasions (namely your PML tutorial and differentiation by FFT).

from cubature.jl.

dazsmith avatar dazsmith commented on August 18, 2024

Here's a slight generalisation of the wrapper which also allows for complex intervals of integration:

complexfunc(f) = (x,v) -> let c = f(x); v[1] = real(c); v[2] = imag(c); end;
vec2complex(v) = Complex(v[1],v[2]);
hquadratureCOMPLEX(f,a,b) = vec2complex(hquadrature(2, complexfunc(t -> f(a+t*(b-a))*(b-a)),0,1,abstol=1e-8)[1]);

It must be possible to improve this so that the named argument abstol can be passed to hquadratureCOMPLEX rather than set in the wrapper itself, but I'm new to Julia. I'll update if I figure it out.

from cubature.jl.

stevengj avatar stevengj commented on August 18, 2024

Ultimately, the right way to solve this is to rewrite in pure Julia.

from cubature.jl.

stevengj avatar stevengj commented on August 18, 2024

See https://github.com/stevengj/HCubature.jl for a pure-Julia re-implementation of hcubature that handles complex integrands, etc.

from cubature.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.