Deterministic Gaussian Sampling
Loading...
Searching...
No Matches
gm_to_dirac_even_binf.h
1#ifndef GM_TO_DIRAC_EVEN_BINF_H
2#define GM_TO_DIRAC_EVEN_BINF_H
3
4#include "approximate_options.h"
5#include "gm_to_dirac_even_binf_optimization_params.h"
6#include "gsl_minimizer.h"
7#include "gsl_vector_matrix_types.h"
8
44template <typename T>
46 public:
47 using GSLVectorType = typename GSLTemplateTypeAlias<T>::VectorType;
48 using GSLMatrixType = typename GSLTemplateTypeAlias<T>::MatrixType;
49
50 // clang-format off
66 bool approximate(size_t L,
67 size_t N,
68 T* x,
69 const T* wX = nullptr,
70 GslminimizerResult* result = nullptr,
72
85 size_t L,
86 size_t N,
87 T* x,
88 const T* wX = nullptr);
89
114 size_t L,
115 size_t N,
116 T* x,
117 const T* wX = nullptr);
118
130 bool approximate(size_t L,
131 size_t N,
132 GSLVectorType* x,
133 const GSLVectorType* wX = nullptr,
134 GslminimizerResult* result = nullptr,
136
147 size_t L,
148 size_t N,
149 GSLVectorType* x,
150 const GSLVectorType* wX = nullptr);
151
165 size_t L,
166 size_t N,
167 GSLVectorType* x,
168 const GSLVectorType* wX = nullptr);
169
181 bool approximate(size_t L,
182 size_t N,
183 GSLMatrixType* x,
184 const GSLVectorType* wX = nullptr,
185 GslminimizerResult* result = nullptr,
187
198 size_t L,
199 size_t N,
200 GSLMatrixType* x,
201 const GSLVectorType* wX = nullptr);
202
216 size_t L,
217 size_t N,
218 GSLMatrixType* x,
219 const GSLVectorType* wX = nullptr);
220 // clang-format on
221
222 private:
225 static void evaluate(const gsl_vector* t,
226 GMToDiracEvenBinfOptimizationParams* params, double* f,
228
229 // gsl_minimizer entry points; these always work in t
230 static double modified_van_mises_distance_sq(const gsl_vector* t,
231 void* params);
233 void* params,
235 static void combined_distance_metric(const gsl_vector* t, void* params,
236 double* f, gsl_vector* grad);
237
238 static inline void calculateAttraction(
240
241 static inline void calculateRepulsion(
243
244 static inline void projectGradient(
246
247 static inline void correctMean(gsl_vector* x, const gsl_vector* wX, size_t L,
248 size_t N);
249
250 static inline bool preconditionsHold(size_t L, size_t N);
251};
252
253#include "gm_to_dirac_even_binf.tpp"
254
255template <>
257 size_t L, size_t N, gsl_vector_float* x, const gsl_vector_float* wX,
259
260template <>
262 size_t L, size_t N, gsl_vector* x, const gsl_vector* wX,
264
265template <>
267 float* distance, size_t L, size_t N, gsl_vector_float* x,
268 const gsl_vector_float* wX);
269
270template <>
272 double* distance, size_t L, size_t N, gsl_vector* x, const gsl_vector* wX);
273
274template <>
276 gsl_vector_float* gradient, size_t L, size_t N, gsl_vector_float* x,
277 const gsl_vector_float* wX);
278
279template <>
281 gsl_vector* gradient, size_t L, size_t N, gsl_vector* x,
282 const gsl_vector* wX);
283
284extern template class gm_to_dirac_even_binf<double>;
285extern template class gm_to_dirac_even_binf<float>;
286
287#endif // GM_TO_DIRAC_EVEN_BINF_H
Definition dirac_to_dirac_approx_short.h:9
bMax-free Gaussian-to-Dirac approximation for an even-dimensional standard normal target
Definition gm_to_dirac_even_binf.h:45
bool approximate(size_t L, size_t N, T *x, const T *wX=nullptr, GslminimizerResult *result=nullptr, const ApproximateOptions &options=ApproximateOptions{})
approximate a standard normal by L Dirac components
Definition gm_to_dirac_even_binf.cpp:86
void modified_van_mises_distance_sq_derivative(T *gradient, size_t L, size_t N, T *x, const T *wX=nullptr)
gradient of the true bMax-free mCvM distance w.r.t. the SAMPLES
Definition gm_to_dirac_even_binf.cpp:110
void modified_van_mises_distance_sq(T *distance, size_t L, size_t N, GSLMatrixType *x, const GSLVectorType *wX=nullptr)
true bMax-free mCvM distance, K_k included
void modified_van_mises_distance_sq_derivative(GSLMatrixType *gradient, size_t L, size_t N, GSLMatrixType *x, const GSLVectorType *wX=nullptr)
gradient of the true bMax-free mCvM distance w.r.t. the SAMPLES
bool approximate(size_t L, size_t N, GSLMatrixType *x, const GSLVectorType *wX=nullptr, GslminimizerResult *result=nullptr, const ApproximateOptions &options=ApproximateOptions{})
approximate a standard normal by L Dirac components
void modified_van_mises_distance_sq(T *distance, size_t L, size_t N, T *x, const T *wX=nullptr)
true bMax-free mCvM distance, K_k included
Definition gm_to_dirac_even_binf.cpp:99
Definition approximate_options.h:6
optimization parameters for the bMax-free closed-form even-N Gaussian-to-Dirac approximation
Definition gm_to_dirac_even_binf_optimization_params.h:30
struct to hold the result of the minimization
Definition gsl_minimizer.h:32