本文整理汇总了C++中math::Matrix::Inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::Inverse方法的具体用法?C++ Matrix::Inverse怎么用?C++ Matrix::Inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Matrix
的用法示例。
在下文中一共展示了Matrix::Inverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(MatrixTest, InverseTest)
{
const Math::Matrix mat1(
{
{ -2.2829352811514658f, -0.9103222363187888f, 0.2792976509411680f, -0.7984393573193174f },
{ 2.4823665798689589f, -0.0599056759070980f, 0.3832364352926366f, -1.6404257204372739f },
{ -0.3841952272526398f, -0.8377700696457873f, -0.3416328338427138f, 1.1746577275723329f },
{ 0.1746031241954947f, -0.4952532117949962f, 0.2155084379835037f, -1.6586460437329220f }
}
);
const Math::Matrix expectedInverse1(
{
{ -0.119472603171041f, 0.331675963276297f, 0.187516809009720f, -0.137720814290806f },
{ -0.387591686166085f, -0.487284946727583f, -0.798527541290274f, 0.102991635972060f },
{ 2.601905603425902f, 2.606899016264679f, -0.528006148839176f, -4.204703326522837f },
{ 0.441220327151392f, 0.519128136207318f, 0.189567009205522f, -1.194469716136194f }
}
);
Math::Matrix inverse1 = mat1.Inverse();
EXPECT_TRUE(Math::MatricesEqual(inverse1, expectedInverse1, TEST_TOLERANCE));
const Math::Matrix mat2(
{
{ -0.05464332404298505f, -0.64357755258235749f, -0.13017671677619302f, -0.56742332785888006f },
{ 0.29048383600458222f, -0.91517047043724875f, 0.84517524415561684f, 0.51628195547960565f },
{ 0.00946488004480186f, -0.89077382212689293f, 0.73565573766341397f, -0.15932513521840930f },
{ -1.01244718912499132f, -0.27840911963972276f, -0.39189681211309862f, 1.18315064340192055f }
}
);
const Math::Matrix expectedInverse2(
{
{ 0.771302711132012f, 1.587542278361995f, -2.003075114445104f, -0.592574156227379f },
{ -1.208929259769431f, -0.786598967848473f, 0.607335305808052f, -0.154759693303324f },
{ -1.500037668208218f, -0.774300278997914f, 1.917800427261255f, -0.123268572651291f },
{ -0.121314770937944f, 0.916925149209746f, -0.935924950785014f, 0.260875394250671f }
}
);
Math::Matrix inverse2 = mat2.Inverse();
EXPECT_TRUE(Math::MatricesEqual(inverse2, expectedInverse2, TEST_TOLERANCE));
}