-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/symmetric correlation matrix #321
Feature/symmetric correlation matrix #321
Conversation
@@ -36,6 +36,21 @@ MT rebuildMatrix(const VT &xvector, const unsigned int n){ | |||
return mat; | |||
} | |||
|
|||
template<typename NT, typename MT> | |||
Eigen::Matrix<NT, Eigen::Dynamic, 1> getCoefficientsFromMatrix(const MT& mat) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this function? Notice that the class CorreMatrix
includes this representation. Look at the member function getCoefficients()
.
However, it's not clear why this function is needed. Can you comment on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here in the uniform_correlation_sampling_MT() function
for(const auto&p : randPoints){
MT final_cor_mat = p.mat + p.mat.transpose() - MT::Identity(n, n);
randCorMatrices.push_back(final_cor_mat);
}
p.mat, etc. return type MT, so I'm actually storing MT and not CorreMatrix in std::list<MT> randCorMatrices
.
but getCoefficients() is a member function of the CorreMatrix class, so in the testing function in the loop
for(const auto& mat : randCorMatrices){
samples.col(jj) = getCoefficientsFromMatrix<NT, MT>(mat);
jj++;
}
since every member of randCorMatrices is MT, I couldn't call the getCoefficients() function which is why I wrote the separate function to get the coefficients
I thought we need this loop for populating the samples variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ic, then let's keep it in the test folder
Eigen::LDLT<MT> A_ldlt; | ||
for(auto& mat : randCorMatrices){ | ||
auto coeffs = getCoefficientsFromMatrix<NT, MT>(mat); | ||
A = rebuildMatrix<NT, MT>(coeffs, n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A should be equal to mat here, isn't it?
I don't see any reason for getCoefficientsFromMatrix()
and rebuildMatrix()
since you want to check if mat
is positive definite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm sorry that was a mistake i'll delete the two lines
MT samples(d, num_points); | ||
unsigned int jj = 0; | ||
for(const auto& mat : randCorMatrices){ | ||
samples.col(jj) = getCoefficientsFromMatrix<NT, MT>(mat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz use mat.getCoefficients()
1d9e8c6
to
7a0be2d
Compare
const unsigned int &walkL, | ||
const unsigned int &num_points, | ||
const NT &a, | ||
unsigned int const& nburns = 0){ | ||
using PointList = std::vector<PointType>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a std::list<>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
const unsigned int &walkL, | ||
const unsigned int &num_points, | ||
unsigned int const& nburns){ | ||
using PointList = std::vector<PointType>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a std::list<>
const unsigned int &walkL, | ||
const unsigned int &num_points, | ||
const VT &c, | ||
const NT &T, | ||
unsigned int const& nburns = 0){ | ||
using PointList = std::vector<PointType>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a std::list<>
@@ -64,6 +79,33 @@ void check_output(PointList &randPoints, int num_points, int n){ | |||
CHECK(score.maxCoeff() < 1.1); | |||
} | |||
|
|||
template<typename NT, typename VT, typename MT> | |||
void check_output_MT(std::list<MT> &randCorMatrices, int num_points, int n){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz fix indentation in this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really sorry for overlooking this. i fixed it
modified the
uniform_correlation_sampling_MT()
function to make the correlation matrix symmetric- in the process, I also modified some functions in test/sampling_correlation_matrices_test.cpp