.TH "src/utils.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME src/utils.cpp \- Implementation of the utils\&. .SH SYNOPSIS .br .PP \fC#include \fP .br \fC#include 'utils\&.hpp'\fP .br .SS "Functions" .in +1c .ti -1c .RI "std::string \fBscientific_format\fP (double d, int width, int prec)" .br .RI "Turns a double into a string written in scientific format\&. " .ti -1c .RI "std::string \fBscientific_format\fP (const std::vector< double > &v, int width, int prec)" .br .RI "Turns a vector of doubles into a string written in scientific format\&. " .ti -1c .RI "void \fBm_assert\fP (bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg)" .br .RI "Test an expression, confirm that test is ok, or abort execution\&. " .ti -1c .RI "bool \fBarma_vector_close_to\fP (arma::vec &a, arma::vec &b, double tol)" .br .RI "Test if two armadillo vectors are close to each other\&. " .ti -1c .RI "bool \fBmkpath\fP (std::string path, int mode)" .br .RI "Make path given\&. " .in -1c .SH "Detailed Description" .PP Implementation of the utils\&. .PP \fBAuthor\fP .RS 4 Cory Alexander Balaton (coryab) .PP Janita Ovidie Sandtrøen Willumsen (janitaws) .RE .PP \fBVersion\fP .RS 4 1\&.0 .RE .PP .PP \fBBug\fP .RS 4 No known bugs .RE .PP .PP Definition in file \fButils\&.cpp\fP\&. .SH "Function Documentation" .PP .SS "bool arma_vector_close_to (arma::vec & a, arma::vec & b, double tol = \fC1e\-8\fP)" .PP Test if two armadillo vectors are close to each other\&. This function takes in 2 vectors and checks if they are approximately equal to each other given a tolerance\&. .PP \fBParameters\fP .RS 4 \fIa\fP Vector a .br \fIb\fP Vector b .br \fItol\fP The tolerance .RE .PP \fBReturns\fP .RS 4 bool .RE .PP .PP Definition at line \fB62\fP of file \fButils\&.cpp\fP\&. .SS "void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)" .PP 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\&. .PP \fBParameters\fP .RS 4 \fIexpr\fP The expression to be evaluated .br \fIexpr_str\fP The stringified version of the expression .br \fIfunc\fP The function name of the caller .br \fIfile\fP The file of the caller .br \fIline\fP The line number where this function is called from .br \fImsg\fP The message to be displayed .RE .PP .PP Definition at line \fB43\fP of file \fButils\&.cpp\fP\&. .SS "bool mkpath (std::string path, int mode = \fC0777\fP)" .PP Make path given\&. This tries to be the equivalent to 'mkdir -p' and creates a new directory whenever it needs to\&. .PP \fBParameters\fP .RS 4 \fIpath\fP The path to be created .br \fImode\fP The mode/permissions for all the new directories .RE .PP \fBReturns\fP .RS 4 bool .RE .PP .PP Definition at line \fB76\fP of file \fButils\&.cpp\fP\&. .SS "std::string scientific_format (const std::vector< double > & v, int width = \fC20\fP, int prec = \fC10\fP)" .PP Turns a vector of doubles into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&. .PP \fBParameters\fP .RS 4 \fIv\fP The vector to stringify .br \fIwidth\fP The reserved width of the string .br \fIprec\fP The precision of the stringified number .RE .PP \fBReturns\fP .RS 4 std::string .RE .PP .PP Definition at line \fB24\fP of file \fButils\&.cpp\fP\&. .SS "std::string scientific_format (double d, int width = \fC20\fP, int prec = \fC10\fP)" .PP Turns a double into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&. .PP \fBParameters\fP .RS 4 \fId\fP The number to stringify .br \fIwidth\fP The reserved width of the string .br \fIprec\fP The precision of the stringified number .RE .PP \fBReturns\fP .RS 4 std::string .RE .PP .PP Definition at line \fB17\fP of file \fButils\&.cpp\fP\&. .SH "Author" .PP Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.