static public BigInteger det(final BigInteger[][] A) throws ArithmeticException
        {
                BigInteger d = BigInteger.ZERO ;
                /* row size */
                final int rL = A.length ;
                if ( rL == 0 )
                        throw new ArithmeticException("zero row count in matrix") ;
                /* column size */
                final int cL = A[0].length ;
                if ( cL != rL )
                        throw new ArithmeticException("Non-square matrix dim "+rL + " by " + cL) ;

                /* Compute the low-order cases directly.
                */
                if ( rL == 1 )
                        return A[0][0] ;

                else if ( rL == 2)
                {
                        d = A[0][0].multiply(A[1][1]) ;
                        return d.subtract( A[0][1].multiply(A[1][0])) ;
                }
                else
                {
                        /* Work arbitrarily along the first column of the matrix */
                        for (int r = 0  ; r < rL  ; r++)
                        {
                                /* Do not consider minors that do no contribute anyway
                                */
                                if ( A[r][0].compareTo(BigInteger.ZERO) != 0 )
                                {
                                        final BigInteger M[][] = minor(A,r,0) ;
                                        final BigInteger m = A[r][0].multiply( det(M)) ;
                                        /* recursive call */
                                        if ( r % 2 == 0)
                                                d = d.add(m) ;
                                        else
                                                d = d.subtract(m) ;
                                }
                        }
                }
                return d;
        }