Determinant calculation with SIMD

Is there an approach for calculating the determinant of small-sized matrices (about 4) that works well with SIMD (neon, SSE, SSE2)? I use a hand extension formula that doesn't work so well. I use SSE before SSE3 and neon, as under Linux. Matrix elements are all floats.

+4
source share
1 answer

Here are my 5 cents.

2x2 matrix determinant:

that the exercise for the reader should be easy to implement

3x3 matrix determinant:

use a scalar three-dimensional product. This will require intelligent implementations of cross()and dot(). Recipes for them are widely available.

4x4 matrix determinant:

. :

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);
}

5x5 +:

.

+2

All Articles