Skip to content
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

Merged

Conversation

atrayees
Copy link
Contributor

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

@@ -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) {
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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);
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz use mat.getCoefficients()

@atrayees atrayees closed this Jul 19, 2024
@atrayees atrayees force-pushed the feature/symmetric-correlation-matrix branch from 1d9e8c6 to 7a0be2d Compare July 19, 2024 07:48
@atrayees atrayees reopened this Jul 19, 2024
@atrayees atrayees requested a review from TolisChal July 19, 2024 13:56
const unsigned int &walkL,
const unsigned int &num_points,
const NT &a,
unsigned int const& nburns = 0){
using PointList = std::vector<PointType>;
Copy link
Member

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<>

Copy link
Contributor Author

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>;
Copy link
Member

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>;
Copy link
Member

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){
Copy link
Member

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

Copy link
Contributor Author

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

@TolisChal TolisChal merged commit c2504a5 into GeomScale:develop Jul 22, 2024
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants