本文整理汇总了C++中math::Matrix::Cofactor方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::Cofactor方法的具体用法?C++ Matrix::Cofactor怎么用?C++ Matrix::Cofactor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Matrix
的用法示例。
在下文中一共展示了Matrix::Cofactor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(MatrixTest, CofactorTest)
{
const Math::Matrix mat1(
{
{ 0.610630320796245f, 1.059932357918312f, -1.581674311378210f, 1.782214448453331f },
{ 0.191028848211526f, -0.813898708757524f, 1.516114203870644f, 0.395202639476002f },
{ 0.335142750345279f, -0.346586619596529f, 0.545382042472336f, -0.879268918923072f },
{ 1.417588151657198f, 1.450841789070141f, 0.219080104196171f, 0.378724047481655f }
}
);
const Math::Matrix expectedCofactors1(
{
{ -2.402679369186782f, 2.282452509293019f, 1.722732204057644f, -0.746939701104385f },
{ -0.687677756877654f, 1.168949180331164f, -0.985354966837796f, -1.334071111592705f },
{ -5.115621958424845f, 4.229724770159009f, 2.529000630782808f, 1.481632618355891f },
{ 0.147480897398694f, -2.140677680337111f, -1.207189492265546f, 0.151236920408051f }
}
);
for (int r = 0; r < 4; ++r)
{
for (int c = 0; c < 4; ++c)
{
float ret = mat1.Cofactor(r, c);
float exp = expectedCofactors1.m[4*c+r];
EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
}
}
const Math::Matrix mat2(
{
{ 0.9845099464982393f, -0.9091233416532389f, -0.6272243714245945f, 0.4645001858944354f },
{ -0.1333308471483736f, 0.9128181433725897f, -1.0937461393836190f, 0.3180936795928376f },
{ -0.0654324396846289f, 0.1014641705415945f, 1.5107709042683430f, -0.0240560430414690f },
{ 0.0179638644093347f, -1.0695585982782767f, -0.1741250853101032f, 1.0803106709464336f }
}
);
const Math::Matrix expectedCofactors2(
{
{ 2.0861102207614466f, 0.2989010779528912f, 0.0746276150537432f, 0.2732659822656097f },
{ 0.6850002886584565f, 1.5513169659641379f, -0.0503743176545917f, 1.5163672441575642f },
{ 1.2385556680997216f, 1.1827709562505695f, 1.2282813085138962f, 1.3483789679871401f },
{ -1.0710790241539783f, -0.5589604503588883f, 0.0100959837872308f, 1.1897872684455839f }
}
);
for (int r = 0; r < 4; ++r)
{
for (int c = 0; c < 4; ++c)
{
float ret = mat2.Cofactor(r, c);
float exp = expectedCofactors2.m[4*c+r];
EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
}
}
}