Skip to content

Commit 20742a8

Browse files
committed
prim test for singular
1 parent a8b1287 commit 20742a8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/unit/math/prim/fun/generalized_inverse_test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ TEST(MathMatrixPrim, Zero) {
99
EXPECT_EQ(0, ginv.cols());
1010
}
1111

12+
TEST(MathMatrixPrim, Singular) {
13+
using stan::math::generalized_inverse;
14+
15+
stan::math::matrix_d m1(2, 3);
16+
m1 << 1, 2, 1, 2, 4, 2;
17+
18+
stan::math::matrix_d m2 = m1 * generalized_inverse(m1) * m1;
19+
EXPECT_MATRIX_NEAR(m1, m2, 1e-9);
20+
}
21+
1222
TEST(MathMatrixPrim, Equal1) {
1323
using stan::math::generalized_inverse;
1424

0 commit comments

Comments
 (0)