|
2 Dimensional Ising Model
Simulate the change in energy and magnetization in a ferro magnet
|
A small test library. More...
Go to the source code of this file.
Macros | |
| #define | ASSERT(expr, msg) details::m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg) |
| A prettier assertion function. | |
Functions | |
| void | details::m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg) |
| Test an expression, confirm that test is ok, or abort execution. | |
| template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type> | |
| static bool | testlib::close_to (arma::Mat< T > &a, arma::Mat< T > &b, double tol=1e-8) |
| Test if two armadillo matrices/vectors are close to each other. | |
| template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type> | |
| static bool | testlib::close_to (T a, T b, double tol=1e-8) |
| Test if two numbers are close to each other. | |
| template<class T , class = typename std::enable_if<std::is_integral<T>::value>::type> | |
| static bool | testlib::is_equal (arma::Mat< T > &a, arma::Mat< T > &b) |
| Test if two armadillo matrices/vectors are equal. | |
| template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type> | |
| static bool | testlib::assert_each (std::function< bool(T)> expr, arma::Mat< T > &M) |
| Test that all elements fulfill the condition. | |
A small test library.
This a small testing library that is tailored for the needs of the project. Anything that is in the details namespace should not be used directly, or else it might cause undefined behavior if not used correctly.
Definition in file testlib.hpp.
| #define ASSERT | ( | expr, | |
| msg | |||
| ) | details::m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg) |
A prettier assertion function.
This macro calls the m_assert function which is a more informative assertion function than the regular assert function from cassert.
Definition at line 31 of file testlib.hpp.
|
static |
Test that all elements fulfill the condition.
| expr | The boolean expression to apply to each element |
| M | The matrix/vector to iterate over |
Definition at line 130 of file testlib.hpp.
|
static |
Test if two armadillo matrices/vectors are close to each other.
This function takes in 2 matrices/vectors and checks if they are approximately equal to each other given a tolerance.
| a | Matrix/vector a |
| b | Matrix/vector b |
| tol | The tolerance |
Definition at line 67 of file testlib.hpp.
|
static |
Test if two numbers are close to each other.
This function takes in 2 matrices/vectors and checks if they are approximately equal to each other given a tolerance.
| a | Matrix/vector a |
| b | Matrix/vector b |
| tol | The tolerance |
Definition at line 94 of file testlib.hpp.
|
static |
Test if two armadillo matrices/vectors are equal.
This function takes in 2 matrices/vectors and checks if they are equal to each other. This should only be used for integral types.
| a | Matrix/vector a |
| b | Matrix/vector b |
Definition at line 111 of file testlib.hpp.
| void details::m_assert | ( | bool | expr, |
| std::string | expr_str, | ||
| std::string | func, | ||
| std::string | file, | ||
| int | line, | ||
| std::string | msg | ||
| ) |
Test an expression, confirm that test is ok, or abort execution.
This function takes in an expression and prints an OK message if it's true, or it prints a fail message and aborts execution if it fails.
| expr | The expression to be evaluated |
| expr_str | The stringified version of the expression |
| func | The function name of the caller |
| file | The file of the caller |
| line | The line number where this function is called from |
| msg | The message to be displayed |
Definition at line 15 of file testlib.cpp.