[FEAT] Matrix: Add cofactor

This commit is contained in:
NADAL Jean-Baptiste
2024-02-02 18:17:27 +01:00
parent f2a7ce738e
commit 47400a4d14
3 changed files with 38 additions and 7 deletions

View File

@@ -294,3 +294,19 @@ TEST_CASE("[Matrix] Calculating a minor of a 3x3 matrix", "[Matrix]")
REQUIRE(a.minor(1, 0) == 25);
}
/* ------------------------------------------------------------------------- */
TEST_CASE("[Matrix] Calculating a cofactor of a 3x3 matrix", "[Matrix]")
{
Matrix a = {
{3, 5, 0},
{2, -1, -7},
{6, -1, 5}
};
REQUIRE(a.minor(0, 0) == -12.0);
REQUIRE(a.cofactor(0, 0) == -12.0);
REQUIRE(a.minor(1, 0) == 25.0);
REQUIRE(a.cofactor(1, 0) == -25.0);
}