202 lines
5.2 KiB
Groff
202 lines
5.2 KiB
Groff
.TH "include/utils.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
include/utils.hpp \- Function prototypes and macros that are useful\&.
|
|
|
|
.SH SYNOPSIS
|
|
.br
|
|
.PP
|
|
\fC#include <armadillo>\fP
|
|
.br
|
|
\fC#include <iomanip>\fP
|
|
.br
|
|
\fC#include <sstream>\fP
|
|
.br
|
|
\fC#include <string>\fP
|
|
.br
|
|
\fC#include <vector>\fP
|
|
.br
|
|
|
|
.SS "Macros"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "#define \fBDEBUG\fP(msg)"
|
|
.br
|
|
.RI "Writes a debug message\&. "
|
|
.ti -1c
|
|
.RI "#define \fBASSERT\fP(expr, msg)"
|
|
.br
|
|
.RI "A prettier assertion function\&. "
|
|
.ti -1c
|
|
.RI "#define \fB__METHOD_NAME__\fP methodName(__PRETTY_FUNCTION__)"
|
|
.br
|
|
.in -1c
|
|
.SS "Functions"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "std::string \fBscientific_format\fP (double d, int width=20, int prec=10)"
|
|
.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=20, int prec=10)"
|
|
.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 func, 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=1e\-8)"
|
|
.br
|
|
.RI "Test if two armadillo vectors are close to each other\&. "
|
|
.in -1c
|
|
.SH "Detailed Description"
|
|
.PP
|
|
Function prototypes and macros that are useful\&.
|
|
|
|
|
|
.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
|
|
These utility function are mainly for convenience and aren't directly related to the project\&.
|
|
.PP
|
|
\fBBug\fP
|
|
.RS 4
|
|
No known bugs
|
|
.RE
|
|
.PP
|
|
|
|
.PP
|
|
Definition in file \fButils\&.hpp\fP\&.
|
|
.SH "Macro Definition Documentation"
|
|
.PP
|
|
.SS "#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)"
|
|
|
|
.PP
|
|
Definition at line \fB48\fP of file \fButils\&.hpp\fP\&.
|
|
.SS "#define ASSERT(expr, msg)"
|
|
\fBValue:\fP.PP
|
|
.nf
|
|
m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \\
|
|
__LINE__, msg)
|
|
.fi
|
|
|
|
.PP
|
|
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\&.
|
|
.PP
|
|
Definition at line \fB45\fP of file \fButils\&.hpp\fP\&.
|
|
.SS "#define DEBUG(msg)"
|
|
|
|
.PP
|
|
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\&.
|
|
.PP
|
|
Definition at line \fB36\fP of file \fButils\&.hpp\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
|
|
Boolean
|
|
.RE
|
|
.PP
|
|
|
|
.PP
|
|
Definition at line \fB59\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 \fB40\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\&.
|
|
.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
|
|
String
|
|
.RE
|
|
.PP
|
|
|
|
.PP
|
|
Definition at line \fB21\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\&. Code stolen from https://github.com/anderkve/FYS3150 Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp
|
|
.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
|
|
String
|
|
.RE
|
|
.PP
|
|
|
|
.PP
|
|
Definition at line \fB14\fP of file \fButils\&.cpp\fP\&.
|
|
.SH "Author"
|
|
.PP
|
|
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|