mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 08:55:37 +00:00
corr to var and SVD dynamic range
This commit is contained in:
parent
0de8091f3c
commit
857a8e59c9
@ -29,7 +29,8 @@ using namespace Latan;
|
||||
******************************************************************************/
|
||||
DMat MATH_NAMESPACE::varToCorr(const DMat &var)
|
||||
{
|
||||
DMat res = var, invDiag = res.diagonal();
|
||||
DMat res = var;
|
||||
DVec invDiag = res.diagonal();
|
||||
|
||||
invDiag = invDiag.cwiseInverse().cwiseSqrt();
|
||||
res = (invDiag*invDiag.transpose()).cwiseProduct(res);
|
||||
@ -37,6 +38,28 @@ DMat MATH_NAMESPACE::varToCorr(const DMat &var)
|
||||
return res;
|
||||
}
|
||||
|
||||
DMat MATH_NAMESPACE::corrToVar(const DMat &corr, const DVec &varDiag)
|
||||
{
|
||||
DMat res = corr;
|
||||
DVec varSqrtDiag = varDiag.cwiseSqrt();
|
||||
|
||||
res = (varSqrtDiag*varSqrtDiag.transpose()).cwiseProduct(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
double MATH_NAMESPACE::svdDynamicRange(const DMat &mat)
|
||||
{
|
||||
DVec s = mat.singularValues();
|
||||
|
||||
return s.maxCoeff()/s.minCoeff();
|
||||
}
|
||||
|
||||
double MATH_NAMESPACE::svdDynamicRangeDb(const DMat &mat)
|
||||
{
|
||||
return 10.*log10(svdDynamicRange(mat));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Standard C functions *
|
||||
******************************************************************************/
|
||||
|
@ -70,6 +70,11 @@ namespace MATH_NAMESPACE
|
||||
|
||||
// convert variance matrix to correlation matrix
|
||||
DMat varToCorr(const DMat &var);
|
||||
DMat corrToVar(const DMat &corr, const DVec &varDiag);
|
||||
|
||||
// matrix SVD dynamic range
|
||||
double svdDynamicRange(const DMat &mat);
|
||||
double svdDynamicRangeDb(const DMat &mat);
|
||||
|
||||
// Constants
|
||||
constexpr double pi = 3.1415926535897932384626433832795028841970;
|
||||
|
Loading…
Reference in New Issue
Block a user