Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Multidimensional example is not working #37

Closed
schneiderfelipe opened this issue Mar 2, 2021 · 3 comments
Closed

Multidimensional example is not working #37

schneiderfelipe opened this issue Mar 2, 2021 · 3 comments

Comments

@schneiderfelipe
Copy link

Hi,

The following example (from the README file) is not working:

julia> using NumericalIntegration

julia> x = range(-π, π, length=50)
-3.141592653589793:0.1282282715750936:3.141592653589793

julia> typeof(x)
StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}

julia> y = sin.(x);

julia> ω = [xᵢ * yᵢ for xᵢ in x, yᵢ in y];

julia> res = integrate((x, y), ω)

julia> typeof(res)
Nothing

The current code also treats StepRangeLen in a different way than Array, although it seems not to be working as well (but for a different reason?):

julia> x = collect(range(-π, π, length=50));

julia> typeof(x)
Array{Float64,1}

julia> y = sin.(x);

julia> ω = [xᵢ * yᵢ for xᵢ in x, yᵢ in y];

julia> res = integrate((x, y), ω)
ERROR: knot-vectors must be sorted in increasing order
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] check_gridded at /home/schneider/.julia/packages/Interpolations/qHlUr/src/gridded/gridded.jl:51 [inlined]
 [3] check_gridded at /home/schneider/.julia/packages/Interpolations/qHlUr/src/gridded/gridded.jl:52 [inlined]
 [4] Interpolations.GriddedInterpolation(::Type{Float64}, ::Tuple{Array{Float64,1},Array{Float64,1}}, ::Array{Float64,2}, ::Interpolations.Gridded{Interpolations.Linear}) at /home/schneider/.julia/packages/Interpolations/qHlUr/src/gridded/gridded.jl:32
 [5] interpolate(::Type{Float64}, ::Type{Float64}, ::Tuple{Array{Float64,1},Array{Float64,1}}, ::Array{Float64,2}, ::Interpolations.Gridded{Interpolations.Linear}) at /home/schneider/.julia/packages/Interpolations/qHlUr/src/gridded/gridded.jl:66
 [6] interpolate at /home/schneider/.julia/packages/Interpolations/qHlUr/src/gridded/gridded.jl:83 [inlined]
 [7] #LinearInterpolation#52 at /home/schneider/.julia/packages/Interpolations/qHlUr/src/convenience-constructors.jl:16 [inlined]
 [8] LinearInterpolation at /home/schneider/.julia/packages/Interpolations/qHlUr/src/convenience-constructors.jl:16 [inlined]
 [9] integrate(::Tuple{Array{Float64,1},Array{Float64,1}}, ::Array{Float64,2}, ::TrapezoidalFast) at /home/schneider/.julia/packages/NumericalIntegration/JrtZK/src/NumericalIntegration.jl:210
 [10] integrate at /home/schneider/.julia/packages/NumericalIntegration/JrtZK/src/NumericalIntegration.jl:203 [inlined]
 [11] integrate(::Tuple{Array{Float64,1},Array{Float64,1}}, ::Array{Float64,2}) at /home/schneider/.julia/packages/NumericalIntegration/JrtZK/src/NumericalIntegration.jl:339
 [12] top-level scope at REPL[41]:1

I'm using the latest version of the package:

julia> versioninfo()
Julia Version 1.4.1
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: AMD Ryzen 5 1600 Six-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, znver1)
Environment:
  JULIA_NUM_THREADS = 12

(@v1.4) pkg> st NumericalIntegration
Status `~/.julia/environments/v1.4/Project.toml`
  [e7bfaba1] NumericalIntegration v0.3.2
@m-wells
Copy link
Contributor

m-wells commented Mar 3, 2021

There is a typo in the README. For the multidimensional example x needs to be redefined to go from -π/2 to π/2 (so that sin(x) is in increasing order from -1 to 1). This fixes the second issue but I will need to look into the first issue. It is mostly likely due to a dispatch error.

@m-wells
Copy link
Contributor

m-wells commented Apr 9, 2021

@dextorious To fully clear out this issue we should make a v0.3.3 release.

@dextorious
Copy link
Collaborator

The release PR is up: JuliaRegistries/General#33958

Once it gets merged, we can close this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants