Update documentation

This commit is contained in:
2023-12-04 22:23:55 +01:00
parent d318491dfe
commit b20fe658b9
15 changed files with 132 additions and 171 deletions

View File

@@ -15,10 +15,17 @@
#include <sys/types.h>
#include <type_traits>
/** @brief Type to use with the IsingModel class and montecarlo module.*/
class data_t {
public:
double E, M, E2, M2, M_abs;
double E; ///< Energy
double M; ///< Magnetization
double E2; ///< Energy squared
double M2; ///< Magnetization squared
double M_abs; ///< Absolute Magnetization
/** @brief constructor with no parameters.
* */
data_t()
{
this->E = 0.;
@@ -28,6 +35,13 @@ public:
this->M_abs = 0.;
}
/** @brief Constructor with parameters.
*
* @param E Initial energy
* @param E2 Initial energy squared
* @param M Initial magnetization
* @param M2 Initial magnetization squared
* @param M_abs Initial absolute magnetization*/
data_t(double E, double E2, double M, double M2, double M_abs)
{
this->E = E;
@@ -37,6 +51,12 @@ public:
this->M_abs = M_abs;
}
/** @brief Overload of the division operator.
*
* @param num The number to divide each field by.
*
* @return data_t
* */
template <class T> data_t operator/(T num)
{
data_t res;
@@ -49,6 +69,13 @@ public:
return res;
}
/** @brief Overload of the division equals operator.
*
* @param num The number to divide each field by.
*
* @return data_t
* */
template <class T> data_t &operator/=(T num)
{
this->E /= (double)num;
@@ -60,6 +87,12 @@ public:
return *this;
}
/** @brief Overload of the multiply operator.
*
* @param num The number to multiply each field by.
*
* @return data_t
* */
template <class T> data_t operator*(T num)
{
data_t res;
@@ -72,6 +105,12 @@ public:
return res;
}
/** @brief Overload of the multiply equals operator.
*
* @param num The number to multiply each field by.
*
* @return data_t
* */
template <class T> data_t &operator*=(T num)
{
this->E *= (double)num;
@@ -83,6 +122,13 @@ public:
return *this;
}
/** @brief Overload of the addition operator.
*
* @param b The data_t field to add.
*
* @return data_t
* */
data_t operator+(const data_t &b)
{
data_t res;
@@ -95,6 +141,12 @@ public:
return res;
}
/** @brief Overload of the addition equals operator.
*
* @param b The data_t field to add.
*
* @return data_t
* */
data_t &operator+=(const data_t &b)
{
this->E += b.E;
@@ -105,17 +157,9 @@ public:
return *this;
}
template <class T> void operator=(T num)
{
this->E = (double)num;
this->E2 = (double)num;
this->M = (double)num;
this->M2 = (double)num;
this->M_abs = (double)num;
}
};
// Declare a custom reduction for the data_t type.
#pragma omp declare reduction(+ : data_t : omp_out += omp_in)
#endif