Skip to content

Commit ccf5b01

Browse files
authored
move getCoefficients() to include/sampling/sample_correlation_matrices
1 parent 22111fc commit ccf5b01

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/sampling/sample_correlation_matrices.hpp

+15
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414

1515
#include <sampling/sampling.hpp>
1616

17+
template<typename NT, typename MT>
18+
Eigen::Matrix<NT, Eigen::Dynamic, 1> getCoefficientsFromMatrix(const MT& mat) {
19+
int n = mat.rows();
20+
int d = n * (n - 1) / 2;
21+
Eigen::Matrix<NT, Eigen::Dynamic, 1> coeffs(d);
22+
int k = 0;
23+
for (int i = 0; i < n; ++i) {
24+
for (int j = 0; j < i; ++j) {
25+
coeffs(k) = mat(i, j);
26+
++k;
27+
}
28+
}
29+
return coeffs;
30+
}
31+
1732
// New implementations for sampling correlation matrices with CorrelationSpectrahedron and CorrelationSpectrahedron_MT
1833

1934
template

0 commit comments

Comments
 (0)