# 2 Dimensional Ising Model: utils Namespace Reference

Loading...
Searching...
No Matches
utils Namespace Reference

## 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.
bool | mkpath (std::string path, int mode=0777)
| Make path given.
std::string | dirname (const std::string &path)
| Get the directory name of the path.
std::string | concatpath (const std::string &left, const std::string &right)
| Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.

## Function Documentation

## concatpath()

std::string utils::concatpath | ( | const std::string & | left,
|  | const std::string & | right
| ) |  |

Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.

This function doesn't care whether or not the values given as parameters are valid path strings. It is the responsibility of the user to make sure that the values given are valid path strings. The function only guarantees that the output string is a valid path string.

Parameters

  left | The left hand side of the result string
  right | The right hand side of the result string

Returns
  string

Definition at line 63 of file utils.cpp.

## dirname()

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

Get the directory name of the path.

Parameters

  path | The 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

  path | The path to be created
  mode | The 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

  v | The vector to stringify
  width | The reserved width of the string
  prec | The 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

  d | The number to stringify
  width | The reserved width of the string
  prec | The precision of the stringified number

Returns
  std::string

Definition at line 16 of file utils.cpp.