Skip to content

Commit 396a8f2

Browse files
author
allywarner
committed
Passing test!
1 parent 7362163 commit 396a8f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Core/Algorithms/Math/Tests/ComputePCAtest.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29+
//ComputePCA algorithm test.
2930
#include <gtest/gtest.h>
3031
#include <Core/Datatypes/DenseMatrix.h>
3132
#include <Core/Datatypes/MatrixComparison.h>
@@ -121,12 +122,14 @@ TEST(ComputePCAtest, checkOutputs)
121122
ASSERT_EQ(1,PrinVals_S->cols());
122123
ASSERT_EQ(2,RightPrinMat_V->cols());
123124

125+
126+
124127
//Eigen does not create a diagonal matrix when it computes SVD, it just has a column with the principal values, so we must put it into a diagonal matrix to be able to do some matrix multiplication later.
125128
DenseMatrix sDiag = Eigen::MatrixXd::Constant(12,2,0);
126129
sDiag.diagonal() = PrinVals_S->col(0);
127130

128131
//Multiplying back together and comparing to the centered matrix. They should be equal to each other with some tolerance.
129-
auto product = (*LeftPrinMat_U) * sDiag * (*RightPrinMat_V).transpose();
132+
DenseMatrix product = (*LeftPrinMat_U) * sDiag * (*RightPrinMat_V).transpose();
130133

131134
auto expected = *centeredInputMatrix();
132135

0 commit comments

Comments
 (0)