Namespace containing operator overloads for std::vector and other mathematical functions on vectors.
More...
|
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 > |
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 > |
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 > |
T | sum (const std::vector< T > &vec) |
| Accumulate all elements in the std::vector vec . More...
|
|
template<typename T > |
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...
|
|
Namespace containing operator overloads for std::vector and other mathematical functions on vectors.
◆ 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
-
- Parameters
-
[in] | lhs | the first vector |
[in] | rhs | the 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
-
- Parameters
-
[in] | lhs | the first vector |
[in] | rhs | the 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
-
- Parameters
-
[in] | vec | the 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
-
- Parameters
-
[in] | lhs | the first vector |
[in] | rhs | the 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] | x | the value to calculate the sign for |
- Returns
- +1 if
x
is positive and -1 if x
is negative or 0 ([[nodiscard]]
)