PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
Classes | Namespaces | Macros | Functions
operators.hpp File Reference

Defines (arithmetic) functions on std::vector and scalars. More...

#include "plssvm/detail/assert.hpp"
#include <cmath>
#include <vector>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  plssvm::operators::transposed< T >
 Wrapper struct for overloading the dot product operator. More...
 

Namespaces

 plssvm
 The main namespace containing all public API functions.
 
 plssvm::operators
 Namespace containing operator overloads for std::vector and other mathematical functions on vectors.
 

Macros

#define PLSSVM_GENERATE_ARITHMETIC_OPERATION(Op)
 Generate arithmetic element-wise operations using Op for std::vector (and scalars). More...
 

Functions

template<typename T >
 plssvm::operators::transposed (const std::vector< T > &) -> transposed< T >
 Deduction guide for the plssvm::operators::transposed struct needed for C++17.
 
template<typename T >
plssvm::operators::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 >
plssvm::operators::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 >
plssvm::operators::sum (const std::vector< T > &vec)
 Accumulate all elements in the std::vector vec. More...
 
template<typename T >
plssvm::operators::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 plssvm::operators::sign (const T x)
 Returns +1 if x is positive and -1 if x is negative or 0. More...
 

Detailed Description

Defines (arithmetic) functions on std::vector and scalars.

Author
Alexander Van Craen
Marcel Breyer
License
This file is part of the PLSSVM project which is released under the MIT license. See the LICENSE.md file in the project root for full license information.

Macro Definition Documentation

◆ PLSSVM_GENERATE_ARITHMETIC_OPERATION

#define PLSSVM_GENERATE_ARITHMETIC_OPERATION (   Op)

Generate arithmetic element-wise operations using Op for std::vector (and scalars).

If available, OpenMP SIMD (#pragma omp simd) is used to speedup the computations.

Given the variables

std::vector<T> vec1 = ...;
std::vector<T> vec2 = ...;
T scalar = ...;

the following operations for Op are generated (e.g., Op is +):

vec1 += vec2; // operator+=(vector, vector)
vec1 + vec2; // operator+(vector, vector)
vec1 += scalar; // operator+=(vector, scalar)
vec1 + scalar; // operator+(vector, scalar)
scalar + vec1; // operator+(scalar, vector)
Parameters
[in]Opthe operator to generate