Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor: methods for higher dim arrays #348

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sathvikbhagavan
Copy link
Member

@sathvikbhagavan sathvikbhagavan commented Oct 17, 2024

  • QuadraticInterpolation
  • LagrangeInterpolation
  • AkimaInterpolation
  • ConstantInterpolation
  • QuadraticSpline
  • CubicHermiteSpline
  • QuinticHermiteSpline
  • Derivatives
  • Integrals
  • Show methods for higher dim arrays
  • Add tests for all

@ashutosh-b-b
Copy link
Contributor

This adds methods for BSplines: #349

@sathvikbhagavan
Copy link
Member Author

Cool, I will add the rest.

@ashutosh-b-b
Copy link
Contributor

There is one more issue that needs to be added to the checklist. The show methods fail when in Array{T, N} N >= 3

@sathvikbhagavan
Copy link
Member Author

Yes, I am aware about that. Added it to the checklist.

@ashutosh-b-b
Copy link
Contributor

ashutosh-b-b commented Oct 22, 2024

Do we need to write different dispatches for Vector{Vector} implementation of BSplines? Essentially we can get away with:

BSplineInterpolation(u::AbstractVector{<:AbstractVector}, args...; kw...) = BSplineInterpolation(reduce(hcat, u), args...; kw...)
# Same for BSplineApprox

@ChrisRackauckas
Copy link
Member

reduce(hcat, u) is a fairly expensive operation.

@ashutosh-b-b
Copy link
Contributor

ashutosh-b-b commented Oct 23, 2024

reduce(hcat, u) is a fairly expensive operation.

But in existing methods we do it anyways. For example in the method for CubicSplines{Vector{Vector}} we do a reduce(hcat, d) down here:

d = transpose(reshape(reduce(hcat, d_), :, n + 1))

And the complexity of this reduce(hcat) is the same as reduce(hcat, u) .
Similarly for BSplines: we do a matrix division right here:

which will need a reduce(hcat) over all vector of vectors.

Meanwhile, all of this happens during the construction of the interpolation function. So we donot loose on performance while actually interpolating.

@ChrisRackauckas
Copy link
Member

Doing it once for construction is fine.

But note that only works for the linear algebra. If you do that, you will change the type of the output, so something like a ComponentArray will loose its type and structure.

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