-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindpaths_cpp.cpp
More file actions
36 lines (35 loc) · 1.12 KB
/
Copy pathfindpaths_cpp.cpp
File metadata and controls
36 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "bct_test.h"
DEFUN_DLD(findpaths_cpp, args, , "Wrapper for C++ function.") {
if (args.length() != 3) {
return octave_value_list();
}
Matrix CIJ = args(0).matrix_value();
Matrix sources = args(1).matrix_value();
int qmax = args(2).int_value();
if (!error_state) {
gsl_matrix* CIJ_gsl = bct_test::to_gslm(CIJ);
gsl_vector* sources_gsl = bct_test::to_gslv(sources);
gsl_vector_add_constant(sources_gsl, -1.0);
gsl_vector* plq;
int qstop;
gsl_matrix* allpths;
gsl_matrix* util;
std::vector<gsl_matrix*> Pq = bct::findpaths(CIJ_gsl, sources_gsl, qmax, &plq, &qstop, &allpths, &util);
gsl_matrix_add_constant(allpths, 1.0);
octave_value_list ret;
ret(0) = octave_value(bct_test::from_gsl(Pq, 1));
ret(1) = octave_value(bct_test::from_gsl(plq, 1));
ret(2) = octave_value(qstop);
ret(3) = octave_value(bct_test::from_gsl(allpths));
ret(4) = octave_value(bct_test::from_gsl(util, 0, 1));
gsl_matrix_free(CIJ_gsl);
gsl_vector_free(sources_gsl);
gsl_vector_free(plq);
gsl_matrix_free(allpths);
gsl_matrix_free(util);
bct::gsl_free(Pq);
return ret;
} else {
return octave_value_list();
}
}