Determinant of a binary matrix I'm looking for the best and fastest way to do a determinant, for determinants until 15x15.

int Determinant(const vector&lt;vector&lt;int&gt; &gt; &amp;a,int n)
{
   int i,j,j1,j2;
   int det = 0;
   vector&lt;vector&lt;int&gt; &gt; m(n, vector&lt;int&gt;(n));

    if (n == 1) { /* Shouldn't get used */
      det = a[0][0];
   } else if (n == 2) {
      det = a[0][0] * a[1][1] - a[1][0] * a[0][1];
   } else {
      det = 0;
      for (j1=0;j1&lt;n;j1++) 
      {
         for (i=1;i&lt;n;i++) 
         {
            j2 = 0;
            for (j=0;j&lt;n;j++) 
            {
               if (j == j1)
                  continue;
               m[i-1][j2] = a[i][j];
               j2++;
            }
         }
         det += pot(-1,1+j1+1) * a[0][j1] * Determinant(m,n-1);
      }
   }
   det = abs(det)%2;
   return det;
}
Unless this is a homework assignment, you should probably not be writing your own linear algebra routines, but rely on libraries instead. Not only is it very hard to write correct and efficient general-purpose algorithms, for numerical algorithms there is an added requirement of numerical stability. For those reasons it is best to use established libraries such as Eigen. 

A determinant can be done using the example in the documentation

#include &lt;iostream&gt;
#include &lt;Eigen/Dense&gt;
using namespace std;
using namespace Eigen;
int main()
{
    Matrix3f A;
    A &lt;&lt; 1, 2, 1,
         2, 1, 0,
        -1, 1, 2;
    cout &lt;&lt; "Here is the matrix A:\n" &lt;&lt; A &lt;&lt; endl;
    cout &lt;&lt; "The determinant of A is " &lt;&lt; A.determinant() &lt;&lt; endl;
}


Output

Here is the matrix A:
1 2 1
2 1 0
-1 1 2
The determinant of A is -3


Granted, for binary matrices the numerical stability argument that holds for floating point matrices is not really relevant, but the correctness and efficiency arguments remain important enough to warrant library use over hand-written implementations.  

UPDATE: I just noticed that you got the same suggestion to start exploring Eigen in your other CodeReview question. I really encourage you to do so because it lets you focus on your application rather than on low-level implementation details that have been solved by others already. Unless of course, learning such details is what you are interested in.