summaryrefslogtreecommitdiff
path: root/src/net_voltages.c
blob: dedf5b2768510bd6daadb7fc261041fa1803c5b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#include "fracture.h"

double *net_voltages(const net_t *net, cholmod_common *c) {
	cholmod_dense *b = net->boundary_cond;
	cholmod_factor *factor = net->factor;

	cholmod_dense *x = CHOL_F(solve)(CHOLMOD_A, factor, b, c);

	if (((double *)x->x)[0] != ((double *)x->x)[0]) {
		printf("GET_VOLTAGE: value is NaN\n");
		exit(EXIT_FAILURE);
	}

	double *voltages = (double *)x->x;
	x->x = NULL;

	CHOL_F(free_dense)(&x, c);

	return voltages;
}