code: public static double leibniz( DMatrixRMaj mat )
      {
          PermuteArray perm = new PermuteArray( mat.numCols );
  
          double total = 0;
  
          int p[] = perm.next();
  
          while( p != null ) {
  
              double prod = 1;
  
              for( int i = 0; i < mat.numRows; i++ ) {
                  prod *= mat.get(i,p[i]);
              }
  
              total += perm.sgn()*prod;
              p = perm.next();
          }
  
          return total;
      }
docs: <p>
  Computes the determinant of the matrix using Leibniz's formula
  </p>
  
  <p>
  A direct implementation of Leibniz determinant equation.  This is of little practical use
  because of its slow runtime of O(n!) where n is the width of the matrix. LU decomposition
  should be used instead.  One advantage of Leibniz's equation is how simplistic it is.
  </p>
  <p>
  det(A) = Sum( &sigma; in S<sub>n</sub> ; sgn(&sigma;) Prod( i = 1 to n ; a<sub>i,&sigma;(i)</sub>) )<br>
  </p>
  <ul>
  <li>sgn is the sign function of permutations. +1 or -1 for even and odd permutations</li>
  <li>a set of permutations. if n=3 then the possible permutations are (1,2,3) (1,3,2), (3,2,1), ... etc</li>
  </ul>
  
  
  @param mat The matrix whose determinant is computed.
  @return The value of the determinant