Skip to content

Conversation

@ashutosh-b-b
Copy link
Contributor

@ashutosh-b-b ashutosh-b-b commented Oct 1, 2024

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@ashutosh-b-b ashutosh-b-b marked this pull request as ready for review October 1, 2024 16:32
@ChrisRackauckas
Copy link
Member

This only fixes matrix, not the array. Fix the array dispatch.

@ashutosh-b-b
Copy link
Contributor Author

This only fixes matrix, not the array. Fix the array dispatch.

We intend to fix the AbstractMatrix right? The AbstractArray corresponds to when ndims(A) > 2. Right now the output looks like this:

julia> using DataInterpolations

julia> u2d = rand(5,5);

julia> t = 0:1:4
0:1:4

julia> LinearInterpolation(u2d, t)(0.1)
5-element Vector{Float64}:
 0.6412661219777369
 0.45226380542841466
 0.667059578536869
 0.3410690837298372
 0.8883286346809633

julia> u3d = rand(5,5,5);

julia> LinearInterpolation(u3d, t)(0.1)
5×5×1 Array{Float64, 3}:
[:, :, 1] =
 0.885232  0.433556   0.225437  0.683801  0.450121
 0.572518  0.0916726  0.244869  0.339845  0.472721
 0.346758  0.568071   0.823261  0.231083  0.803863
 0.627925  0.158742   0.909838  0.38132   0.846073
 0.381645  0.756691   0.31842   0.106938  0.565953

@sathvikbhagavan
Copy link
Member

For N-D called with just a single time point, shouldn't it be (N-1)-D output?

@ashutosh-b-b
Copy link
Contributor Author

For N-D called with just a single time point, shouldn't it be (N-1)-D output?

Right, fixed it now the output looks like this:

julia> u2d = rand(5,5);

julia> u3d = rand(5,5,5);

julia> t = 0:1:4
0:1:4

julia> LinearInterpolation(u2d, t)(0.12)
5-element Vector{Float64}:
 0.8955879753612471
 0.17218902066690886
 0.5403394528994946
 0.28106129729671586
 0.264249745025073

julia> LinearInterpolation(u3d, t)(0.12)
5×5 Matrix{Float64}:
 0.491654  0.237982  0.819793  0.93269    0.516005
 0.480924  0.733239  0.543345  0.0662969  0.67747
 0.552783  0.18947   0.362321  0.238529   0.0915166
 0.625032  0.844209  0.498186  0.171338   0.357868
 0.485161  0.653258  0.703258  0.860978   0.0744935

@ChrisRackauckas ChrisRackauckas merged commit 7b36a83 into SciML:master Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants