I'm looking for the best way to do a determinant, for determinants until 15x15 and looking for speed
int Determinant(const vector<vector<int> > &a,int n)
{
int i,j,j1,j2;
int det = 0;
vector<vector<int> > m(n, vector<int>(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<n;j1++)
{
for (i=1;i<n;i++)
{
j2 = 0;
for (j=0;j<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;
}