[FEAT] Add Submatrix

This commit is contained in:
NADAL Jean-Baptiste
2024-02-02 17:41:51 +01:00
parent 7d52592cd5
commit a584bf54d8
3 changed files with 57 additions and 0 deletions

View File

@@ -239,3 +239,41 @@ TEST_CASE("[Matrix] Calculating the determinant of a 2x2 matrix", "[Matrix]")
REQUIRE(a.determinant() == 17);
}
/* ------------------------------------------------------------------------- */
TEST_CASE("[Matrix] A submatrix of a 3x3 matrix is a 2x2 matrix", "[Matrix]")
{
Matrix a = {
{ 1, 5, 0},
{-3, 2, 7},
{ 0, 6, -3}
};
Matrix b = {
{-3, 2},
{ 0, 6}
};
REQUIRE(a.sub_matrix(0, 2) == b);
}
/* ------------------------------------------------------------------------- */
TEST_CASE("[Matrix] A submatrix of a 4x4 matrix is a 3x3 matrix", "[Matrix]")
{
Matrix a = {
{-6, 1, 1, 6},
{-8, 5, 8, 6},
{-1, 0, 8, 2},
{-7, 1, -1, 1}
};
Matrix b = {
{-6, 1, 6},
{-8, 8, 6},
{-7, -1, 1}
};
REQUIRE(a.sub_matrix(2, 1) == b);
}