mu
vector.h File Reference
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <initializer_list>
#include <numeric>
#include <ostream>
#include <type_traits>
#include <utility>
#include "mu/typetraits.h"
#include "mu/utility.h"
Include dependency graph for vector.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mu::Matrix< N, M, T >
 A generic matrix. More...
 
class  mu::Vector< N, T >
 A generic vector. More...
 

Functions

template<std::size_t Nn, class U >
std::ostream & mu::operator<< (std::ostream &os, const Vector< Nn, U > &v)
 
template<std::size_t N, class T , class U = T>
Vector< N, T > mu::operator+ (const Vector< N, T > &lhs, const Vector< N, U > &rhs)
 plus operator More...
 
template<std::size_t N, class T , class U = T>
Vector< N, T > mu::operator- (const Vector< N, T > &lhs, const Vector< N, U > &rhs)
 minus operator More...
 
template<std::size_t N, class T , class U = T>
Vector< N, T > mu::operator* (const Vector< N, T > &lhs, const Vector< N, U > &rhs)
 multiplication operator More...
 
template<std::size_t N, class T , class U = T>
Vector< N, T > mu::operator/ (const Vector< N, T > &lhs, const Vector< N, U > &rhs)
 division operator More...
 
template<std::size_t N, class T , class TScalar >
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > > mu::operator+ (const Vector< N, T > &lhs, const TScalar &rhs)
 vector and scalar addition More...
 
template<std::size_t N, class T , class TScalar >
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > > mu::operator+ (const TScalar &lhs, const Vector< N, T > &rhs)
 vector and scalar addition More...
 
template<std::size_t N, class T , class TScalar >
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > > mu::operator- (const Vector< N, T > &lhs, const TScalar &rhs)
 subtract a scalar from this vector More...
 
template<std::size_t N, class T , class TScalar >
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > > mu::operator* (const Vector< N, T > &lhs, const TScalar &rhs)
 vector and scalar multiplication More...
 
template<std::size_t N, class T , class TScalar >
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > > mu::operator* (const TScalar &lhs, const Vector< N, T > &rhs)
 vector and scalar multiplication More...
 
template<std::size_t N, class T , class TScalar >
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > > mu::operator/ (const Vector< N, T > &lhs, const TScalar &rhs)
 vector and scalar division More...
 
template<std::size_t N, class T >
mu::min (const Vector< N, T > &v)
 
template<std::size_t N, class T >
mu::max (const Vector< N, T > &v)
 
template<std::size_t N, class T >
mu::sum (const Vector< N, T > &v)
 
template<class U = void, std::size_t N, typename T >
std::conditional_t< std::is_same< U, void >::value, T, U > mu::mean (const Vector< N, T > &v)
 
template<class U = void, std::size_t N1, class T1 , std::size_t N2, class T2 >
std::conditional_t< std::is_same< U, void >::value, T1, U > mu::dot (const Vector< N1, T1 > &lhs, const Vector< N2, T2 > &rhs)
 
template<typename U = void, std::size_t N, typename T , std::size_t N2, std::size_t M2, typename T2 >
std::conditional_t< std::is_same< U, void >::value, Vector< M2, T >, Vector< M2, U > > mu::dot (const Vector< N, T > &lhs, const Matrix< N2, M2, T2 > &rhs)
 
template<std::size_t N, class T >
void mu::flip (Vector< N, T > &v)
 free fucking function flip More...
 
template<std::size_t N, class T >
Vector< N, T > mu::flipped (const Vector< N, T > &v)
 
template<std::size_t N, class T >
void mu::sort (Vector< N, T > &v)
 
template<std::size_t N, class T , typename Compare >
void mu::sort (Vector< N, T > &v, const Compare &compare)
 
template<std::size_t N, class T >
Vector< N, T > mu::sorted (const Vector< N, T > &v)
 
template<std::size_t N, class T , typename Compare >
Vector< N, T > mu::sorted (const Vector< N, T > &v, const Compare &compare)
 
template<std::size_t N, typename T = int>
Vector< N, T > mu::ones ()
 
template<std::size_t N, typename T = int>
Vector< N, T > mu::zeros ()
 

Detailed Description

Vector class and free functions

Function Documentation

◆ flip()

template<std::size_t N, class T >
void mu::flip ( Vector< N, T > &  v)
inline

free fucking function flip

Template Parameters
N
T
Parameters
v
Here is the call graph for this function:

◆ operator*() [1/3]

template<std::size_t N, class T , class U = T>
Vector<N, T> mu::operator* ( const Vector< N, T > &  lhs,
const Vector< N, U > &  rhs 
)
inline

multiplication operator

Template Parameters
N
T
U
Parameters
lhs
rhs
Returns
Vector<N, T>
Here is the call graph for this function:

◆ operator*() [2/3]

template<std::size_t N, class T , class TScalar >
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T> > mu::operator* ( const Vector< N, T > &  lhs,
const TScalar &  rhs 
)
inline

vector and scalar multiplication

see operator*=(scalar)

Template Parameters
N
T
TScalar
Parameters
lhs
rhs
Returns
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T>>
Here is the call graph for this function:

◆ operator*() [3/3]

template<std::size_t N, class T , class TScalar >
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T> > mu::operator* ( const TScalar &  lhs,
const Vector< N, T > &  rhs 
)
inline

vector and scalar multiplication

see operator*=(scalar)

Template Parameters
N
T
TScalar
Parameters
lhs
rhs
Returns
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T>>
Here is the call graph for this function:

◆ operator+() [1/3]

template<std::size_t N, class T , class U = T>
Vector<N, T> mu::operator+ ( const Vector< N, T > &  lhs,
const Vector< N, U > &  rhs 
)
inline

plus operator

Template Parameters
N
T
U
Parameters
lhs
rhs
Returns
Vector<N, T>
Here is the call graph for this function:

◆ operator+() [2/3]

template<std::size_t N, class T , class TScalar >
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T> > mu::operator+ ( const Vector< N, T > &  lhs,
const TScalar &  rhs 
)
inline

vector and scalar addition

see operator+=(scalar)

Template Parameters
N
T
TScalar
Parameters
lhs
rhs
Returns
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T>>
Here is the call graph for this function:

◆ operator+() [3/3]

template<std::size_t N, class T , class TScalar >
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T> > mu::operator+ ( const TScalar &  lhs,
const Vector< N, T > &  rhs 
)
inline

vector and scalar addition

see operator+=(scalar)

Template Parameters
N
T
TScalar
Parameters
lhs
rhs
Returns
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T>>
Here is the call graph for this function:

◆ operator-() [1/2]

template<std::size_t N, class T , class U = T>
Vector<N, T> mu::operator- ( const Vector< N, T > &  lhs,
const Vector< N, U > &  rhs 
)
inline

minus operator

Template Parameters
N
T
U
Parameters
lhs
rhs
Returns
Vector<N, T>
Here is the call graph for this function:

◆ operator-() [2/2]

template<std::size_t N, class T , class TScalar >
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T> > mu::operator- ( const Vector< N, T > &  lhs,
const TScalar &  rhs 
)
inline

subtract a scalar from this vector

Template Parameters
N
T
TScalar
Parameters
lhs
rhs
Returns
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T>>
Here is the call graph for this function:

◆ operator/() [1/2]

template<std::size_t N, class T , class U = T>
Vector<N, T> mu::operator/ ( const Vector< N, T > &  lhs,
const Vector< N, U > &  rhs 
)
inline

division operator

Template Parameters
N
T
U
Parameters
lhs
rhs
Returns
Vector<N, T>
Here is the call graph for this function:

◆ operator/() [2/2]

template<std::size_t N, class T , class TScalar >
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T> > mu::operator/ ( const Vector< N, T > &  lhs,
const TScalar &  rhs 
)
inline

vector and scalar division

Template Parameters
N
T
TScalar
Parameters
lhs
rhs
Returns
std::enable_if_t<std::is_arithmetic<TScalar>::value, Vector<N, T>>
Here is the call graph for this function:

◆ operator<<()

template<std::size_t Nn, class U >
std::ostream& mu::operator<< ( std::ostream &  os,
const Vector< Nn, U > &  v 
)
Example
mu::Vector<4, int> a{2, 3, 4, 5};
// std::cout << a << std::endl;
// [ 2, 3, 4, 5 ]
Template Parameters
Nn
U
Parameters
os
v
Returns
std::ostream&