Permalink
Browse files

Compute covariance matrix from feature matrix.

  • Loading branch information...
1 parent 02f4968 commit c76c1ddc545fd21ef19547a8769898bc089d9ed6 @daviddoria committed Jun 14, 2012
Showing with 9 additions and 0 deletions.
  1. +6 −0 EigenHelpers.cpp
  2. +3 −0 EigenHelpers.h
View
@@ -207,6 +207,12 @@ Eigen::MatrixXf ConstructCovarianceMatrixZeroMeanFast(const EigenHelpers::Vector
return covarianceMatrix;
}
+Eigen::MatrixXf ConstructCovarianceMatrixFromFeatureMatrix(const Eigen::MatrixXf& featureMatrix)
+{
+ Eigen::MatrixXf covarianceMatrix = (1.0f / static_cast<float>(featureMatrix.cols())) * featureMatrix * featureMatrix.transpose();
+ return covarianceMatrix;
+}
+
Eigen::MatrixXf ConstructCovarianceMatrixZeroMean(const EigenHelpers::VectorOfVectors& vectors)
{
unsigned int numberOfVectors = vectors.size();
View
@@ -58,6 +58,9 @@ Eigen::VectorXf ComputeMaxVector(const EigenHelpers::VectorOfVectors& vectors);
/** Construct the sample covariance matrix from a collection of vectors. */
Eigen::MatrixXf ConstructCovarianceMatrix(const EigenHelpers::VectorOfVectors& vectors);
+/** Construct the sample covariance matrix from a feature matrix. */
+Eigen::MatrixXf ConstructCovarianceMatrixFromFeatureMatrix(const Eigen::MatrixXf& featureMatrix);
+
/** Construct the sample covariance matrix from a collection of vectors that has already had their mean subtracted. */
Eigen::MatrixXf ConstructCovarianceMatrixZeroMean(const EigenHelpers::VectorOfVectors& vectors);

0 comments on commit c76c1dd

Please sign in to comment.