FYS3150: Project 2
Loading...
Searching...
No Matches
Macros | Functions
utils.hpp File Reference

Function prototypes and macros that are useful. More...

#include <string>
#include <vector>
#include <iomanip>
#include <sstream>

Go to the source code of this file.

Macros

#define DEBUG(msg)
 Writes a debug message.
 

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.
 

Detailed Description

Function prototypes and macros that are useful.

These utility function are mainly for convenience and aren't directly related to the project.

Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
Bug:
No known bugs

Macro Definition Documentation

◆ DEBUG

#define DEBUG (   msg)

Writes a debug message.

This function 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.

Function Documentation

◆ scientific_format() [1/2]

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.

Parameters
vThe vector to stringify
widthThe reserved width of the string
precThe precision of the stringified number
Returns
String

◆ scientific_format() [2/2]

std::string scientific_format ( double  d,
int  width = 20,
int  prec = 10 
)

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

Parameters
dThe number to stringify
widthThe reserved width of the string
precThe precision of the stringified number
Returns
String