Dirac-to-Dirac reduction with user-defined weight function.
Overview
dirac_to_dirac_approx_short_function<T> reduces a Dirac mixture with M components to L components in N dimensions, similar to:
The key difference:
Instead of providing static weights wX, this implementation computes the reduced mixture weights via user-defined callbacks.
This allows:
- State-dependent weighting
- Structure-adaptive reduction
- Custom weighting strategies
Interface
Inherits:
- dirac_to_dirac_approx_function_i<T>
Template parameter:
The user must provide:
- wXf → weight callback
- wXd → weight gradient callback
Callback Types
The following function types are required:
using wXf =
void (*)(
const T* x,
size_t L,
size_t N);
using wXd =
void (*)(
const T* x,
size_t L,
size_t N);
Definition dirac_to_dirac_approx_short.h:9
- wXf computes the weights for the reduced components
- wXd computes the derivative of the weights w.r.t. x
Both callbacks operate on flattened L × N data.
Supported Input Formats
Three overload families are available:
- Raw pointer interface (T*)
- GSL vector interface (gsl_vector)
- GSL matrix interface (gsl_matrix)
Memory layout and parameter semantics match the non-function-based implementation.
Example Callbacks
static void wXcallback(const double* x,
size_t L,
size_t N)
{
for (
size_t i = 0;
i < L; ++
i) {
for (
size_t k = 0;
k < N; ++
k) {
}
}
}
static void wXDcallback(const double* x,
size_t L,
size_t N)
{
for (
size_t i = 0;
i < L; ++
i) {
for (
size_t k = 0;
k < N; ++
k) {
}
for (
size_t k = 0;
k < N; ++
k) {
}
}
}
Example (Raw Pointer)
y,
M,
L,
N,
bMax,
x,
wXcallback,
wXDcallback,
);
bool approximate(const T *y, size_t M, size_t L, size_t N, size_t bMax, T *x, const T *wX=nullptr, const T *wY=nullptr, GslminimizerResult *result=nullptr, const ApproximateOptions &options=ApproximateOptions{}) override
reduce the data points using raw pointers
Definition dirac_to_dirac_approx_short.cpp:24
Example (GSL Vector)
L,
N,
bMax,
wXcallback,
wXDcallback,
);
Example (GSL Matrix)
L,
bMax,
wXcallback,
wXDcallback,
);
Notes
- Weights are fully controlled by user callbacks
- Analytical gradient includes weight derivatives
- Multi-threaded implementation
- Interface-compatible with other Dirac-to-Dirac variants