12 #ifndef PLSSVM_KERNEL_FUNCTION_TYPES_HPP_
13 #define PLSSVM_KERNEL_FUNCTION_TYPES_HPP_
76 [[nodiscard]]
inline real_type
kernel_function(
const std::vector<real_type> &xi,
const std::vector<real_type> &xj, Args &&...args) {
79 PLSSVM_ASSERT(xi.size() == xj.size(),
"Sizes mismatch!: {} != {}", xi.size(), xj.size());
82 static_assert(
sizeof...(args) == 0,
"Illegal number of additional parameters! Must be 0.");
85 static_assert(
sizeof...(args) == 3,
"Illegal number of additional parameters! Must be 3.");
86 const auto degree =
static_cast<real_type
>(detail::get<0>(args...));
87 const auto gamma =
static_cast<real_type
>(detail::get<1>(args...));
88 const auto coef0 =
static_cast<real_type
>(detail::get<2>(args...));
91 static_assert(
sizeof...(args) == 1,
"Illegal number of additional parameters! Must be 1.");
92 const auto gamma =
static_cast<real_type
>(detail::get<0>(args...));
95 static_assert(detail::always_false_v<real_type>,
"Unknown kernel type!");
114 template <
typename real_type>
Implements a custom assert macro PLSSVM_ASSERT.
#define PLSSVM_ASSERT(cond, msg,...)
Defines the PLSSVM_ASSERT macro if PLSSVM_ASSERT_ENABLED is defined.
Definition: assert.hpp:74
Defines universal utility functions.
Implements custom exception classes derived from std::runtime_error including source location informa...
Namespace containing operator overloads for std::vector and other mathematical functions on vectors.
Definition: core.hpp:49
T squared_euclidean_dist(const std::vector< T > &lhs, const std::vector< T > &rhs)
Calculates the squared Euclidean distance of both vectors: .
Definition: operators.hpp:162
The main namespace containing all public API functions.
Definition: backend_types.hpp:24
std::istream & operator>>(std::istream &in, backend_type &backend)
Use the input-stream in to initialize the backend type.
std::ostream & operator<<(std::ostream &out, backend_type backend)
Output the backend to the given output-stream out.
kernel_function_type
Enum class for all implemented kernel functions.
Definition: kernel_function_types.hpp:31
detail::parameter< double > parameter
The public parameter type uses double to store the SVM parameters.
Definition: parameter.hpp:328
real_type kernel_function(const std::vector< real_type > &xi, const std::vector< real_type > &xj, Args &&...args)
Computes the value of the two vectors xi and xj using the kernel function determined at compile-time.
Definition: kernel_function_types.hpp:76
std::string_view kernel_function_type_to_math_string(kernel_function_type kernel) noexcept
Return the mathematical representation of the kernel_type kernel.
Defines (arithmetic) functions on std::vector and scalars.
Class for encapsulating all important C-SVM parameters.
Definition: parameter.hpp:106
Wrapper struct for overloading the dot product operator.
Definition: operators.hpp:99
Defines some generic type traits used in the PLSSVM library.