The committed files are a fully functioning implementation of the Karhunen–Loève transform (KLT) as defined on Wikipedia, and verified using multiple languages - Python, R and MATLAB. Note. It may be common for libraries to call this algorithm 'covariance', 'eig' or similar to distiguish from the SVD alogrithm or otherwise. The source code is built entirely on the GNU GSL (2.7) library, to utilise BLAS optimised functionality.
25 lines
421 B
C
25 lines
421 B
C
#include <gsl/gsl_matrix.h>
|
|
#include <gsl/gsl_vector.h>
|
|
|
|
|
|
#ifndef PCA_H
|
|
#define PCA_H
|
|
|
|
#define PCA_AUTO_ALGORITHM -1
|
|
#define PCA_KLT_ALGORITHM 1
|
|
#define PCA_SVD_ALGORITHM 2
|
|
#define PCA_ALS_ALGORITHM 3
|
|
|
|
#define PCA_CE_MAGIC -1
|
|
|
|
int
|
|
pca (gsl_matrix *A, int nc, int algorithm, gsl_matrix *m);
|
|
|
|
int
|
|
_klt (gsl_matrix *A, gsl_vector *eval, gsl_matrix *m);
|
|
|
|
int
|
|
_internal_eigen_sign_correction (gsl_matrix *evec);
|
|
|
|
#endif
|