|
AiLibrary
v1.3.0
A single-header C++ Library from Ailurus Studio
|
Functions providing different math methods and checks. More...
Functions | |
| template<typename T > | |
| INLINE T | ai::sign (const T value) |
| Returns signum of the value. More... | |
| template<typename T > | |
| INLINE T | ai::min (const T a, const T b) |
| Returns minimum of two values. More... | |
| template<typename T > | |
| INLINE T | ai::max (const T a, const T b) |
| Returns maximum of two values. More... | |
| template<typename T > | |
| INLINE T | ai::min (const std::vector< T > &input) |
| Returns minimum of vector values. More... | |
| template<typename T > | |
| INLINE T | ai::max (const std::vector< T > &input) |
| Returns maximum of vector values. More... | |
| template<typename T > | |
| INLINE T | ai::min (const std::vector< std::vector< T > > &input) |
| Returns minimum of matrix values. More... | |
| template<typename T > | |
| INLINE T | ai::max (const std::vector< std::vector< T > > &input) |
| Returns maximum of matrix values. More... | |
| template<typename T > | |
| INLINE bool | ai::isSquare (const T value) |
| Checks if number is square. More... | |
| template<typename T > | |
| INLINE bool | ai::isSquare (const std::vector< std::vector< T > > &matrix) |
| Checks if matrix is square. More... | |
| template<typename T > | |
| INLINE void | ai::generateRandomVector (std::vector< T > &vector, const std::size_t length, const T min=std::numeric_limits< T >::min(), const T max=std::numeric_limits< T >::max()) |
| template<typename T > | |
| INLINE void | ai::generateRandomMatrix (std::vector< std::vector< T > > &matrix, const std::size_t xSize, const std::size_t ySize, const T min=std::numeric_limits< T >::min(), const T max=std::numeric_limits< T >::max()) |
| Fill matrix with random values. More... | |
| template<typename T > | |
| INLINE void | ai::generateRandomMatrix (std::vector< std::vector< T > > &matrix, const std::size_t size, const T min=std::numeric_limits< T >::min(), const T max=std::numeric_limits< T >::max()) |
| Fill matrix with random values. More... | |
| template<typename T > | |
| void | ai::rotateMatrix (std::vector< std::vector< T > > &matrix, const bool rotateClockwise=false) |
| Rotate square matrix. More... | |
| template<typename T > | |
| INLINE void | ai::inverseMatrix (std::vector< std::vector< T > > matrix, std::vector< std::vector< T > > &inverse) |
| template<typename T > | |
| INLINE void | ai::inverseMatrix (std::vector< std::vector< T > > &matrix) |
| template<typename T > | |
| INLINE void | ai::translateMatrixIntoVector (std::vector< std::vector< T > > &matrix, std::vector< T > &vector) |
| Elongates matrix into a vector. More... | |
| template<typename T > | |
| INLINE void | ai::translateVectorIntoSquareMatrix (std::vector< T > &vector, std::vector< std::vector< T > > &matrix) |
| Transform vector into a square matrix (if possible) More... | |
| template<typename T > | |
| INLINE void | ai::generateCirculantMatrix (std::vector< std::vector< T > > &matrix, std::vector< T > &source, const bool moveToTheRight=true) |
| template<typename T > | |
| INLINE void | ai::multiply (const std::vector< std::vector< T > > &left, const std::vector< std::vector< T > > &right, std::vector< std::vector< T > > &result) |
| template<typename T > | |
| INLINE void | ai::multiply (const std::vector< std::vector< T > > &left, const std::vector< T > &right, std::vector< T > &result) |
| template<typename T > | |
| INLINE void | ai::multiply (const std::vector< T > &left, const std::vector< T > &right, T &result) |
| Calculate vector-vector multiplication. More... | |
| template<typename T > | |
| INLINE void | ai::multiplyElementWise (const std::vector< std::vector< T > > &left, const std::vector< std::vector< T > > &right, std::vector< std::vector< T > > &result) |
| template<typename T > | |
| INLINE void | ai::multiplyElementWise (const std::vector< T > &left, const std::vector< T > &right, std::vector< T > &result) |
| template<typename T > | |
| INLINE void | ai::multiplyComplexElementWise (const std::vector< std::vector< T > > &left, const std::vector< std::vector< T > > &right, std::vector< std::vector< T > > &result) |
| template<typename T > | |
| INLINE std::string | ai::complexIntoString (const std::vector< T > complexValue) |
| template<typename T > | |
| INLINE void | ai::conjugate (std::vector< std::vector< T > > &complexVector) |
| template<typename T > | |
| INLINE void | ai::fft (std::vector< std::vector< T > > &complexVector) |
| template<typename T > | |
| INLINE void | ai::ifft (std::vector< std::vector< T > > &complexVector) |
Variables | |
| static const double | ai::e = 2.71828182845904523536 |
| Mathematical constant 'e'. More... | |
| static const double | ai::pi = 3.14159265358979323846 |
| Mathematical constant 'pi'. More... | |
Group of functions that completes standard C++ mathematical methods and helps with matrices and vectors
| INLINE std::string ai::complexIntoString | ( | const std::vector< T > | complexValue | ) |
| T | A number type |

| INLINE void ai::conjugate | ( | std::vector< std::vector< T > > & | complexVector | ) |
| T | A number type |

| INLINE void ai::fft | ( | std::vector< std::vector< T > > & | complexVector | ) |
| T | A number type |


| INLINE void ai::generateCirculantMatrix | ( | std::vector< std::vector< T > > & | matrix, |
| std::vector< T > & | source, | ||
| const bool | moveToTheRight = true |
||
| ) |

| void ai::generateRandomMatrix | ( | std::vector< std::vector< T > > & | matrix, |
| const std::size_t | xSize, | ||
| const std::size_t | ySize, | ||
| const T | min = std::numeric_limits<T>::min(), |
||
| const T | max = std::numeric_limits<T>::max() |
||
| ) |
This function fills the matrix of given sizes with random values using std::random_device and generateRandomVector()
| T | A number type |
| matrix | Matrix to fill |
| xSize | Required length of the matrix |
| ySize | Required height of the matrix |
| min | Lower limit of generated values, no limitation by default |
| max | Upper limit of generated values, no limitation by default |


| void ai::generateRandomMatrix | ( | std::vector< std::vector< T > > & | matrix, |
| const std::size_t | size, | ||
| const T | min = std::numeric_limits<T>::min(), |
||
| const T | max = std::numeric_limits<T>::max() |
||
| ) |
This function fills the square matrix of given sizes with random values using std::random_device and generateRandomVector()
| T | A number type |
| matrix | Matrix to fill |
| size | Required size of the square matrix |
| min | Lower limit of generated values, no limitation by default |
| max | Upper limit of generated values, no limitation by default |

| INLINE void ai::generateRandomVector | ( | std::vector< T > & | vector, |
| const std::size_t | length, | ||
| const T | min = std::numeric_limits<T>::min(), |
||
| const T | max = std::numeric_limits<T>::max() |
||
| ) |


| INLINE void ai::ifft | ( | std::vector< std::vector< T > > & | complexVector | ) |
| T | A number type |

| INLINE void ai::inverseMatrix | ( | std::vector< std::vector< T > > | matrix, |
| std::vector< std::vector< T > > & | inverse | ||
| ) |


| INLINE void ai::inverseMatrix | ( | std::vector< std::vector< T > > & | matrix | ) |

| bool ai::isSquare | ( | const T | value | ) |
This function checks if number is square
| T | A number type |
| value | Number to test |

| bool ai::isSquare | ( | const std::vector< std::vector< T > > & | matrix | ) |
This function checks if matrix is square
| T | A number type |
| matrix | Matrix to test |
| T ai::max | ( | const T | a, |
| const T | b | ||
| ) |
This function compares two values and returns a maximum
| T | A number type |
| a | First number |
| b | Second number |

| T ai::max | ( | const std::vector< T > & | input | ) |
This function compares vector values using max() and returns a maximum
| T | A number type |
| input | Vector to search for a maximum value |

| T ai::max | ( | const std::vector< std::vector< T > > & | input | ) |
This function compares matrix values using max() and returns a maximum
| T | A number type |
| input | Matrix to search for a maximum value |

| T ai::min | ( | const T | a, |
| const T | b | ||
| ) |
This function compares two values and returns a minimum
| T | A number type |
| a | First number |
| b | Second number |

| T ai::min | ( | const std::vector< T > & | input | ) |
This function compares vector values using min() and returns a minimum
| T | A number type |
| input | Vector to search for a minimum value |

| T ai::min | ( | const std::vector< std::vector< T > > & | input | ) |
This function compares matrix values using min() and returns a minimum
| T | A number type |
| input | Matrix to search for a minimum value |

| INLINE void ai::multiply | ( | const std::vector< std::vector< T > > & | left, |
| const std::vector< std::vector< T > > & | right, | ||
| std::vector< std::vector< T > > & | result | ||
| ) |
| INLINE void ai::multiply | ( | const std::vector< std::vector< T > > & | left, |
| const std::vector< T > & | right, | ||
| std::vector< T > & | result | ||
| ) |
| void ai::multiply | ( | const std::vector< T > & | left, |
| const std::vector< T > & | right, | ||
| T & | result | ||
| ) |
This function calculates vector-vector multiplication
| T | A number type |
| left | Left vector to multiply |
| right | Right vector to multiply |
| result | Variable to store result |
| std::runtime_error | If input sizes are inappropriate |
| INLINE void ai::multiplyComplexElementWise | ( | const std::vector< std::vector< T > > & | left, |
| const std::vector< std::vector< T > > & | right, | ||
| std::vector< std::vector< T > > & | result | ||
| ) |
| T | A number type |
| INLINE void ai::multiplyElementWise | ( | const std::vector< std::vector< T > > & | left, |
| const std::vector< std::vector< T > > & | right, | ||
| std::vector< std::vector< T > > & | result | ||
| ) |
| INLINE void ai::multiplyElementWise | ( | const std::vector< T > & | left, |
| const std::vector< T > & | right, | ||
| std::vector< T > & | result | ||
| ) |
| void ai::rotateMatrix | ( | std::vector< std::vector< T > > & | matrix, |
| const bool | rotateClockwise = false |
||
| ) |
This function rotates the square matrix 90 degrees clockwise or anticlockwise
| T | Any copiable type |
| matrix | Matrix to rotate |
| rotateClockwise | Optional. If true, rotate clockwise. Otherwise, rotate anticlockwise (default) |
| T ai::sign | ( | const T | value | ) |
This function returns signum of the number value (usign copysign())
| T | A number type |
| value | The number to which signum is applied |
| void ai::translateMatrixIntoVector | ( | std::vector< std::vector< T > > & | matrix, |
| std::vector< T > & | vector | ||
| ) |
This function converts the matrix into a vector, writing each row one after another in a line
| T | A number type |
| matrix | Matrix to tranform |
| vector | Vector to store the result |
| void ai::translateVectorIntoSquareMatrix | ( | std::vector< T > & | vector, |
| std::vector< std::vector< T > > & | matrix | ||
| ) |
This function converts the vector into a matrix, if possible. Otherwise, an exception will be thrown at runtime
| T | A number type |
| vector | Vector to tranform |
| matrix | Matrix to store the result |
| std::runtime_error | If matrix is not square |

|
static |
Mathematical constant
(20 decimal places)
|
static |
Mathematical constant
(20 decimal places)