Deterministic Gaussian Sampling
Loading...
Searching...
No Matches
dirac_to_dirac_approx_short_function

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:

  • T ∈ {float, double}

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,
double* res,
size_t L,
size_t N)
{
for (size_t i = 0; i < L; ++i) {
double sum = 0.0;
for (size_t k = 0; k < N; ++k) {
double v = x[i * N + k];
sum += v * v;
}
res[i] = std::exp(0.5 * sum);
}
}
static void wXDcallback(const double* x,
double* grad,
size_t L,
size_t N)
{
for (size_t i = 0; i < L; ++i) {
double sum = 0.0;
for (size_t k = 0; k < N; ++k) {
double v = x[i * N + k];
sum += v * v;
}
double factor = std::exp(0.5 * sum);
for (size_t k = 0; k < N; ++k) {
grad[i * N + k] = x[i * N + k] * factor;
}
}
}

Example (Raw Pointer)

y, // input points (M × N)
M,
L,
N,
bMax,
x, // initial guess / output
wXcallback, // weight function
wXDcallback, // weight derivative
);
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)

Example (GSL Matrix)

Notes

  • Weights are fully controlled by user callbacks
  • Analytical gradient includes weight derivatives
  • Multi-threaded implementation
  • Interface-compatible with other Dirac-to-Dirac variants