PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
Classes | Functions
plssvm::operators Namespace Reference

Namespace containing operator overloads for std::vector and other mathematical functions on vectors. More...

Classes

struct  transposed
 Wrapper struct for overloading the dot product operator. More...
 

Functions

template<typename T >
 transposed (const std::vector< T > &) -> transposed< T >
 Deduction guide for the plssvm::operators::transposed struct needed for C++17.
 
template<typename T >
operator* (const transposed< T > &lhs, const std::vector< T > &rhs)
 Calculate the dot product ( \(x^T \cdot y\)) between both std::vector. More...
 
template<typename T >
dot (const std::vector< T > &lhs, const std::vector< T > &rhs)
 Calculate the dot product ( \(x^T \cdot y\)) between both std::vector. More...
 
template<typename T >
sum (const std::vector< T > &vec)
 Accumulate all elements in the std::vector vec. More...
 
template<typename T >
squared_euclidean_dist (const std::vector< T > &lhs, const std::vector< T > &rhs)
 Calculates the squared Euclidean distance of both vectors: \(d^2(x, y) = (x_1 - y_1)^2 + (x_2 - y_2)^2 + \dots + (x_n - y_n)^2\). More...
 
template<typename T >
constexpr T sign (const T x)
 Returns +1 if x is positive and -1 if x is negative or 0. More...
 

Detailed Description

Namespace containing operator overloads for std::vector and other mathematical functions on vectors.

Function Documentation

◆ operator*()

template<typename T >
T plssvm::operators::operator* ( const transposed< T > &  lhs,
const std::vector< T > &  rhs 
)
inline

Calculate the dot product ( \(x^T \cdot y\)) between both std::vector.

Explicitly uses std::fma for better performance and accuracy.

Template Parameters
Tthe value type
Parameters
[in]lhsthe first vector
[in]rhsthe second vector
Returns
the dot product ([[nodiscard]])

◆ dot()

template<typename T >
T plssvm::operators::dot ( const std::vector< T > &  lhs,
const std::vector< T > &  rhs 
)
inline

Calculate the dot product ( \(x^T \cdot y\)) between both std::vector.

Explicitly uses std::fma for better performance and accuracy.

Template Parameters
Tthe value type
Parameters
[in]lhsthe first vector
[in]rhsthe second vector
Returns
the dot product ([[nodiscard]])

◆ sum()

template<typename T >
T plssvm::operators::sum ( const std::vector< T > &  vec)
inline

Accumulate all elements in the std::vector vec.

Uses OpenMP SIMD reduction to speedup the calculation.

Template Parameters
Tthe value type
Parameters
[in]vecthe elements to accumulate
Returns
the sum of all elements ([[nodiscard]])

◆ squared_euclidean_dist()

template<typename T >
T plssvm::operators::squared_euclidean_dist ( const std::vector< T > &  lhs,
const std::vector< T > &  rhs 
)
inline

Calculates the squared Euclidean distance of both vectors: \(d^2(x, y) = (x_1 - y_1)^2 + (x_2 - y_2)^2 + \dots + (x_n - y_n)^2\).

Explicitly uses std::fma for better performance and accuracy.

Template Parameters
Tthe value type
Parameters
[in]lhsthe first vector
[in]rhsthe second vector
Returns
the squared euclidean distance ([[nodiscard]])

◆ sign()

template<typename T >
constexpr T plssvm::operators::sign ( const T  x)
inlineconstexpr

Returns +1 if x is positive and -1 if x is negative or 0.

Parameters
[in]xthe value to calculate the sign for
Returns
+1 if x is positive and -1 if x is negative or 0 ([[nodiscard]])