1 #ifndef GL_POSITIONS_FROM_LAPLACIAN_HPP
2 #define GL_POSITIONS_FROM_LAPLACIAN_HPP
4 #include "../structures/Graph.hpp"
11 #ifndef DOXYGEN_SHOULD_SKIP_THIS
15 extern "C" void sgeev_(
16 const char &,
const char &,
const int &,
float *,
17 const int &,
float *,
float *,
float *,
const int &,
18 float *,
const int &,
float *,
const int &,
int *);
26 std::pair<std::vector<float>, std::vector<float>>
PositionsFromLaplacian(std::vector<float> laplacian,
double factor = 5.0)
28 int N = std::sqrt(laplacian.size());
32 float eigenvectorsL[NN];
33 float eigenvectorsR[NN];
37 for (
int i = 0; i < NN; i++)
39 data[i] = laplacian.data()[i];
41 sgeev_(
'V',
'N', N, data, N, wr, wi, eigenvectorsR, N, eigenvectorsL, N, work, NN, &info);
42 GL_ASSERT(info == 0,
"BLAS call was not correct, got " + std::to_string(info) +
" instead of 0.");
43 std::vector<float> ev1(N);
44 std::vector<float> ev2(N);
46 for (
int i = 0; i < N; i++)
48 ev1[i] = eigenvectorsR[i * N] * (1 + laplacian[N * i + i]) * factor;
49 ev2[i] = eigenvectorsR[i * N + 1] * (1 + laplacian[N * i + i]) * factor;
51 return std::make_pair(ev1, ev2);
57 #endif // GL_POSITIONS_FROM_LAPLACIAN_HPP
std::pair< std::vector< float >, std::vector< float > > PositionsFromLaplacian(std::vector< float > laplacian, double factor=5.0)
Compute Positions from Laplacian using BLAS routine.
Definition: PositionsFromLaplacian.hpp:26
#define GL_ASSERT(EXPR, ERROR_MSG)
Custom assert that supports attaching a message.
Definition: gl_assert.hpp:14