Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ file(GLOB GM_TO_DIRAC_C_WRAPPER_SOURCES ${GM_TO_DIRAC_C_WRAPPER_DIR}/*.cpp)
set(COMMON_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/debug/capture_time.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gsl_minimizer/gsl_minimizer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/options/wrappers/approximate_options_c.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/gsl_multivariative_gradient
)
# common includes
Expand All @@ -53,6 +54,7 @@ set(COMMON_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/math_utils
${CMAKE_CURRENT_SOURCE_DIR}/cache_manager
${CMAKE_CURRENT_SOURCE_DIR}/options
${CMAKE_CURRENT_SOURCE_DIR}/options/wrappers
)

# static library target
Expand Down
108 changes: 107 additions & 1 deletion lib/dirac_to_dirac/dirac_to_dirac_approx_function_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @brief interface for the gausian mixture to dirac approximation with a custom
* weight function
*
* @tparam T type of the vector (float, double, long double)
* @tparam T type of the vector (float, double)
*/
template <typename T>
class dirac_to_dirac_approx_function_i {
Expand Down Expand Up @@ -48,6 +48,43 @@ class dirac_to_dirac_approx_function_i {
GslminimizerResult* result,
const ApproximateOptions& options) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param distance pointer to distance value to be calculated
* @param y input data points
* @param M number of elements in y
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wXcallback callback for the weight function
* @param wXDcallback callback for the gradient of the weight function
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq(T* distance, const T* y, size_t M,
size_t L, size_t N, size_t bMax,
T* x, wXf wXcallback,
wXd wXDcallback) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param gradient pointer to gradient to be calculated
* @param y input data points
* @param M number of elements in y
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wXcallback callback for the weight function
* @param wXDcallback callback for the gradient of the weight function
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq_derivative(
T* gradient, const T* y, size_t M, size_t L, size_t N, size_t bMax, T* x,
wXf wXcallback, wXd wXDcallback) = 0;

/**
* @brief reduce the data points using gsl vectors
*
Expand All @@ -67,6 +104,42 @@ class dirac_to_dirac_approx_function_i {
wXd wXDcallback, GslminimizerResult* result,
const ApproximateOptions& options) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param distance pointer to distance value to be calculated
* @param y input data points
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wXcallback callback for the weight function
* @param wXDcallback callback for the gradient of the weight function
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq(T* distance,
const GSLVectorType* y, size_t L,
size_t N, size_t bMax,
GSLVectorType* x, wXf wXcallback,
wXd wXDcallback) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param gradient pointer to gradient to be calculated
* @param y input data points
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wXcallback callback for the weight function
* @param wXDcallback callback for the gradient of the weight function
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq_derivative(
GSLMatrixType* gradient, const GSLVectorType* y, size_t L, size_t N,
size_t bMax, GSLVectorType* x, wXf wXcallback, wXd wXDcallback) = 0;

/**
* @brief reduce the data points using gsl matricies where possible
*
Expand All @@ -84,6 +157,39 @@ class dirac_to_dirac_approx_function_i {
GSLMatrixType* x, wXf wXcallback, wXd wXDcallback,
GslminimizerResult* result,
const ApproximateOptions& options) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param distance pointer to distance value to be calculated
* @param y input data points
* @param L number of elements in x
* @param bMax bMax
* @param x input data points
* @param wXcallback callback for the weight function
* @param wXDcallback callback for the gradient of the weight function
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq(T* distance, GSLMatrixType* y,
size_t L, size_t bMax,
GSLMatrixType* x, wXf wXcallback,
wXd wXDcallback) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param gradient pointer to gradient to be calculated
* @param y input data points
* @param L number of elements in x
* @param bMax bMax
* @param x input data points
* @param wXcallback callback for the weight function
* @param wXDcallback callback for the gradient of the weight function
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq_derivative(
GSLMatrixType* gradient, GSLMatrixType* y, size_t L, size_t bMax,
GSLMatrixType* x, wXf wXcallback, wXd wXDcallback) = 0;
};

#endif // DIRAC_TO_DIRAC_APPROX_FUNCTION_I_H
109 changes: 108 additions & 1 deletion lib/dirac_to_dirac/dirac_to_dirac_approx_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
/**
* @brief interface for the gausian mixture to dirac approximation
*
* @tparam T type of the vector (float, double, long double)
* @tparam T type of the vector (float, double)
*/
template <typename T>
class dirac_to_dirac_approx_i {
public:
using GSLVectorType = typename GSLTemplateTypeAlias<T>::VectorType;
using GSLVectorViewType = typename GSLTemplateTypeAlias<T>::VectorViewType;
using GSLMatrixType = typename GSLTemplateTypeAlias<T>::MatrixType;
using GSLMatrixViewType = typename GSLTemplateTypeAlias<T>::MatrixViewType;

virtual ~dirac_to_dirac_approx_i() = default;

Expand All @@ -45,6 +46,43 @@ class dirac_to_dirac_approx_i {
GslminimizerResult* result,
const ApproximateOptions& options) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param distance pointer to distance value to be calculated
* @param y input data points
* @param M number of elements in y
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wX weights for the x data points
* @param wY weights for the y data points
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq(T* distance, const T* y, size_t M,
size_t L, size_t N, size_t bMax,
T* x, const T* wX,
const T* wY) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param gradient pointer to gradient to be calculated
* @param y input data points
* @param M number of elements in y
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wX weights for the x data points
* @param wY weights for the y data points
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq_derivative(
T* gradient, const T* y, size_t M, size_t L, size_t N, size_t bMax, T* x,
const T* wX, const T* wY) = 0;

/**
* @brief reduce the data points using gsl vectors
*
Expand All @@ -65,6 +103,41 @@ class dirac_to_dirac_approx_i {
GslminimizerResult* result,
const ApproximateOptions& options) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param distance pointer to distance value to be calculated
* @param y input data points
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wX weights for the x data points
* @param wY weights for the y data points
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq(
T* distance, const GSLVectorType* y, size_t L, size_t N, size_t bMax,
GSLVectorType* x, const GSLVectorType* wX, const GSLVectorType* wY) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param gradient pointer to gradient to be calculated
* @param y input data points
* @param L number of elements in x
* @param N dimension of the data
* @param bMax bMax
* @param x input data points
* @param wX weights for the x data points
* @param wY weights for the y data points
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq_derivative(
GSLMatrixType* gradient, const GSLVectorType* y, size_t L, size_t N,
size_t bMax, GSLVectorType* x, const GSLVectorType* wX,
const GSLVectorType* wY) = 0;

/**
* @brief reduce the data points using gsl matricies where possible
*
Expand All @@ -82,6 +155,40 @@ class dirac_to_dirac_approx_i {
GSLMatrixType* x, const GSLVectorType* wX,
const GSLVectorType* wY, GslminimizerResult* result,
const ApproximateOptions& options) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param distance pointer to distance value to be calculated
* @param y input data points
* @param L number of elements in x
* @param bMax bMax
* @param x input data points
* @param wX weights for the x data points
* @param wY weights for the y data points
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq(T* distance, GSLMatrixType* y,
size_t L, size_t bMax,
GSLMatrixType* x,
const GSLVectorType* wX,
const GSLVectorType* wY) = 0;

/**
* @brief calculate modified van mises distance based on x and y
*
* @param gradient pointer to gradient to be calculated
* @param y input data points
* @param L number of elements in x
* @param bMax bMax
* @param x input data points
* @param wX weights for the x data points
* @param wY weights for the y data points
* @return true, on success, false otherwise
*/
virtual void modified_van_mises_distance_sq_derivative(
GSLMatrixType* gradient, GSLMatrixType* y, size_t L, size_t bMax,
GSLMatrixType* x, const GSLVectorType* wX, const GSLVectorType* wY) = 0;
};

#endif // DIRAC_TO_DIRAC_APPROX_I_H
Loading