|
Penning Trap Simulation
Simulate particle behavior inside a Penning Trap
|
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 | ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg) |
| A prettier assertion function. | |
| #define | __METHOD_NAME__ methodName(__PRETTY_FUNCTION__) |
| Get the name of the current method/function without the return type. | |
Functions | |
| std::string | scientific_format (double d, int width=20, int prec=10) |
| Turns a double into a string written in scientific format. | |
| std::string | 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. | |
| void | 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. | |
| bool | close_to (arma::vec &a, arma::vec &b, double tol=1e-8) |
| Test if two armadillo vectors are close to each other. | |
| bool | mkpath (std::string path, int mode=0777) |
| Make path given. | |
Function prototypes and macros that are useful.
These utility function are mainly for convenience and aren't directly related to the project.
Definition in file utils.hpp.
| #define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__) |
| #define ASSERT | ( | expr, | |
| msg | |||
| ) | m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg) |
| #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.
| bool close_to | ( | arma::vec & | a, |
| arma::vec & | b, | ||
| double | tol = 1e-8 |
||
| ) |
| void 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 |
| bool mkpath | ( | std::string | path, |
| int | mode = 0777 |
||
| ) |
| std::string 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 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 |