summaryrefslogtreecommitdiff
path: root/lib/src/network.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-01-24 19:01:18 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-01-24 19:01:18 -0500
commite3b663588a30ec4f05afe50c260982bd44a1bb2b (patch)
tree0563b21d7a25a7bb99e906abf1ad1f63afb0e335 /lib/src/network.cpp
parentc83636a1b56b331cf4ea16450dcf637e6e9fae8a (diff)
downloadfuse_networks-e3b663588a30ec4f05afe50c260982bd44a1bb2b.tar.gz
fuse_networks-e3b663588a30ec4f05afe50c260982bd44a1bb2b.tar.bz2
fuse_networks-e3b663588a30ec4f05afe50c260982bd44a1bb2b.zip
style changes
Diffstat (limited to 'lib/src/network.cpp')
-rw-r--r--lib/src/network.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/src/network.cpp b/lib/src/network.cpp
index 3812f43..027946a 100644
--- a/lib/src/network.cpp
+++ b/lib/src/network.cpp
@@ -3,7 +3,7 @@
network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.size(), false), thresholds(G.edges.size(), 1) {
b = CHOL_F(zeros)(G.vertices.size(), 1, CHOLMOD_REAL, c);
- for (unsigned int i = 0; i < G.edges.size(); i++) {
+ for (unsigned i = 0; i < G.edges.size(); i++) {
double v0y = G.vertices[G.edges[i].v[0]].r.y;
double v1y = G.vertices[G.edges[i].v[1]].r.y;
@@ -15,29 +15,29 @@ network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.
}
}
- unsigned int nnz = G.vertices.size() + G.edges.size();
+ unsigned nnz = G.vertices.size() + G.edges.size();
cholmod_triplet *t = CHOL_F(allocate_triplet)(G.vertices.size(), G.vertices.size(), nnz, 1, CHOLMOD_REAL, c);
- for (unsigned int i = 0; i < G.vertices.size(); i++) {
+ for (unsigned i = 0; i < G.vertices.size(); i++) {
((CHOL_INT *)t->i)[i] = i;
((CHOL_INT *)t->j)[i] = i;
((double *)t->x)[i] = 0.0;
}
- unsigned int terms = G.vertices.size();
+ unsigned terms = G.vertices.size();
- std::unordered_map<std::array<unsigned int, 2>, unsigned int> known_edges;
+ std::unordered_map<std::array<unsigned, 2>, unsigned> known_edges;
- for (unsigned int i = 0; i < G.edges.size(); i++) {
- unsigned int v0 = G.edges[i].v[0];
- unsigned int v1 = G.edges[i].v[1];
+ for (unsigned i = 0; i < G.edges.size(); i++) {
+ unsigned v0 = G.edges[i].v[0];
+ unsigned v1 = G.edges[i].v[1];
((double *)t->x)[v0]++;
((double *)t->x)[v1]++;
- unsigned int s0 = v0 < v1 ? v0 : v1;
- unsigned int s1 = v0 < v1 ? v1 : v0;
+ unsigned s0 = v0 < v1 ? v0 : v1;
+ unsigned s1 = v0 < v1 ? v1 : v0;
auto it = known_edges.find({s0, s1});
@@ -67,7 +67,7 @@ network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.
t->nnz = 2 * G.edges.size();
- for (unsigned int i = 0; i < G.edges.size(); i++) {
+ for (unsigned i = 0; i < G.edges.size(); i++) {
((CHOL_INT *)t->i)[2 * i] = i;
((CHOL_INT *)t->j)[2 * i] = G.edges[i].v[0];
((double *)t->x)[2 * i] = 1.0;
@@ -106,16 +106,16 @@ void network::set_thresholds(double beta, std::mt19937& rng) {
}
}
-void network::break_edge(unsigned int e, bool unbreak) {
+void network::break_edge(unsigned e, bool unbreak) {
fuses[e] = !unbreak;
- unsigned int v0 = G.edges[e].v[0];
- unsigned int v1 = G.edges[e].v[1];
+ unsigned v0 = G.edges[e].v[0];
+ unsigned v1 = G.edges[e].v[1];
- unsigned int n = factor->n;
+ unsigned n = factor->n;
cholmod_sparse *update_mat = CHOL_F(allocate_sparse)(n, n, 2, true, true, 0, CHOLMOD_REAL, c);
- unsigned int s1, s2;
+ unsigned s1, s2;
s1 = v0 < v1 ? v0 : v1;
s2 = v0 < v1 ? v1 : v0;
@@ -123,11 +123,11 @@ void network::break_edge(unsigned int e, bool unbreak) {
CHOL_INT *ii = (CHOL_INT *)update_mat->i;
double *xx = (double *)update_mat->x;
- for (unsigned int i = 0; i <= s1; i++) {
+ for (unsigned i = 0; i <= s1; i++) {
pp[i] = 0;
}
- for (unsigned int i = s1 + 1; i <= n; i++) {
+ for (unsigned i = s1 + 1; i <= n; i++) {
pp[i] = 2;
}
@@ -210,10 +210,10 @@ void network::fracture(hooks& m, double cutoff) {
break;
}
- unsigned int max_pos = UINT_MAX;
+ unsigned max_pos = UINT_MAX;
long double max_val = std::numeric_limits<long double>::lowest();
- for (unsigned int i = 0; i < G.edges.size(); i++) {
+ for (unsigned i = 0; i < G.edges.size(); i++) {
if (!fuses[i] && fabs(ci.currents[i]) > cutoff) {
long double val = logl(fabs(ci.currents[i])) - thresholds[i];
if (val > max_val) {