- optimized determinant calculations for small matrices (size <= 4)

(only 30 muls for size 4)
- rework the matrix inversion: now using cofactor technique for size<=3,
  so the ugly unrolling is only used for size 4 anymore, and even there
  I'm looking to get rid of it.
This commit is contained in:
Benoit Jacob
2008-04-14 17:07:12 +00:00
parent 9789c04467
commit 2a86f052a5
6 changed files with 150 additions and 32 deletions

View File

@@ -392,16 +392,12 @@ Block<Derived> MatrixBase<Derived>
{
case TopLeft:
return Block<Derived>(derived(), 0, 0, cRows, cCols);
break;
case TopRight:
return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
break;
case BottomLeft:
return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
break;
case BottomRight:
return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
break;
default:
ei_assert(false && "Bad corner type.");
}
@@ -416,16 +412,12 @@ const Block<Derived> MatrixBase<Derived>
{
case TopLeft:
return Block<Derived>(derived(), 0, 0, cRows, cCols);
break;
case TopRight:
return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
break;
case BottomLeft:
return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
break;
case BottomRight:
return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
break;
default:
ei_assert(false && "Bad corner type.");
}
@@ -452,16 +444,12 @@ Block<Derived, CRows, CCols> MatrixBase<Derived>
{
case TopLeft:
return Block<Derived, CRows, CCols>(derived(), 0, 0);
break;
case TopRight:
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
break;
case BottomLeft:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
break;
case BottomRight:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
break;
default:
ei_assert(false && "Bad corner type.");
}
@@ -477,16 +465,12 @@ const Block<Derived, CRows, CCols> MatrixBase<Derived>
{
case TopLeft:
return Block<Derived, CRows, CCols>(derived(), 0, 0);
break;
case TopRight:
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
break;
case BottomLeft:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
break;
case BottomRight:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
break;
default:
ei_assert(false && "Bad corner type.");
}

View File

@@ -513,6 +513,7 @@ template<typename Derived> class MatrixBase
//@{
const Inverse<Derived, true> inverse() const;
const Inverse<Derived, false> quickInverse() const;
Scalar determinant() const;
//@}
private: