title: computing determinant of a matrix (nxn) recursively
body: <p>I'm about to write some code that computes the determinant of a square matrix (nxn), using the Laplace algorithm (Meaning recursive algorithm) as written <a href="http://en.wikipedia.org/wiki/Laplace_expansion" rel="nofollow">Wikipedia's <strong>Laplace Expansion</strong></a>.</p>
  
  <p>I already have the class <code>Matrix</code>, which includes <strong>init</strong>, <strong>setitem</strong>, <strong>getitem</strong>, <strong>repr</strong> and all the things I need to compute the determinant (including <code>minor(i,j)</code>).</p>
  
  <p>So I've tried the code below:</p>
  
  <pre><code>def determinant(self,i=0)  # i can be any of the matrix's rows
      assert isinstance(self,Matrix)
      n,m = self.dim()    # Q.dim() returns the size of the matrix Q
      assert n == m
      if (n,m) == (1,1):
          return self[0,0]
      det = 0
      for j in range(n):
          det += ((-1)**(i+j))*(self[i,j])*((self.minor(i,j)).determinant())
      return det
  </code></pre>
  
  <p>As expected, in every recursive call, <code>self</code> turns into an appropriate minor. But when coming back from the recursive call, it doesn't change back to it's original matrix. 
  This causes trouble when in the <code>for</code> loop (when the function arrives at <code>(n,m)==(1,1)</code>, this one value of the matrix is returned, but in the <code>for</code> loop, <code>self</code> is still a 1x1 matrix - why?)</p>