|
2 Dimensional Ising Model
Simulate the change in energy and magnetization in a ferro magnet
|
Function prototypes and macros that are useful. More...
#include <armadillo>#include <iomanip>#include <sstream>#include <string>#include <sys/stat.h>#include <vector>Go to the source code of this file.
Macros | |
| #define | DEBUG(msg) |
| Writes a debug message. | |
| #define | __METHOD_NAME__ details::methodName(__PRETTY_FUNCTION__) |
| Get the name of the current method/function without the return type. | |
Functions | |
| std::string | details::methodName (const std::string &pretty_function) |
| Takes in the PRETTY_FUNCTION string and removes the return type. | |
| std::string | utils::scientific_format (double d, int width=20, int prec=10) |
| Turns a double into a string written in scientific format. | |
| std::string | utils::scientific_format (const std::vector< double > &v, int width=20, int prec=10) |
| Turns a vector of doubles into a string written in scientific format. | |
| bool | utils::mkpath (std::string path, int mode=0777) |
| Make path given. | |
| std::string | utils::dirname (const std::string &path) |
| Get the directory name of the path. | |
Function prototypes and macros that are useful.
These utility function are mainly for convenience and aren't directly related to 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 utils.hpp.
| #define __METHOD_NAME__ details::methodName(__PRETTY_FUNCTION__) |
| #define DEBUG | ( | msg | ) |
Writes a debug message.
This macro writes a debug message that includes the filename, line number, and a custom message. The function is wrapped in an ifdef that checks if DBG is defined, so one can choose to display the debug messages by adding the -DDBG flag when compiling.
| std::string utils::dirname | ( | const std::string & | path | ) |
|
inline |
Takes in the PRETTY_FUNCTION string and removes the return type.
This function should only be used for the METHOD_NAME macro, since it takes the output from PRETTY_FUNCTION and strips the return type.
| pretty_function | The string from PRETTY_FUNCTION |
| bool utils::mkpath | ( | std::string | path, |
| int | mode = 0777 |
||
| ) |
| std::string utils::scientific_format | ( | const std::vector< double > & | v, |
| int | width = 20, |
||
| int | prec = 10 |
||
| ) |
Turns a vector of doubles into a string written in scientific format.
The code is stolen from https://github.com/anderkve/FYS3150.
| v | The vector to stringify |
| width | The reserved width of the string |
| prec | The precision of the stringified number |
| std::string utils::scientific_format | ( | double | d, |
| int | width = 20, |
||
| int | prec = 10 |
||
| ) |
Turns a double into a string written in scientific format.
The code is stolen from https://github.com/anderkve/FYS3150.
| d | The number to stringify |
| width | The reserved width of the string |
| prec | The precision of the stringified number |