Giter Club home page Giter Club logo

cubature.jl's People

Contributors

arnostrouwen avatar dependabot[bot] avatar dilumaluthge avatar eschnett avatar femtocleaner[bot] avatar inkydragon avatar jtravs avatar juliatagbot avatar panlanfeng avatar ranocha avatar scheidan avatar staticfloat avatar stevengj avatar timholy avatar tkelman avatar yuyichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cubature.jl's Issues

Integrating complex functions

In the README you recommend integrating complex functions as vectors with PAIRED error. Would you be averse to having a simple Julia wrapper which accepts functions which return complex values? As in does it go against the library philosophy or is it a matter of time? If it is the latter I would be happy to contribute.

Unable to automatically install 'Cubature'

The error message is following

(@v1.7) pkg> add Cubature
Resolving package versions...
Downloaded artifact: Cubature
Downloaded artifact: Cubature
ERROR: Unable to automatically install 'Cubature' from 'C:\Users\zhanglu.julia\packages\Cubature_jll\CVTTF\Artifacts.toml'
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] ensure_artifact_installed(name::String, meta::Dict{String, Any}, artifacts_toml::String; platform::Base.BinaryPlatforms.Platform, verbose::Bool, quiet_download::Bool, io::Base.TTY)
@ Pkg.Artifacts C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\Artifacts.jl:441
[3] download_artifacts(env::Pkg.Types.EnvCache; platform::Base.BinaryPlatforms.Platform, julia_version::VersionNumber, verbose::Bool, io::Base.TTY)
@ Pkg.Operations C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:617
[4] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, new_git::Set{Base.UUID}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform)
@ Pkg.Operations C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1182
[5] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
@ Pkg.API C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\API.jl:268
[6] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Pkg.API C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\API.jl:149
[7] add(pkgs::Vector{Pkg.Types.PackageSpec})
@ Pkg.API C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\API.jl:144
[8] do_cmd!(command::Pkg.REPLMode.Command, repl::REPL.LineEditREPL)
@ Pkg.REPLMode C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:407
[9] do_cmd(repl::REPL.LineEditREPL, input::String; do_rethrow::Bool)
@ Pkg.REPLMode C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:385
[10] do_cmd
@ C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:376 [inlined]
[11] (::Pkg.REPLMode.var"#24#27"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
@ Pkg.REPLMode C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:549
[12] #invokelatest#2
@ .\essentials.jl:716 [inlined]
[13] invokelatest
@ .\essentials.jl:714 [inlined]
[14] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\LineEdit.jl:2493
[15] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL C:\Users\zhanglu\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:1230
[16] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL .\task.jl:423

host source/binary downloads on another server?

Both yesterday and today the ab-initio.mit.edu server was awfully slow, making it impossible to download the file cubature-1.0.2.tar.gz when installing this package. This is GPLed code, so I believe it should be fine to just mirror the file here on Github and use that link when installing the package.

hcubature does not converge on discontinuous functions

As discussed in giordano/Cuba.jl#16, hcubature seems to fail for a discontinuous integrand (see MWE there). The integrand is the indicator function of a polygon, so a Riemann sum with NxN points should be accurate to 1/N, and the integral should be about 0.88408, with a small error on the last digit. When running Cuba vs Cubature for decreasing values of abstol (reltol and maxiters are fixed at 0), I get:

0.8840847072116771 ± 9.995513758054815e-5 (Cuba.jl)
0.8848895327256797 ± 9.998142861595564e-5 (Cubature.jl)

0.8840898028407925 ± 9.998969682594401e-6 (Cuba.jl)
0.8848941514595511 ± 9.999535960807015e-6 (Cubature.jl)

0.8840867311005485 ± 9.99974855348049e-7 (Cuba.jl)
0.8848940796576487 ± 9.999981972972212e-7 (Cubature.jl)

0.8840865507480177 ± 9.999859751764881e-8 (Cuba.jl)
0.8848940808860499 ± 9.999994401879008e-8 (Cubature.jl)

So Cuba looks about right, but Cubature appears to fail in that case.

Example for hcubature_v / pcubature_v?

Would it be possible to get an example for the _v integration routines?

Alternatively, is there a way to "retrieve", as an array, the points where the integrand was evaluated (and the corresponding integrand values)?

Could a similar approach be used to provide nlopt for Julia?

I was wondering if the approach of using a global object until such time as cfunction can support a closure could also be used to generate a Julia package for the nlopt library? I would be willing to help in whatever way I can on such a project (although I realize it may be faster for you to work on it alone) because I really want to be able to optimize a nonlinear function subject to box constraints.

hquadrature and pquadrature do not match for a simple 1d example

MWE:

using Cubature

function V(x)
       return cos(4*π*x)
end
function μ(x)
       return exp(-V(x))
end

pquadrature(μ,0,1)
#(0.3678794411714423, 5.551115123125783e-17)

hquadrature(μ,0,1)
#(1.2660658777520202, 1.6177162823726988e-9)

I tried to change the absolute/relative error in the function calls, but it did not matter. I was expecting the two outputs to be approximately the same.
Cubature version: 1.5.1
Julia version: 1.6.3

hquadrature hangs for function that integrates to zero (unless abstol is set)

hquadrature(sin, 0.0, 2*pi)

Info on my machine and Julia version:

Julia Version 0.6.1
Commit 0d7248e2ff (2017-10-24 22:15 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

Suggest a simple example of change of variables.

Although there is a link introducing how to apply change of variables method to compute integrals over infinite or semi-infinite domains, I think taking an example would be more friendly way to explain how to use it.

If f(x)=1/(x^2), we could calculate the integral of f(x) over [a, ∞] by hands in advance.

To compute an integral over a semi-infinite interval, you have to perform the change of variables x=a+t/(1-t):

Now we could turn all of them into Julia script.

a = 1 # assume that the lower bound of integral is 1.

function f(x)
	return 1/(x^2)
end

function g(a, t)
	return f(a+(t/(1-t)))*(1/(1-t)^2)
end

hquadrature(g, 0, 1)

returning (1.0, 1.1102230246251565e-14) which are the same as our calculation by hands.

c++ error while importing

Hi,

I recently upgraded to Julia version 0.4.0 on my Mac running OS X Yosemite Version 10.10.5. I was able to add the package Cubature with no problems but when I try to import it:

using Cubature

I get the following error and Julia crashes:

julia> using Cubature
Assertion failed: (ctx->gensym_assigned.at(idx)), function emit_expr, file codegen.cpp, line 3130.

signal (6): Abort trap: 6
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Abort trap: 6

Because I believe this may be a C/C++ complier error I've attached the information regarding gcc/g++

Tyche: ~/Research/notebooks $ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

Tyche: ~/Research/notebooks $ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

Is this a known issue? Have I not upgraded some important software?

Improper integration problem.

using QuadGk
value , error = quadgk(f9, 1, 1e20)
(0.785398163397316, 2.03069694813391e-9)

using Cubature 
value , error = hquadrature(f9, 1, 1e20)
(1.5707963267948977, 3.9302603196994814e-10)

a better notation in the README

As writes in the README, when the integrand is multi-dimensional, it should be passessed as f(x, v), and it should be noted that v is assigned in f. I am thinking it is better to name the integrand with an additional ! suffix to remind the fact that f changes its arguments. And the notation in integrals of vector valued integrands of the README would be more straitforward to julia users.

Example of integral over semi-infinite domain

Hi Steven!

I'm using Cubature.jl to compute an integral over semi-infinite domain, and I was wondering if you have any example on how to do that. I've looked at http://ab-initio.mit.edu/wiki/index.php/Cubature#Infinite_intervals and understood how to do integration by change of variables (on paper) but I'm really not sure how to translate it to code. My (wrong) attempt so far:

Since x = a + t/(1-t), I solve for t in change_var()

change_var(x, a) = (x-a) / (1+x-a)
hquadrature(x -> change_var(x, 3) -> f(t) / (1-t)^2, 0, 1)

, where a is the lower limit (3 in this case) and infinity is the lower limit. Am I on the right track, and how should I perform integration by change of variables?

Thanks in advance,
Khoa

Error compiling cubature : could not load library "libcubature"

Hi there,

I recently tried to use Cubature, but I got that error, which appears when I try to use a function of the package (it has been installed and imported without raising any error).

LoadError: error compiling cubature: error compiling #17: could not load library "C:\Users\Benoit\.julia\v0.5\Cubature\src\..\deps\libcubature"
%1 is not a valid Win32 application.

while loading C:\Users\Benoit\Documents\Université\Master Project\test.jl, in expression starting on line 18
 in #hcubature#22(::Float64, ::Int64, ::Int64, ::Function, ::Function, ::Array{Float64,1}, ::Array{Float64,1}) at Cubature.jl:232
 in hcubature(::Function, ::Array{Float64,1}, ::Array{Float64,1}) at Cubature.jl:232
 in include_string(::String, ::String) at loading.jl:441
 in include_string(::Module, ::String, ::String) at eval.jl:32
 in (::Atom.##59#62{String,String})() at eval.jl:73
 in withpath(::Atom.##59#62{String,String}, ::String) at utils.jl:30
 in withpath(::Function, ::String) at eval.jl:38
 in macro expansion at eval.jl:71 [inlined]
 in (::Atom.##58#61{Dict{String,Any}})() at task.jl:60

I am using Windows 8 and the Juno package for Atom to run Julia.
I tried to reinstalled the package but nothing changed.

Mysteriously (for me at least), if I try Pkg.build("Cubature"), I get

INFO: Cubature 1.0.2 is already installed.

which is strange since Pkg.status() tell me that my version of Cubature is 1.2.1.

That's it, thanks for both your attention and the package.

how to cite when using this package?

Sorry for asking questions in issue. But I have used this package heavily in my work and I think I should give it a citation. In the README there are complex references about the theoretical work and code, so I am kind of confused about how to cite. Would you please give a 'how to cite' section?

memory leaks in hcubature.c ?

I was running hcubature_v many, many times in a row without theoretically allocating any new space, and it ended up filling 32 GB of RAM. I am not sure whether this is a cubature thing or a Julia thing (I'm still testing), but it seems that replacing the zero-resize in

static void heap_free(heap *h)
{
     h->n = 0;
     heap_resize(h, 0);
     h->fdim = 0;
     free(h->ee);
}

with an explicit free

static void heap_free(heap *h)
{
     h->n = 0;
     h->nalloc = 0;
     free(h->items);
     h->items = NULL;
     h->fdim = 0;
     free(h->ee);
}

fixes at least a large part of the memory issue.

I'm on Mac OS X Yosemite and checked that the same behaviour occurs with your provided library and with a self-built one.

pquadrature for oscillating integrals

I get wrong results when I use pquadrature to compute the Fourier transform of a Gaussian, but only when abstol is set to a value other than the default value.

The commented out lines (changing the integration limits, leaving abstol to its default value and using quadgk) all give the correct result.

using PyPlot
using Cubature

function test_numerical_integration_FT()
    t_c, σ = 0.05, .7
    freq = linspace(-.2, .2, 21)
    y_imag = zeros(freq)
    for i = 1:length(freq)
        f_red = 2π * freq[i]
        y_imag[i] = -pquadrature(t -> exp(-(t - t_c)^2 / 2σ^2) * sin(f_red * t), -5., 5., abstol=1e-10)[1]
        #y_imag[i] = -pquadrature(t -> exp(-(t - t_c)^2 / 2σ^2) * sin(f_red * t), -5., 5.1, abstol=1e-10)[1]
        #y_imag[i] = -pquadrature(t -> exp(-(t - t_c)^2 / 2σ^2) * sin(f_red * t), -5., 5.)[1]
        #y_imag[i] = -quadgk(t -> exp(-(t - t_c)^2 / 2σ^2) * sin(f_red * t), -5., 5., abstol=1e-3, reltol=1e-3)[1]
    end
    # analytical FT
    y = sqrt(2π)σ * exp(-2π * freq .* (π * freq * σ^2 + 1im * t_c))
    figure(); grid(true)
    plot(freq, y_imag, label="numerical, imag")
    plot(freq, imag(y), label="analytical, imag")
    legend(frameon=false)
end

Very slow for one-dimensional integral

Hi,

I noticed that hquadrature sometimes does not work. For example, the command

hquadrature(sin, -5,  5)

does not terminate. Is this a known issue? Strangely, the command works well if maxevals is provided.

specify order of pcubature rule

pcubature gives the wrong answer when integrating sin(x)^2 in the interval [0,2π]: it should be π, it returns instead 0 (thread in discourse)

julia> pcubature(x -> sin(x[1])^2, [0.0], [2π], reltol=1e-6, abstol=1e-4)
(1.2564358174293111e-31,3.1410895435732783e-32)
julia> hcubature(x -> sin(x[1])^2, [0.0], [2π], reltol=1e-6, abstol=1e-4)
(3.1415926535897936,8.38977585329799e-9)

This is because pcubature starts with a low order rule and samples the integrand at the three points 0, π and 2π for which sin^2 is identically 0. Similarly, when the integrand is cos^2 it returns 2π because the integrand at those points is 1. (Note that hcubature gives the correct result in both cases.)

Currently there is no way of specifying a higher order rule: can this be supported?

Package doesn't work in Julia 0.5

At least since 2016-05-24 (see http://pkg.julialang.org/detail/Cubature.html) this package doesn't work in Julia 0.5. This is an excerpt from http://pkg.julialang.org/logs/Cubature_0.5.log:

ERROR: LoadError: sigatomic_end called in non-sigatomic region
 in cubature(::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::Function, ::Int64, ::Int64, ::Float64, ::Float64, ::Int64, ::Int32) at /home/vagrant/.julia/v0.5/Cubature/src/Cubature.jl:213
 in #hquadrature#12(::Float64, ::Float64, ::Int64, ::Function, ::Function, ::Int64, ::Int64) at /home/vagrant/.julia/v0.5/Cubature/src/Cubature.jl:227
 in (::Cubature.#kw##hquadrature)(::Array{Any,1}, ::Cubature.#hquadrature, ::Function, ::Int64, ::Int64) at ./null:0
 in include_from_node1(::String) at ./loading.jl:426
 in process_options(::Base.JLOptions) at ./client.jl:266
 in _start() at ./client.jl:322
while loading /home/vagrant/.julia/v0.5/Cubature/test/runtests.jl, in expression starting on line 7

Move package to JuliaMath

@stevengj Do you think it is a good idea to move this project into JuliaMath? The code itself seems to require little to no maintenance, but putting it in the JuliaMath org might allow people to contribute to package maintenance such as #47.

Access to number of function evaluations

In order to assess the sampling efficiency of cubature methods, I'd like to be able to retrieve the number of evaluations used by the cubature code. I can see it is possible to set the maximum number of evaluations, but this doesn't help.

Suggest a example, which is easy to understand, of function 'hcubature'.

The integrand in the example now is written in the form of inline function.

But, I believe it's easier to understand how to use 'hcubature' when the integrand is written in "caller" style. Because it's more often using multi-dimensional integrals of more complex function than f(x, y)=(x^3)*y.

I mean that maybe the example of 'hcubature' could use the following codes.

# ORIGINAL example
hcubature(x -> begin println(x[1],",",x[2]); x[1]^3*x[2]; end, [0,0],[1,1])
# SUGGESTION example
function f( x::Vector{Float64} ) # the integrand i.e., f(x, y)=x^3 y
    println(x[1], ",", x[2])
    return (x[1]^3) * x[2]
end
hcubature(f, [0,0],[1,1])

build error because of SDE dependence

Recently when I tried to update and build Cubature with Pkg.update() and Pkg.build("Cubature") I got a build error:

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
==============================[ ERROR: Cubature ]============================

LoadError: failed process: Process(`tar xzf cubature-1.0.2.tar.gz --directory=.`, ProcessExited(2)) [2]
while loading ~/.julia/v0.5/Cubature/deps/build.jl, in expression starting on line 17

=============================================================================

=============================[ BUILD ERRORS ]==============================

WARNING: Cubature had build errors.

 - packages with build errors remain installed in /home/sayed/.julia/v0.5
 - build the package(s) and all dependencies with `Pkg.build("Cubature")`
 - build a single package by running its `deps/build.jl` script

==========================================================================

Or when I try to run a simple code I get:

using Cubature
hcubature(x->x^2,0,2)
ERROR: error compiling cubature: could not load library "~/.julia/v0.5/Cubature/src/../deps/libcubature"
~/.julia/v0.5/Cubature/src/../deps/libcubature: cannot open shared object file: No such file or directory in hcubature at ~/.julia/v0.5/Cubature/src/Cubature.jl:227

So I checked this page, and it says Cubature passes the build tests. Then I checked the dependencies with Pkg.dependents("Cubature") which gives:

2-element Array{AbstractString,1}:
 "SDE"            
 "KernelEstimator"

and SDE fails the build test.

Because I have some amount of code which uses cubature, what is a temporary work around for this problem?

version:

Version 0.5.0-dev+433 (2015-09-29 15:39 UTC)
Commit e60fd18 (103 days old master)
x86_64-linux-gnu

h-adaptive algorithm only evaluates the integrand at the interior of the domain?

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0 (2017-06-19 13:05 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> using Cubature
julia> hquadrature(x-> 1/sqrt(1-x^2),0.0,1.0)
(Inf, NaN)

If hquadrature only evaluates the integrand at the interior of the domain I would expect pi/2 in this example.

passing parameters to function for integration?

Is it possible to pass parameters to the function that will be integrated? For example if I am integrating Ae^x, and the value of A might change, can I do something like

function f(x,A)
    return Aexp^x
end
Avec=[1 2 3 4]
Res=ones(length(Avec))
for i in 1:length(Avec)
    Res[i]=pquadrature(f(Avec[i],x),xmin, xmax,reltol=1e-8, abstol=0, maxevals=0)
end

?

Pkg.add fails: ERROR: download_cmd not defined

I'm trying to install Cubature, but Pkg.add emits an error.

My version of julia is:

Version 0.2.0-1474.r6912a42a.dirty
Commit 6912a42a6a 2013-05-10 20:23:09*

The error I get:

julia> Pkg.add("Cubature")
MESSAGE: Installing BinDeps v0.0.1
 in anonymous at no file:163
Cloning into 'BinDeps'...
remote: Counting objects: 52, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 52 (delta 19), reused 50 (delta 19)
Receiving objects: 100% (52/52), 11.29 KiB, done.
Resolving deltas: 100% (19/19), done.
MESSAGE: Installing Cubature v0.1.0
 in anonymous at no file:163
Cloning into 'Cubature'...
remote: Counting objects: 49, done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 49 (delta 18), reused 38 (delta 7)
Receiving objects: 100% (49/49), 29.09 KiB, done.
Resolving deltas: 100% (18/18), done.
MESSAGE: Running build script for package Cubature
 in cd at file.jl:25
ERROR: download_cmd not defined
 in evalfile at loading.jl:144
 in anonymous at no file:249
 in cd at file.jl:25
 in runbuildscript at pkg.jl:246
 in _resolve at pkg.jl:361
 in anonymous at no file:163
 in cd at file.jl:25
 in cd_pkgdir at pkg.jl:42
 in add at pkg.jl:143
 in add at pkg.jl:175

Cubature.jl is broken on Julia 0.6

Cubature.jl is currently broken on Julia master, probably due to JuliaLang/julia#17057. See the log from package evaluator:

ERROR: LoadError: MethodError: no method matching quad_tst1(::Array{Float64,1})
The applicable method may be too new: running in world age 20394, while current world is 20395.
Closest candidates are:
  quad_tst1(::Any) at /home/vagrant/.julia/v0.6/Cubature/test/runtests.jl:10 (method too new to be called from this world context.)
 in (::Cubature.##17#18{Bool,Bool,Int64,Float64,Float64,Int64,Int32,Int64})() at /home/vagrant/.julia/v0.6/Cubature/src/Cubature.jl:208
 in disable_sigint at ./c.jl:326 [inlined]
 in cubature(::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::Function, ::Array{Float64,1}, ::UnitRange{Int64}, ::Float64, ::Float64, ::Int64, ::Int32) at /home/vagrant/.julia/v0.6/Cubature/src/Cubature.jl:162
 in #hcubature#22(::Float64, ::Float64, ::Int64, ::Function, ::Function, ::Array{Float64,1}, ::UnitRange{Int64}) at /home/vagrant/.julia/v0.6/Cubature/src/Cubature.jl:223
 in (::Cubature.#kw##hcubature)(::Array{Any,1}, ::Cubature.#hcubature, ::Function, ::Array{Float64,1}, ::UnitRange{Int64}) at ./<missing>:0
 in macro expansion; at /home/vagrant/.julia/v0.6/Cubature/test/runtests.jl:15 [inlined]
 in anonymous at ./<missing>:?
 in include_from_node1(::String) at ./loading.jl:532
 in include(::String) at ./sysimg.jl:14
 in process_options(::Base.JLOptions) at ./client.jl:293
 in _start() at ./client.jl:357
while loading /home/vagrant/.julia/v0.6/Cubature/test/runtests.jl, in expression starting on line 11

Error reported on discourse, but got no solution. I'm interested also because Cuba.jl is broken as well, for the same exact reason ;-)

hcubature hangs on some integrand

hcubature seems to hang for some integrands when the integrand is symmetric in the domain of integration and the tolerance is sufficiently high.

julia> hcubature(x -> (1.0+(x[1]*x[3]*cos(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], abstol=1e-6)
(0.5026995050032178,3.3306690738754696e-16)
julia> hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.20001], [0.2,2π,0.2], abstol=1e-6) # note the domain of integration
(0.502712074725032,4.440892098500626e-16)
julia> hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], abstol=1e-6) # hangs forever
julia> hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], abstol=1e-3) # note the reduced tolerance
(0.5026887210432646,3.325688687261241e-5)

(Sorry for the contrived example: I could not find one with lower dimensionality.)

Installation Fails: Missing package versions

Using bleeding edge Julia:

> Pkg.add("Cubature") 
INFO: Updating cache of Cubature...
ERROR: Missing package versions (possible metadata misconfiguration):  Cubature v(nothing,v"1.0.1") [3a57cb6fb52c58a5ad0e3277408f7eabf99943f6[1:10]]

 in error at error.jl:21
 in _resolve at pkg.jl:210
 in _resolve at no file
 in anonymous at no file:33
 in cd at file.jl:25
 in cd at pkg/dir.jl:28
 in edit at pkg.jl:23
 in add at pkg.jl:20

I wasn't sure whether to file this issue here or JuliaLang/METADATA.jl, as it looks like the sha1 that 1.0.1 points to does not exist (yet?) in this repository.

Simple integration over sin(x) fails

I'm on Ubuntu 14.04 with Julia 0.3.5. I got interested with this thread on Julia user group, in which the OP was using quadgk to do integration. I tried Cubature and the results were even odder. Am I missing something here

pquadrature(x -> sin(x), 0, pi)
(1.9999999999999998,2.6597646307635614e-9)

is normally executed. But

pquadrature(x -> sin(x), 0, 2*pi)
ERROR: hcubature error 1
 in cubature at /home/xiaoweiz/.julia/v0.3/Cubature/src/Cubature.jl:203
 in pquadrature at /home/xiaoweiz/.julia/v0.3/Cubature/src/Cubature.jl:220

fails, and

hquadrature(x -> sin(x), 0, 2*pi)

kills Julia kenel with

[1]    2642 bus error (core dumped)  julia

Example of bivariate integration over semi-infinite domain

Hi I was wondering if you could give an example of how to do the change-of-varaibles trick for integrating a function of two variables over a semi-infinite domain? I read this http://ab-initio.mit.edu/wiki/index.php/Cubature#Infinite_intervals but wasn't sure if I could just repeated the procedure for two variables. I am trying to integrate a joint probability distribution; it happens to be a lognormal. Here is what I did:

  qdp(p) =hcubature(x-> begin
    l = x[2]/(1-x[2])
    ɛ = x[1]/(1-x[1])
    if l*p>ɛ
      return 0
    end
    l*f(ɛ,l)/((1-x[1])*(1-x[2]))^2
  end, [0,0],[1,1])[1]

Error: Error building `Cubature`

With Cubature v1.5.0 I get a

Error: Error building `Cubature`: 
│ ERROR: LoadError: ArgumentError: Package BinaryProvider not found in current path:- Run `import Pkg; Pkg.add("BinaryProvider")` to install the BinaryProvider package.
│ 
│ Stacktrace:
│  [1] top-level scope at none:5in expression starting at /home/j/.julia/packages/Cubature/NwQxL/deps/build.jl:1
└ @ Pkg.Operations /build/julia/src/julia-1.4.0/usr/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892

Precompilation crash? on OS X 10.11.2

$ julia --version
julia version 0.4.2

$ julia
julia> using Cubature
Assertion failed: (ctx->gensym_assigned.at(idx)), function emit_expr, file codegen.cpp, line 3136.

signal (6): Abort trap: 6
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
[1]    78750 abort      julia

$ uname -a
Darwin <hostname> 15.2.0 Darwin Kernel Version 15.2.0; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64

i.e. This is on OS X 10.11.2 (15C50). Perhaps this is a Julia bug, in which case I will report it upstream.

Possible error on 1.1

Hi,
I have the following error in my code on Julia 1.1.1 with Cubature 1.4.0. The error is likely from my code, and I am going to try and extract a MWE. However, the stack trace suggests the error could be from Cubature. Is it possible?

ERROR: LoadError: setfield! immutable struct of type IntegrandData cannot be changed
Stacktrace:
 [1] setproperty! at .\sysimg.jl:19 [inlined]
 [2] qintegrand_v(::UInt32, ::UInt64, ::Ptr{Float64}, ::Cubature.IntegrandData{getfield(Luna.Modes, Symbol("##2#3")){Luna.Modes.TransModalRadial{Array{Any,1},FFTW.rFFTWPlan{Float64,-1,false,2},Tuple{getfield(Luna.Nonlinear, Symbol("#Kerr#1")){Float64}},Luna.Grid.RealGrid,typeof(densityfun)}}}, ::UInt32, ::Ptr{Float64}) at C:\Users\John\.julia\packages\Cubature\Iqftj\src\Cubature.jl:96
 [3] #17 at C:\Users\John\.julia\packages\Cubature\Iqftj\src\Cubature.jl:181 [inlined]
 [4] disable_sigint(::getfield(Cubature, Symbol("##17#18")){Bool,Bool,Int64,Float64,Float64,Int64,Int32,Int64,Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Cubature.IntegrandData{getfield(Luna.Modes, Symbol("##2#3")){Luna.Modes.TransModalRadial{Array{Any,1},FFTW.rFFTWPlan{Float64,-1,false,2},Tuple{getfield(Luna.Nonlinear, Symbol("#Kerr#1")){Float64}},Luna.Grid.RealGrid,typeof(densityfun)}}},Ptr{Nothing}}) at .\c.jl:446
 [5] cubature at C:\Users\John\.julia\packages\Cubature\Iqftj\src\Cubature.jl:178 [inlined]
 [6] #pquadrature_v#31 at C:\Users\John\.julia\packages\Cubature\Iqftj\src\Cubature.jl:236 [inlined]
 [7] #pquadrature_v at .\none:0 [inlined]
 [8] (::Luna.Modes.TransModalRadial{Array{Any,1},FFTW.rFFTWPlan{Float64,-1,false,2},Tuple{getfield(Luna.Nonlinear, Symbol("#Kerr#1")){Float64}},Luna.Grid.RealGrid,typeof(densityfun)})(::Array{Complex{Float64},2}, ::Array{Complex{Float64},2}, ::Int64) at C:\Users\John\Documents\GitHub\Luna\src\Modes.jl:164
....

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.