Skip to content
Snippets Groups Projects
Commit a29e5290 authored by Matthew Webster's avatar Matthew Webster
Browse files

removed redundant calc_corr

parent 96143800
No related branches found
No related tags found
No related merge requests found
......@@ -211,53 +211,6 @@ namespace Melodic{
return out;
}
Matrix calc_corr(const Matrix& in, const Matrix& weights, int econ)
{
Matrix Res;
int nrows=in.Nrows();
int ncols=in.Ncols();
Res = zeros(nrows,nrows);
RowVector localweights;
if(weights.Storage() == 0)
localweights = ones(1,ncols);
else
localweights = weights;
if(econ>0){
RowVector colmeans(ncols);
for (int n=1; n<=ncols; n++) {
colmeans(n)=0;
for (int m=1; m<=nrows; m++) {
colmeans(n)+=in(m,n);
}
colmeans(n)/=nrows;
}
int dcol = econ;
Matrix suba;
for(int ctr=1; ctr <= in.Ncols(); ctr+=dcol){
suba=in.SubMatrix(1,nrows,ctr,Min(ctr+dcol-1,ncols));
int scolmax = suba.Ncols();
for (int n=1; n<=scolmax; n++) {
double cmean=colmeans(ctr + n - 1);
double locw =localweights(ctr + n - 1);
for (int m=1; m<=nrows; m++) {
suba(m,n)-=cmean;
suba(m,n)*= locw;
}
}
Res += suba*suba.t() / ncols;
}
}
else{
Res = SP2(in,localweights);
Res = cov_r(Res,false,econ);
}
return Res;
} //Matrix calc_corr
float calc_white(const Matrix& tmpE, const RowVector& tmpD, const RowVector& PercEV, int dim, Matrix& param, Matrix& paramS, Matrix& white, Matrix& dewhite)
{
......@@ -335,7 +288,7 @@ namespace Melodic{
tmp2 = calc_white(tmpE,tmpD, tmp, dim, param, paramS, white, dewhite);
} //Matrix calc_white
void calc_white(const SymmetricMatrix& Corr, int dim, Matrix& white, Matrix& dewhite)
void calc_white(const SymmetricMatrix& Corr, int dim, Matrix& white, Matrix& dewhite)
{
Matrix RE;
DiagonalMatrix RD;
......@@ -349,9 +302,10 @@ namespace Melodic{
void std_pca(const Matrix& Mat, const Matrix& weights, SymmetricMatrix& Corr, Matrix& evecs, RowVector& evals, int econ)
{
if(weights.Storage()>0)
Corr << calc_corr(Mat, weights, econ);
Corr = cov_r(Mat, weights, econ);
else
Corr = cov_r(Mat,false,econ);
DiagonalMatrix tmpD;
EigenValues(Corr,tmpD,evecs);
evals = tmpD.AsRow();
......
......@@ -56,8 +56,6 @@ namespace Melodic{
Matrix corrcoef(const Matrix& in1, const Matrix& in2);
Matrix corrcoef(const Matrix& in1, const Matrix& in2, const Matrix& part);
Matrix calc_corr(const Matrix& in, const Matrix& weights, int econ = 20000);
float calc_white(const Matrix& tmpE, const RowVector& tmpD, const RowVector& PercEV, int dim, Matrix& param, Matrix& paramS, Matrix& white, Matrix& dewhite);
float calc_white(const Matrix& tmpE, const RowVector& tmpD, const RowVector& PercEV, int dim, Matrix& white, Matrix& dewhite);
void calc_white(const Matrix& tmpE, const RowVector& tmpD, int dim, Matrix& param, Matrix& paramS, Matrix& white, Matrix& dewhite);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment