https://kotlinlang.org logo
#mathematics
Title
# mathematics
p

PHondogo

02/14/2023, 7:34 AM
Hello! Is there KMath analog for org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction?
a

altavir

02/14/2023, 8:12 AM
I did not work on 2D interpolation. There is a wrapper for commons math in https://github.com/SciProgCentre/kmath/tree/dev/kmath-commons, but it does include 2d interpolation. Could you please create an issue with a problem description, so we can add either wrapper or multiplatform implementation in the next release?
Contributions are welcome as always. There is a more or less stable API for 1D interpolation here: https://github.com/SciProgCentre/kmath/blob/784d397ab12103bae441d770b8ee6c2f8e0c03[…]nMain/kotlin/space/kscience/kmath/interpolation/Interpolator.kt. I am not sure if it is good for 2d interpolation.
Actually... it shoul work with Vector2D for X...
The problem with 2D interpolation is that it is not clear how the data and result are represented. For example numpy uses bizarre meshes, but as far as I can remember, it could not handle non-uniform points.
p

PHondogo

02/14/2023, 8:50 AM
Alexander, thanks for answering! I'm developing Kotlin multiplatform project for working with surfaces. Surface is given by points matrix and to be able to render it at any scale I need to interpolate. Now client is using Jetpack Compose Canvas (working in JVM Desktop and Android for now). For interpolation I'm using PiecewiseBicubicSplineInterpolatingFunction by Apache Commons Math. Now I'm trying to adopt it for JS target and looking for math multiplatform library.
a

altavir

02/14/2023, 8:54 AM
I usually just take Commons Math code and port it to multiplatform, generifying and optimizing it along the way. CM bicubic spline seems to be a thin wrapper on top of 1D spline interpolator: https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/src-html/org/apache/[…]erpolation/PiecewiseBicubicSplineInterpolatingFunction.html And spline interpolator is already implemented in the multiplatform: https://github.com/SciProgCentre/kmath/blob/dev/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt
I can add it in a week or so and create a dev release. But Issue with a problem description would be also nice.
p

PHondogo

02/14/2023, 8:56 AM
Where should I file an issue?
a

altavir

02/14/2023, 8:57 AM
https://github.com/SciProgCentre/kmath/issues. We plan to move to our YouTrack for that. But I do not have any specific timeline.
Thanks!
10 Views