aboutsummaryrefslogtreecommitdiff
path: root/src/mathfunc.cpp
diff options
context:
space:
mode:
authorPjotr Prins2020-09-26 11:25:04 +0100
committerPjotr Prins2020-09-26 11:25:04 +0100
commit519c4d005098dec382344514a837d49c164a5372 (patch)
treef68f35311cdf8856b1aade0fdfae256d93e4a4cb /src/mathfunc.cpp
parent7286000660c54c9989f49164ca4800d687b7a315 (diff)
downloadpangemma-519c4d005098dec382344514a837d49c164a5372.tar.gz
Comments added
Diffstat (limited to 'src/mathfunc.cpp')
-rw-r--r--src/mathfunc.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mathfunc.cpp b/src/mathfunc.cpp
index 614da14..9043e00 100644
--- a/src/mathfunc.cpp
+++ b/src/mathfunc.cpp
@@ -169,6 +169,7 @@ void CenterMatrix(gsl_matrix *G) {
}
// Center the matrix G.
+// Only used in vc
void CenterMatrix(gsl_matrix *G, const gsl_vector *w) {
double d, wtw;
gsl_vector *Gw = gsl_vector_safe_alloc(G->size1);
@@ -192,6 +193,7 @@ void CenterMatrix(gsl_matrix *G, const gsl_vector *w) {
}
// Center the matrix G.
+// Only used in vc
void CenterMatrix(gsl_matrix *G, const gsl_matrix *W) {
gsl_matrix *WtW = gsl_matrix_safe_alloc(W->size2, W->size2);
gsl_matrix *WtWi = gsl_matrix_safe_alloc(W->size2, W->size2);
@@ -233,6 +235,7 @@ void CenterMatrix(gsl_matrix *G, const gsl_matrix *W) {
}
// "Standardize" the matrix G such that all diagonal elements = 1.
+// (only used by vc)
void StandardizeMatrix(gsl_matrix *G) {
double d = 0.0;
vector<double> vec_d;
@@ -260,11 +263,13 @@ void StandardizeMatrix(gsl_matrix *G) {
double ScaleMatrix(gsl_matrix *G) {
double d = 0.0;
+ // Compute mean of diagonal
for (size_t i = 0; i < G->size1; ++i) {
d += gsl_matrix_get(G, i, i);
}
d /= (double)G->size1;
+ // Scale the matrix using the diagonal mean
if (d != 0) {
gsl_matrix_scale(G, 1.0 / d);
}