Skip to content

Precision and backends

Extended precision can be selected for local weight construction, global dense solves, or the supported sparse LHI path. The optional backends have method-specific limits; see their docstrings and capabilities.

rbflab.Precision dataclass

Select local-weight and global-solve arithmetic independently.

Parameters:

Name Type Description Default
local_digits int | None

Decimal digits for local weights; None uses Float64. Extended weights may be rounded for a Float64 global system.

None
global_dtype str

"float64" or "mpmath" for supported sparse systems. Full mpmath sparse assembly also requires local_digits.

'float64'
global_digits int | None

Decimal digits for supported dense global solves.

None

A Float64 global solve remains Float64 when only local_digits is set. Check the method's supported precision combination.

rbflab.PrecisionData dataclass

Dual data callback: vectorized Float64 and scalar extended(ctx, *coordinates).

LocalApproximation uses kernel_scaling="physical" by default. Set kernel_scaling="local" to normalize kernel coordinates; None aliases "physical". StencilPolicy remains a compatibility option, but explicitly conflicting values supplied through kernel_scaling and stencil_policy.scaling are rejected. Shape-sensitive kernels change meaning under coordinate normalization. For the radius convention and its effect on shape parameters, see local stencil scaling.

rbflab.StencilPolicy dataclass

Choose neighborhood selection and kernel distance scaling.

Parameters:

Name Type Description Default
scaling str

"physical" (default) evaluates the kernel at physical displacements. "local" evaluates K((x-y)/h), where h is the local radius. Single-field LocalApproximation measures the maximum distance over selected source and trial centers from the first selected source center. Mixed LocalApproximation and Stokes LHI use matching source/trial sites and measure it from the target. Zero radius uses one. Physical derivative factors h**(-order) are included automatically; do not rescale returned weights. Shape parameters then refer to dimensionless distances, so switching policy with the same numeric parameter can change the approximation.

'physical'
shape_rule str

"fixed" uses the supplied kernel parameter. Stokes LHI also supports "hardy", "radius_scaled" and "separation_scaled"; other combinations fail preflight.

'fixed'
selection str

"nearest" keeps the requested stencil size. "quality" grows a nearest-neighbor set until polynomial-rank and node-separation thresholds are met, or raises an error. Mixed LocalApproximation checks the combined functional polynomial matrix and grows eligible sized groups together; explicit indices and groups using all samples remain fixed.

'nearest'
max_size int | None

Largest stencil considered by quality selection. If None, use min(number of source points, 2 * stencil_size). For mixed samples this limit is per sized group, using eligible points after target exclusion and twice that group's size.

None
min_polynomial_ratio float

Minimum singular-value ratio of the normalized, column-scaled polynomial matrix in quality selection. Mixed selection uses the joint functional matrix with row and column scaling, and the strictest participating group threshold.

1e-05
min_separation_ratio float

Minimum node separation divided by the radius measured from the target, used only in quality selection.

1e-06

Local scaling alone does not enable quality selection, move nodes, or change precision. Polynomials are normalized under both scaling policies. These options do not certify conditioning, accuracy, or PDE stability.

rbflab.PythonBackend dataclass

Bases: BackendSettings

Python local-weight backend for supported scalar and vector stencils.

Used by divergence-free LHI Stokes and reusable RBF-FD operators. Supported pathways depend on the calling method; this backend alone does not imply support for every coupled PDE.

Parameters:

Name Type Description Default
workers int

Number of local-assembly worker processes.

1
compute_condition bool

Whether to estimate each local condition number.

False

Numerical policies are specified on the method and StencilPolicy.

rbflab.CppBackend dataclass

Bases: BackendSettings

Compiled local-weight backend for supported scalar and vector stencils.

Used by supported LHI Stokes and reusable RBF-FD operator paths. Native compilation is optional and not included by default pip install.

Float64 uses the native C++ executable; extended local digits select its MPFR executable. Compilation is a separate optional installation step.

Parameters:

Name Type Description Default
threads int

OpenMP thread count for local systems.

1
compute_condition bool

Whether to estimate local condition numbers.

False

Use LocalSolver on the method to select local factorization.

rbflab.LocalExecution dataclass

Schedule mixed local jobs, independently of their numerical backend.

scheduler: serial or real mpi execution. MPI requires CppBackend. ranks: Number of MPI ranks (idle ranks are allowed for small requests). launcher: Optional MPI command prefix, e.g. ("mpiexec", "--oversubscribe"). wsl_distribution: On Windows, explicitly select a WSL MPI launcher. If no native MPI exists, the default Windows fallback uses Ubuntu. reuse: none, exact identical-request reuse, or factor shared native factorization for identical ordered source/trial matrices. factor uses source-centered polynomial coordinates and retains each job's kernel scaling. Reuse requires exact geometry and functionals.

rbflab.CppGlobalBackend dataclass

Compile and reuse a C++ scalar or divergence-free Stokes global worker.

Native assembly, factorization, solves, and evaluation stay in the selected arithmetic. Accessing system.matrix explicitly exports entries lazily. Windows uses native MinGW-w64 GCC and directly launches Windows executables.

Parameters:

Name Type Description Default
threads int

Thread limit for native assembly, evaluation, matrix products, and Eigen's parallel global dense factorization when applicable.

1
compute_condition bool

Estimate the balanced matrix one-norm condition.

False
cache_dir object

Directory for compiled native artifacts.

None
distribution str

Compatibility field; retain the default Ubuntu. CPU execution is native.

'Ubuntu'
timeout float

Maximum seconds for each worker command.

120.0
derivative_order int

Maximum evaluation derivative order to prepare, in addition to source functional derivatives. Total order is at most 6.

2
reuse_workers bool

Keep up to four idle workers for subsequent assemblies.

True
linear_solver str

Dense factor engine, 'eigen' (default) or the optional MPFR-only 'mplapack'. Assembly and evaluation are unchanged.

'eigen'
mplapack_dir object

Explicit installed MPLAPACK MPFR/OpenMP dependency prefix.

None

CppGlobalBackend selects native dense assembly, factorization and evaluation for scalar stationary/unsteady GlobalCollocation, global interpolate, and steady/unsteady symmetric SymbolicStokes with DivergenceFreeSpace velocity and scalar pressure spaces in 2D/3D. Use Precision() for double or Precision(global_digits=80) for MPFR. This setting is independent of the local-weight backend used by RBF-FD and LHI. See the global collocation tutorial. The Stokes tutorial shows the field API: velocity, pressure, pressure_gradient, divergence, and residuals accept extended=True to retain multiprecision output. Unsteady Stokes supports backward Euler and BDF2 with native stiffness/mass assembly, shifted LU caching and mass products. Prescribed forcing and boundary data use generated C++ evaluators when all components are supported symbolic expressions or numeric constants. The problem declarations and time-stepping API are unchanged. Initial velocity evaluation remains in Python.

Scalar EvolutionPDE problems use the same assemble(...).solve(dt=..., steps=...) contract with backward Euler or BDF2. C++ assembles indexed mass rows, projects initial data to coefficients using a separately cached initial factor, combines coefficient histories, evaluates supported symbolic data and solves each shifted system. Python schedules steps and constructs the existing trajectory objects. Initial derivative-boundary compatibility and arbitrary data callbacks retain Python evaluation. The spatial and boundary operators must be linear and fixed in time. .matrix/.spatial export stiffness A; .mass exports M; neither silently becomes the last shifted system. .initial_matrix exposes the initial projection separately.

interpolate(kernel_or_space, points, data, backend=CppGlobalBackend(...)) shares the dense engine and factor options. Scalar samples return scalar predictions. An (N, C) array with an ordinary kernel or ScalarSpace fits independent components, sharing one native LU. DivergenceFreeSpace instead builds a coupled solenoidal interpolant in 2D/3D with (N, dimension) predictions. This choice enforces analytic divergence freedom; it is not automatic for vector data. Native interpolation supports derivatives and evaluate_mp, and owns its worker: use a context manager or call .close(). Supplied Float64 measurements retain their original accuracy even when the solve uses MPFR.

Native symbolic data supports arithmetic, integer/rational powers, sin, cos, exp, log, absolute values, and exact rational/float constants including native MPFR evaluation of pi and e. Expressions participate in executable cache identities; runtime row mappings preserve component ordering and boundary tags. Arbitrary callbacks, normal-dependent data, unsupported expressions, and conflicting overlapping boundary groups retain Python evaluation for the whole data vector. Stationary time-bound symbolic data also retain Python semantics. Compilation and native evaluation failures are reported rather than hidden by fallback. Diagnostics expose data_backend and data_fallback_reason.

For an optional MPLAPACK MPFR/OpenMP factor engine, build an explicit dependency prefix using scripts/build_mplapack_windows.py on Windows or scripts/build_mplapack.sh on Linux as described in native setup, then select:

backend = CppGlobalBackend(
    linear_solver="mplapack", mplapack_dir="path/to/mplapack-prefix", threads=4,
)
# Pass backend together with Precision(global_digits=60) to GlobalCollocation.

MPLAPACK requires extended precision; Float64 requests fail during preflight. Eigen remains the default. Both engines retain the same assembly, balancing, residual, field evaluation, condition estimation and shifted-factor caching. MPLAPACK transfers scalars directly through MPFR without conversion to double. Preparation never downloads or installs dependencies and never silently falls back to another engine. Solution and trajectory diagnostics report linear_solver. The explicit dependency prefix must remain available while workers run because it supplies the MPFR/GMP/MPC runtime libraries.

threads also controls eligible Eigen global dense operations. Local stencil solvers retain their separate outer-parallel scheduling. MPFR worker threads share the precision selected for that worker's current assembly. Global MPFR matrix updates reuse scratch storage for multiplication and addition, avoiding temporary allocations while retaining separate rounding operations. An unchanged time-step shift reuses its active matrix and factorization. Repeated field queries cache their evaluation operators in a per-system LRU cache bounded to 512 MiB of estimated storage; larger queries use uncached evaluation. Interior velocity queries reuse the existing mass matrix. Closing or reinitializing a system releases its cached operators. Threaded factorization can change arithmetic ordering, so expect precision-level agreement rather than bitwise-identical coefficients across thread counts.

Compiled global workers persist in ~/.cache/rbflab, shared across examples and Python sessions. Set CppGlobalBackend(cache_dir="path/to/shared/cache") to choose another directory. SHA-256 artifact identifiers cover generated source, native headers, compiler version, Eigen, build flags, and arithmetic mode, selected factor engine and optional dependency content. Completed builds are published from unique temporary directories; different builds have different identifiers. Integrity manifests are checked before reuse. Bound kernel parameters and MPFR digit counts are runtime inputs, so they can reuse a compatible compiled kernel family. method.prepare(problem) warms this cache before a benchmark; it does not cache a particular mesh or LU.

rbflab.TorchBackend dataclass

Bases: BackendSettings

CPU Float64, 2D unaugmented physical-coordinate Stokes local systems.

rbflab.LocalSolver dataclass

Local factorization. SVD is currently supported by C++ Float64 Stokes LHI.

rcond is a relative singular-value cutoff; it changes the numerical method.

On Windows, current CPU C++ backends compile and run native MinGW-w64 executables with Float64 or MPFR; see native Windows setup. The normal Python backend API is unchanged. WSL is retained only by the archived legacy bridge and experimental CUDA adapter. Optional MPLAPACK uses an explicitly built native static prefix on Windows; see the MPLAPACK setup instructions.

Inspecting execution

execution_info(obj) returns a JSON-compatible description of covered global methods, systems, scalar/componentwise/vector fits, global evolution states and trajectories, and LocalApproximation. evidence="configured" describes a requested route; evidence="implementation" describes the object's code path. recorded includes selected diagnostics already attached to the object. No timings, worker checks, matrix exports, callbacks, or solves are triggered.

The report includes backend, arithmetic, decimal digits (null for Float64), linear_solver, Float64 geometry, and locations for assembly, solve, evaluation, data and time stepping. Null means unknown or inapplicable; supported=false means the helper does not cover that type, rather than that the numerical feature is unsupported. A native data route is reported only when recorded. In evolution reports this is the recorded forcing/boundary route for the final saved step; initial data may have a different, unknown route. Arbitrary callbacks and symbolic fallback routes run in Python. Native scalar evolution uses Python orchestration and C++ step algebra; native Stokes retains Python history orchestration with C++ mass and shifted solves. components preserves independent fit reports, including mixed metadata if present. Native componentwise interpolation shares one LU.

Local reports cover weight/map construction only and leave the later solve unknown. Extended arithmetic does not increase precision of existing inputs: Python floats retain their binary values, and geometry/query storage is Float64. Use exact constants and precision-aware data where supported.

rbflab.execution_info(obj)

Describe a supported object's configured or implemented execution route.

Parameters:

Name Type Description Default
obj object

Global method, system, fit, evolution state/trajectory, or local approximation to inspect without evaluation or worker requests.

required

Returns:

Type Description
dict

JSON-compatible execution metadata.

None means unknown or not applicable; supported=False means this reporting helper does not cover the type. Implementation describes code paths, not runtime profiling. recorded contains selected existing diagnostics only.

Optional condition estimates

Condition estimation is disabled by default for Python, C++, native global, and Torch backends. Ordinary examples need only PythonBackend() or CppBackend(). Pass compute_condition=True when you want the additional condition diagnostic. Skipped estimates are reported as None; this option does not change the equations, precision, weights, or solver regularization.