TRIQS/app4triqs 3.3.0
A TRIQS application
Loading...
Searching...
No Matches
app4triqs.cpp
Go to the documentation of this file.
1
5
6#include <cmath>
7#include "./app4triqs.hpp"
8
9namespace app4triqs {
10
11 toto &toto::operator+=(toto const &b) {
12 this->i += b.i;
13 return *this;
14 }
15
16 toto toto::operator+(toto const &b) const {
17 auto res = *this;
18 res += b;
19 return res;
20 }
21
22 bool toto::operator==(toto const &b) const { return (this->i == b.i); }
23
24 void h5_write(h5::group grp, std::string subgroup_name, toto const &m) {
25 grp = subgroup_name.empty() ? grp : grp.create_group(subgroup_name);
26 h5_write(grp, "i", m.i);
27 h5_write_attribute(grp, "Format", toto::hdf5_format());
28 }
29
30 void h5_read(h5::group grp, std::string subgroup_name, toto &m) {
31 grp = subgroup_name.empty() ? grp : grp.open_group(subgroup_name);
32 int i;
33 h5_read(grp, "i", i);
34 m = toto(i);
35 }
36
37 int chain(int i, int j) {
38 int n_digits_j = j > 0 ? (int)log10(j) + 1 : 1;
39 return i * int(pow(10, n_digits_j)) + j;
40 }
41
42} // namespace app4triqs
Provides various functions and classes for the app4triqs application.
toto operator+(toto const &b) const
Arithmetic operations.
Definition app4triqs.cpp:16
bool operator==(toto const &b) const
Comparison.
Definition app4triqs.cpp:22
static std::string hdf5_format()
HDF5.
Definition app4triqs.hpp:63
int chain(int i, int j)
Chain digits of two integers.
Definition app4triqs.cpp:37