summaryrefslogtreecommitdiff
path: root/src/net_voltages.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2017-01-16 01:31:10 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2017-01-16 01:31:10 -0500
commit1e1fdfc2e3892667bccaf317a01defd8832041c7 (patch)
treecc5ef9adbfe4a8f11744f4b7afd23a37cfdd74d4 /src/net_voltages.c
parent57857b9ebfb2c0a78c2eb1128d3fb4ed8d597ec4 (diff)
downloadfuse_networks-1e1fdfc2e3892667bccaf317a01defd8832041c7.tar.gz
fuse_networks-1e1fdfc2e3892667bccaf317a01defd8832041c7.tar.bz2
fuse_networks-1e1fdfc2e3892667bccaf317a01defd8832041c7.zip
fixed voltage and torus conditions, current and free boundaries and broken right now
Diffstat (limited to 'src/net_voltages.c')
-rw-r--r--src/net_voltages.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/net_voltages.c b/src/net_voltages.c
index dedf5b2..c3537a5 100644
--- a/src/net_voltages.c
+++ b/src/net_voltages.c
@@ -12,11 +12,29 @@ double *net_voltages(const net_t *net, cholmod_common *c) {
exit(EXIT_FAILURE);
}
- double *voltages = (double *)x->x;
+ double *t_voltages = (double *)x->x;
x->x = NULL;
-
CHOL_F(free_dense)(&x, c);
- return voltages;
+ graph_t *g = net->graph;
+
+ if (g->boundary == TORUS_BOUND) {
+ return t_voltages;
+ } else if (net->voltage_bound) {
+ double *voltages = (double *)malloc(g->nv * sizeof(double));
+ for (uint_t i = 0; i < g->nv - g->bi[g->nb]; i++) {
+ voltages[g->nbi[i]] = t_voltages[i];
+ }
+ for (uint_t i = 0; i < 2; i++) {
+ for (uint_t j = 0; j < g->bi[i + 1] - g->bi[i]; j++) {
+ voltages[g->b[g->bi[i] + j]] = 1 - i;
+ }
+ }
+
+ free(t_voltages);
+ return voltages;
+ } else {
+ return t_voltages;
+ }
}