Changelog
KernelInterpolation.jl follows the interpretation of semantic versioning (semver) used in the Julia ecosystem. Notable changes will be documented in this file for human readability.
Changes when updating to v0.4 from v0.3.x
Changed
MultiquadricKernelandPolyharmonicSplineKernelnow include the sign(-1)^m, wheremis the order of the kernel, such that they are conditionally positive definite of orderm(see Wendland (2004), Corollary 8.18, and Fasshauer (2007), Chapter 8). This changes the sign ofphiand of the kernel coefficients of theMultiquadricKernelwith oddceil(beta)(e.g., the defaultbeta = 0.5) and of thePolyharmonicSplineKernelwithk = 1, 4, 5, 8, 9, .... Interpolants and least squares approximations are the same as before. However,kernel_normnow returns the native space semi-norm for these kernels instead of0, and interpolants with anL2Regularizationchange, since the regularization only acts as intended with the sign (#220).MultiquadricKernelthrows anArgumentErrorforbeta <= 0(useInverseMultiquadricKernelwith-betafor negativebeta) and for integerbeta(the kernel is then a polynomial and not conditionally positive definite).PolyharmonicSplineKernelthrows anArgumentErrorifkis not a positive integer (#220).kernel_normandkernel_inner_productproject the kernel coefficients onto the vectors satisfying the moment conditions of the polynomials (which hold for interpolations up to round-off errors and for least squares approximations only approximately).kernel_normthrows aDomainErrorif the squared native space norm is then negative beyond the level of round-off errors, instead of silently returning0(#220).RieszKernelnow uses itsshape_parameter, i.e.,phi(r) = -(shape_parameter * r)^betaas documented, instead of ignoring it. Interpolants do not change, since the kernel is only scaled (#221).The order of a
SumKernelis the maximum instead of the minimum of the orders of its components, since a sum of conditionally positive definite kernels is in general only conditionally positive definite of the largest order. Hence, interpolations with such a kernel are augmented by polynomials of higher order (#221).ProductKernelthrows anArgumentErrorif one of its components is not positive definite (i.e., has an order larger than 0), since the product of conditionally positive definite kernels is in general not conditionally positive definite (#221).RadialCharacteristicKernelthrows anArgumentErrorforbeta < (Dim + 1) / 2, where it is not guaranteed to be positive definite. Before, itsorderreturnedInfin this case, andinterpolatefailed with anInexactError(#221).SumKernelandProductKernelstore their component kernels in aTupleinstead of aVector{AbstractKernel}and have the type of this tuple as an additional type parameter, e.g.,SumKernel{2, Tuple{GaussKernel{2, Float64}, ThinPlateSplineKernel{2}}}. They can still be constructed from a vector. Nested sums (products) are flattened into a single sum (product). Evaluating them is now type-stable and does not allocate, which makes, e.g., assembling kernel matrices several times faster (#222).Invalid arguments throw an
ArgumentError,DimensionMismatch, orBoundsErrorinstead of anAssertionError, e.g., invalid kernel parameters, points of different lengths, or adimkeyword argument that does not match the other arguments. The checks of the kernel parameters are in the inner constructors, such that they also apply if the constructor with all type parameters is called directly, e.g.,MultiquadricKernel{2, Float64}(1.0, 1.0)(#223).All kernels with a shape parameter throw an
ArgumentErrorif it is not positive. For a shape parameter0, the kernel is constant, and for a negative one, e.g., theWendlandKernel,WuKernel,RadialCharacteristicKernel, Matern kernels, andRieszKernelare not positive definite or not defined.InverseMultiquadricKernelthrows anArgumentErrorforbeta <= 0andMaternKernelfornu <= 0(#224).
Fixed
RadialCharacteristicKernelwas treated as not positive definite forbeta = (Dim + 1) / 2, e.g., for the defaultbeta = 2in three dimensions, although it is positive definite there (#221).kernel_normandkernel_inner_productreturned wrong values for interpolations in theLagrangeBasis, since they used the coefficients with respect to the cardinal functions as kernel coefficients. They now compute the native space (semi-)norm and inner product, which agree with the ones of the same interpolation in the standard basis. For interpolations in anRBFFDBasis, which have no global native space representation, they throw anArgumentErrorinstead of returning a meaningless value (#220).
Removed
- The deprecated function
values_along_dimis removed. Usenodeset[:, i]instead (#220).
Changes in the v0.3 lifecycle
Added
- The whole interpolation process is now differentiable with forward-mode automatic differentiation, e.g. with ForwardDiff.jl, i.e. not only the evaluation of an
Interpolation, but also the assembly of the system matrix and the linear solve. The interpolated values, the nodes, and the parameters of the kernel may have different element types, which allows differentiatinginterpolateandsolve_stationarywith respect to any of them (#200). - Added
smoothness(kernel), returning the largestksuch that the multivariate functionPhi(x) = phi(||x||)isktimes continuously differentiable. It is used to decide whether a differential operator of ordermmay be evaluated at the center of a kernel, which requiressmoothness(kernel) >= m. The fallback for user-defined kernels is the conservative value0. - Added
fill_distancefunction (#187). - Added support for RBF-FD (#182).
- Added
differentiation_matrixto assemble the matrix of a differential operator (sparse forRBFFDBasis, dense for kernel collocation), and added polynomial augmentation to the collocation PDE assembly (solve_stationary,operator_matrix,pde_boundary_matrix) so that conditionally positive definite kernels are augmented automatically (#182). - Add multiscale interpolation functionality with the function
multiscale_interpolateand the typeMultiscaleInterpolation(#180). - Allow applying differential operators to an
Interpolationto get a callable object that evaluates the operator at any point (#179). - Added support for methods from
LinearSolve.jlinsolve_stationary(#178). - Added support for methods from
LinearSolve.jlininterpolate(#176). - Added a keyword argument
factorization_methodtointerpolate,interpolation_matrix, andleast_squares_matrixto allow for different factorization methods (#130).
Fixed
homogeneous_hypercubeandhomogeneous_hypercube_boundarydid not terminate if the bounds were of different types, e.g.,homogeneous_hypercube(3, 0, 1.0; dim = 2). The functions creatingNodeSets (random_hypercube,random_hypercube_boundary,homogeneous_hypercube,homogeneous_hypercube_boundary,random_hypersphere,random_hypersphere_boundary) as well asAdvectionEquationandAdvectionDiffusionEquationnow accept arguments of different types, e.g., integer and floating point bounds, radii, centers, or advection velocities, and convert them to a common type (#218).multiscale_interpolatefailed if the kernels of the different scales are of different types. Constructing aMultiquadricKernel,InverseMultiquadricKernel,RadialCharacteristicKernel,MaternKernel, orRieszKernelwith an integershape_parameterfailed with anInexactError; it is now converted to a floating point number (#212).random_hypersphere_boundaryignored thecenterin one dimension.homogeneous_hypercubeproducedNaNcoordinates if only one node is used in a dimension; this node is now placed at the midpoint between the bounds. The heatmap of a two-dimensional kernel was transposed, which is visible for kernels that are not symmetric with respect to swapping the coordinates (#213).- Setting a node of a
NodeSetby anMVectordid not invalidate the cached separation distance, soseparation_distancecould return an outdated value. Setting a node of a one-dimensionalNodeSetby aVectoror anMVectorfailed with a method ambiguity (#211). - Second derivatives at the kernel center of the general
MaternKernel(withnu > 1) and ofPolyharmonicSplineKernelwith evenk >= 4returnedNaN, e.g., forLaplacianandEllipticOperator. Hence, collocation matrices of second-order PDEs with these kernels hadNaNon the diagonal. In addition,phi(MaternKernel{d}(1.0), 0.0)returnedNaNinstead of1.0(#210). - Derivatives of radial-symmetric kernels are now evaluated through the chain rule on the scalar radial profile
phiinstead of by differentiatingx -> Phi(kernel, x)directly. Previously, thesave_callworkaround perturbed the argument byepsat the kernel center to keep automatic differentiation from producingNaNat the singularity ofnorm. That had three consequences, all of which are fixed:- Second-order operators were badly wrong at the center. The radial formula
Delta Phi = phi'' + (d - 1) phi' / rsuffers catastrophic cancellation atr = eps, so every diagonal entry of aLaplacianorEllipticOperatorcollocation matrix carried anO(10%)error. For example,LaplacianofWendlandKernel{2}(3, shape_parameter = 0.4)at the center returned-5.52instead of the correct-7.04. Solutions of PDE examples change accordingly, and are generally more accurate. - For kernels that are not differentiable at the origin (
smoothness == 0, e.g.WendlandKernelwithk = 0,Matern12Kernel,RieszKernelwithbeta <= 1), a non-existent derivative was silently returned as a value pointing along the first coordinate direction. Such calls now throw anArgumentError. save_callmutated its argument, so derivatives at the center errored for immutable input vectors such asSVector. These now work (#204).
- Second-order operators were badly wrong at the center. The radial formula
Changed
- The right-hand side
rhs!of aSemidiscretizationno longer allocates. TheThinPlateSplineKernel, theSumKernel, andkernel_inner_productkeep the floating point type of their input, e.g.,Float32.vtk_readno longer silently ignores errors when reading the point data (#218). fill_distanceuses aKDTreeinstead of the full distance matrix, which makes it much faster and avoids the memory of sizelength(nodeset) * length(reference). Evaluating an RBF-FD interpolation, or applying a differential operator to it, finds the nearest center with theKDTreestored in theRBFFDBasisinstead of a linear search over all centers. In addition, the assembly of sparse RBF-FD matrices (e.g.,kernel_matrix,pde_matrix, anddifferentiation_matrixwith anRBFFDBasis) is type-stable now, which makes it about twice as fast (#217).- Applying differential operators and equations to a radial-symmetric kernel at static vectors no longer allocates, which speeds up the assembly of collocation matrices. Evaluating an interpolation with polynomial augmentation, or applying a differential operator to it, at a plain
Vectorallocates less and is faster (#216). - Evaluating a radial-symmetric kernel at static vectors, e.g., at the nodes of a
NodeSet, no longer allocates, which speeds up the evaluation of interpolants and the assembly of kernel matrices (#215). - Several performance improvements reducing allocations, using threaded loops, using
KDTreefor nearest-neighbor searches, and computing the separation distance lazily (#191). - Speed up
LagrangeBasisconstruction (and hence also the RBF-FDRBFFDLagrangeBasiscache) by assembling and factorizing the augmented interpolation matrix once per node set and solving for all cardinal functions with a single multiple-right-hand-side solve, instead of re-assembling and re-factorizing it for each cardinal function (#190). - Speed up RBF-FD stencil selection (
KNearestNeighbors,RadiusSearch) by using aKDTreefrom NearestNeighbors.jl instead of a brute-forceO(N^2)distance scan, reducing the overall neighborhood search to roughlyO(N log N)(#189). - Define slicing for
NodeSets and deprecatevalues_along_dim(#139). - Fix order of
PolyharmonicSplineKernelto return an integer (#127).
Changes when updating to v0.3 from v0.2.x
Added
- General floating point support (#121).
Changed
- The functions
random_hypersphereandrandom_hypersphere_boundarynow require aTuplefor the argumentcenter. Before, e.g., aVectorwas allowed (#121). - The element type of
NodeSets will now always be converted to a floating point type, i.e., also when integer values are passed. This is more consistent for an interpolation framework makes many things easier. A similar approach is also used in the Meshes.jl/CoordRefSystems.jl ecosystem (#121).
Changes in the v0.2 lifecycle
Added
Changed
- Use OrdinaryDiffEqRosenbrock.jl instead of OrdinaryDiffEq.jl in the examples and documentation (#108).
- Fix seriestype for 1D plots (#101).
Changes when updating to v0.2 from v0.1.x
Added
- Added tutorial on noisy data (#95).
- Added L2 regularization (#94).
- Added least squares approximation (#93, #97).
Changed
- Add interface for general bases and add
StandardBasis. This is breaking for least squares approximations because the order ofcentersandnodesetneeds to be swapped in theinterpolatefunction. Alternatively, use the newStandardBasis(#100).