Skip to content

refactor: RadialBasis - #605

Merged
ChrisRackauckas merged 5 commits into
SciML:masterfrom
sathvikbhagavan:sb/pr08-radial-basis
Aug 31, 2026
Merged

ChrisRackauckas merged 5 commits into
SciML:masterfrom
sathvikbhagavan:sb/pr08-radial-basis

Conversation

@sathvikbhagavan

Copy link
Copy Markdown
Member

This PR does:

Bug fixes

  • thinplateRadial tested iszero on the sample difference, a MethodError for tuples — the kernel was unusable in more than one dimension. Now tested on norm(z).
  • multiquadricRadial's c = 1.0 default is a Float64 literal, which promoted a Float32 design to Float64. c is now taken to the radius' type.
  • Single- vs multi-output was chosen by typeof(y) == Vector{Float64}, a type equality test, so Float32, BigFloat and integer responses took the wrong branch.
    Replaced by the shared _construct_y_matrix.
  • update! grew rad.x/rad.y with push!/append!, mutating the caller's own vectors. Replaced by the shared _append_samples.
  • The kernel matrix was built at eltype(x), throwing InexactError on integer designs for most scale_factor values; scale_factor and regularization kept their
    Float64 defaults, promoting a Float32 solve. Both are now converted to float(eltype(first(x))).
  • Queries whose element type differed from the samples threw InexactError; the accumulator took its type from the query rather than from coefficient × kernel
    value.
  • The 1D evaluation path had no coefficient-count guard; only ND did. Both now share one.
  • throw("string") replaced by an ArgumentError.

Performance

Removed _approx_rbf(val::Number, …), which sliced coeff[:, i] into a heap-allocated vector per sample; the general path already handled Numbers. Hoisted the per-evaluation linearRadial() construction to a constant, dropped a dead collect(val), replaced the f = rad.phi keyword with applying phi at the call site, and stopped copying the kernel matrix when regularization is zero.

@ChrisRackauckas
ChrisRackauckas merged commit 22e5cdc into SciML:master Aug 31, 2026
10 checks passed
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.

2 participants