BBolosSierra / InfoCoRe

0 stars 0 forks source link

Function for renormalising graph #2

Open BBolosSierra opened 8 months ago

BBolosSierra commented 8 months ago

Renormalising graph with the transition tau.

cmclean5 commented 8 months ago

for (size_t i = 0; i < rho.n_rows; ++i) { for (size_t j = 0; j < rho.n_cols; ++j) {

  rho_tmp = rho(i, j)/std::min(rho(i, i), rho(j, j));
  if (rho_tmp - 1  >= 0){
    adj2(i, j) = 1;
  } else if (rho_tmp - 1 < 0){
    adj2(i, j) = 0;
  }
}

}


// Perform the logic from code arma::uword i,j; int N = x.n_rows; double rho_temp, rho_ii, rho_jj;

arma::mat L1 = x; // Use the input matrix directly arma::mat rho = expmat(-tau * L1); double tr = arma::trace(rho); rho = rho / tr;

arma::mat adj2(N,N, fill::zeros);

for(i = 0; i < N; ++i) { rho_ii = rho.at(i,i);
for(j = 0; j < N; ++j) { rho_jj = rho.at(j,j); rho_tmp = rho.at(i, j)/std::min(rho_ii, rho_jj); if (rho_tmp - 1 >= 0){ adj2.at(i, j) = 1; }
} }

Not tested, for some reason I use ".at(i,j)" notation to get and assign elements to matrix.

BBolosSierra commented 8 months ago

[like] Begoña Bolos reacted to your message:


From: colin mclean @.> Sent: Monday, December 18, 2023 2:06:09 PM To: BBolosSierra/InfoCoRe @.> Cc: Begoña Bolos @.>; Author @.> Subject: Re: [BBolosSierra/InfoCoRe] Function for renormalising graph (Issue #2)

This email was sent to you by someone outside the University. You should only click on links or attachments if you are certain that the email is genuine and the content is safe.

for (size_t i = 0; i < rho.n_rows; ++i) { for (size_t j = 0; j < rho.n_cols; ++j) {

rho_tmp = rho(i, j)/std::min(rho(i, i), rho(j, j)); if (rho_tmp - 1 >= 0){ adj2(i, j) = 1; } else if (rho_tmp - 1 < 0){ adj2(i, j) = 0; } }

}

int i, N = rho.n_rows; double rho_temp, rho_ii, rho_jj; mat adj2(N, N); adj2.zeros(); for(i = 0; i < N; ++i) { rho_ii = rho.at(i,i); for(j = 0; j < N; ++j) { rho_jj = rho.at(j,j); rho_tmp = rho.at(i, j)/std::min(rho_ii, rho_jj); if (rho_tmp - 1 >= 0){ adj2.at(i, j) = 1; } } } Not tested, but for some reason I use ".at(i,j)" notation to get and assign elements to matrix.

— Reply to this email directly, view it on GitHubhttps://github.com/BBolosSierra/InfoCoRe/issues/2#issuecomment-1860592725, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BBB74D5YKOIVNXVEHB3JB3LYKBEVDAVCNFSM6AAAAABATHBPTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRQGU4TENZSGU. You are receiving this because you authored the thread.Message ID: @.***>

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th’ ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336.