2 Dimensional Ising Model
Simulate the change in energy and magnetization in a ferro magnet
Loading...
Searching...
No Matches
utils.cpp File Reference

Implementation of the utils. More...

#include "utils.hpp"

Go to the source code of this file.

Functions

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.
 

Detailed Description

Implementation of the utils.

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

Definition in file utils.cpp.

Function Documentation

◆ dirname()

std::string utils::dirname ( const std::string &  path)

Get the directory name of the path.

Parameters
pathThe path to use.
Returns
string

Definition at line 58 of file utils.cpp.

◆ mkpath()

bool utils::mkpath ( std::string  path,
int  mode = 0777 
)

Make path given.

This tries to be the equivalent to "mkdir -p" and creates a new directory whenever it needs to.

Parameters
pathThe path to be created
modeThe mode/permissions for all the new directories
Returns
bool Success/Fail

Definition at line 32 of file utils.cpp.

◆ scientific_format() [1/2]

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.

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

Definition at line 23 of file utils.cpp.

◆ scientific_format() [2/2]

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.

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

Definition at line 16 of file utils.cpp.