Commit bfd22685 authored by Tiago Peixoto's avatar Tiago Peixoto

graph_blockmodel.hh: Cosmetic changes

parent 64789f16
Pipeline #266 passed with stage
in 312 minutes and 24 seconds
...@@ -1024,40 +1024,35 @@ public: ...@@ -1024,40 +1024,35 @@ public:
for (size_t i = 0; i < _rec_types.size(); ++i) for (size_t i = 0; i < _rec_types.size(); ++i)
{ {
auto& wparams = _wparams[i]; auto& wp = _wparams[i];
switch (_rec_types[i]) switch (_rec_types[i])
{ {
case weight_type::REAL_EXPONENTIAL: case weight_type::REAL_EXPONENTIAL:
positive_entries_op(i, positive_entries_op(i,
[&](auto N, auto x) [&](auto N, auto x)
{ return positive_w_log_P(N, x, { return positive_w_log_P(N, x, wp[0],
wparams[0], wp[1]);
wparams[1]);
}); });
break; break;
case weight_type::DISCRETE_GEOMETRIC: case weight_type::DISCRETE_GEOMETRIC:
positive_entries_op(i, positive_entries_op(i,
[&](auto N, auto x) [&](auto N, auto x)
{ return geometric_w_log_P(N, x, { return geometric_w_log_P(N, x, wp[0],
wparams[0], wp[1]);
wparams[1]);
}); });
break; break;
case weight_type::DISCRETE_POISSON: case weight_type::DISCRETE_POISSON:
positive_entries_op(i, positive_entries_op(i,
[&](auto N, auto x) [&](auto N, auto x)
{ return poisson_w_log_P(N, x, { return poisson_w_log_P(N, x, wp[0],
wparams[0], wp[1]);
wparams[1]);
}); });
break; break;
case weight_type::DISCRETE_BINOMIAL: case weight_type::DISCRETE_BINOMIAL:
positive_entries_op(i, positive_entries_op(i,
[&](auto N, auto x) [&](auto N, auto x)
{ return binomial_w_log_P(N, x, { return binomial_w_log_P(N, x, wp[0],
wparams[0], wp[1], wp[2]);
wparams[1],
wparams[2]);
}); });
break; break;
case weight_type::REAL_NORMAL: case weight_type::REAL_NORMAL:
...@@ -1076,18 +1071,14 @@ public: ...@@ -1076,18 +1071,14 @@ public:
auto dx = get<1>(delta)[i]; auto dx = get<1>(delta)[i];
auto dx2 = get<2>(delta)[i]; auto dx2 = get<2>(delta)[i];
auto sigma1 = x2rs - xrs * (xrs / ers); auto sigma1 = x2rs - xrs * (xrs / ers);
auto sigma2 = x2rs + dx2 - (xrs + dx) * ((xrs + dx) / (ers + d)); auto sigma2 = (x2rs + dx2 - (xrs + dx) *
((xrs + dx) / (ers + d)));
dS -= -signed_w_log_P(ers, xrs, sigma1, dS -= -signed_w_log_P(ers, xrs, sigma1,
wparams[0], wp[0], wp[1], wp[2],
wparams[1], wp[3]);
wparams[2],
wparams[3]);
dS += -signed_w_log_P(ers + d, xrs + dx, dS += -signed_w_log_P(ers + d, xrs + dx,
sigma2, sigma2, wp[0], wp[1],
wparams[0], wp[2], wp[3]);
wparams[1],
wparams[2],
wparams[3]);
}); });
break; break;
case weight_type::DELTA_T: // waiting times case weight_type::DELTA_T: // waiting times
...@@ -1098,16 +1089,18 @@ public: ...@@ -1098,16 +1089,18 @@ public:
if (r != null_group) if (r != null_group)
{ {
dS -= -positive_w_log_P(_mrp[r], _brecsum[r], dS -= -positive_w_log_P(_mrp[r], _brecsum[r],
_wparams[i][0], _wparams[i][1]); wp[0], wp[1]);
dS += -positive_w_log_P(_mrp[r] - k, _brecsum[r] - dt[0], dS += -positive_w_log_P(_mrp[r] - k,
_wparams[i][0], _wparams[i][1]); _brecsum[r] - dt[0],
wp[0], wp[1]);
} }
if (nr != null_group) if (nr != null_group)
{ {
dS -= -positive_w_log_P(_mrp[nr], _brecsum[nr], dS -= -positive_w_log_P(_mrp[nr], _brecsum[nr],
_wparams[i][0], _wparams[i][1]); wp[0], wp[1]);
dS += -positive_w_log_P(_mrp[nr] + k, _brecsum[nr] + dt[0], dS += -positive_w_log_P(_mrp[nr] + k,
_wparams[i][0], _wparams[i][1]); _brecsum[nr] + dt[0],
wp[0], wp[1]);
} }
} }
break; break;
...@@ -1457,6 +1450,7 @@ public: ...@@ -1457,6 +1450,7 @@ public:
{ {
for (size_t i = 0; i < _rec_types.size(); ++i) for (size_t i = 0; i < _rec_types.size(); ++i)
{ {
auto& wp = _wparams[i];
switch (_rec_types[i]) switch (_rec_types[i])
{ {
case weight_type::REAL_EXPONENTIAL: case weight_type::REAL_EXPONENTIAL:
...@@ -1464,9 +1458,7 @@ public: ...@@ -1464,9 +1458,7 @@ public:
{ {
auto ers = _mrs[me]; auto ers = _mrs[me];
auto xrs = _brec[me][i]; auto xrs = _brec[me][i];
S += -positive_w_log_P(ers, xrs, S += -positive_w_log_P(ers, xrs, wp[0], wp[1]);
_wparams[i][0],
_wparams[i][1]);
} }
break; break;
case weight_type::DISCRETE_GEOMETRIC: case weight_type::DISCRETE_GEOMETRIC:
...@@ -1474,9 +1466,7 @@ public: ...@@ -1474,9 +1466,7 @@ public:
{ {
auto ers = _mrs[me]; auto ers = _mrs[me];
auto xrs = _brec[me][i]; auto xrs = _brec[me][i];
S += -geometric_w_log_P(ers, xrs, S += -geometric_w_log_P(ers, xrs, wp[0], wp[1]);
_wparams[i][0],
_wparams[i][1]);
} }
break; break;
case weight_type::DISCRETE_POISSON: case weight_type::DISCRETE_POISSON:
...@@ -1484,25 +1474,20 @@ public: ...@@ -1484,25 +1474,20 @@ public:
{ {
auto ers = _mrs[me]; auto ers = _mrs[me];
auto xrs = _brec[me][i]; auto xrs = _brec[me][i];
S += -poisson_w_log_P(ers, xrs, S += -poisson_w_log_P(ers, xrs, wp[0], wp[1]);
_wparams[i][0],
_wparams[i][1]);
} }
for (auto e : edges_range(_g)) for (auto e : edges_range(_g))
S += boost::math::lgamma(_rec[e][i] + 1); S += lgamma(_rec[e][i] + 1);
break; break;
case weight_type::DISCRETE_BINOMIAL: case weight_type::DISCRETE_BINOMIAL:
for (auto me : edges_range(_bg)) for (auto me : edges_range(_bg))
{ {
auto ers = _mrs[me]; auto ers = _mrs[me];
auto xrs = _brec[me][i]; auto xrs = _brec[me][i];
S += -binomial_w_log_P(ers, xrs, S += -binomial_w_log_P(ers, xrs, wp[0], wp[1], wp[2]);
_wparams[i][0],
_wparams[i][1],
_wparams[i][2]);
} }
for (auto e : edges_range(_g)) for (auto e : edges_range(_g))
S -= lbinom(_wparams[i][0], _rec[e][i]); S -= lbinom(wp[0], _rec[e][i]);
break; break;
case weight_type::REAL_NORMAL: case weight_type::REAL_NORMAL:
for (auto me : edges_range(_bg)) for (auto me : edges_range(_bg))
...@@ -1511,21 +1496,16 @@ public: ...@@ -1511,21 +1496,16 @@ public:
auto xrs = _brec[me][i]; auto xrs = _brec[me][i];
auto x2rs = _bdrec[me][i]; auto x2rs = _bdrec[me][i];
auto sigma = x2rs - xrs * (xrs / ers); auto sigma = x2rs - xrs * (xrs / ers);
S += -signed_w_log_P(ers, xrs, sigma, S += -signed_w_log_P(ers, xrs, sigma, wp[0], wp[1],
_wparams[i][0], wp[2], wp[3]);
_wparams[i][1],
_wparams[i][2],
_wparams[i][3]);
} }
break; break;
case weight_type::DELTA_T: // waiting times case weight_type::DELTA_T: // waiting times
for (auto r : vertices_range(_bg)) for (auto r : vertices_range(_bg))
{ {
if (_bignore_degrees[r] > 0) if (_bignore_degrees[r] > 0)
S += -positive_w_log_P(_mrp[r], S += -positive_w_log_P(_mrp[r], _brecsum[r], wp[0],
_brecsum[r], wp[1]);
_wparams[i][0],
_wparams[i][1]);
} }
break; break;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment