determinant calculation with SIMD

▼魔方 西西 提交于 2019-12-05 17:18:38

Here's my 5 cents.

determinant of a 2x2 matrix:

that's an exercise for the reader, should be simple to implement

determinant of a 3x3 matrix:

use the scalar triple product. This will require smart cross() and dot() implementations. The recipes for these are widely available.

determinant of a 4x4 matrix:

Use one of the tricks in here. My code:

template <class T>
inline T det(matrix<T, 4, 4> const& m) noexcept
{
  auto const A(make_matrix<T, 2, 2>(m(0, 0), m(0, 1), m(1, 0), m(1, 1)));
  auto const B(make_matrix<T, 2, 2>(m(0, 2), m(0, 3), m(1, 2), m(1, 3)));
  auto const C(make_matrix<T, 2, 2>(m(2, 0), m(2, 1), m(3, 0), m(3, 1)));
  auto const D(make_matrix<T, 2, 2>(m(2, 2), m(2, 3), m(3, 2), m(3, 3)));

  return det(A - B * inv(D) * C) * det(D);
}

determinant of a 5x5+ matrix:

probably use the tricks above.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!