From 519c4d005098dec382344514a837d49c164a5372 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 26 Sep 2020 11:25:04 +0100 Subject: Comments added --- src/mathfunc.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/mathfunc.cpp') 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 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); } -- cgit v1.2.3