title: How to compare two matrices to see if they are identical in R?
body: <p>For example, I have two matrices and I wanna know if they are identical in each element.</p>
  
  <pre><code>mymatrix&lt;-Matrix(rnorm(20),ncol=5)
  mysvd&lt;-svd(mymatrix) 
  newmatrix&lt;-mysvd$u %*% diag(mysvd$d) %*% t(mysvd$v)
  </code></pre>
  
  <p>I used the following ways to compare them:</p>
  
  <pre><code>identical(Matrix(newmatrix), mymatrix)
  all.equal(Matrix(newmatrix), mymatrix)
  </code></pre>
  
  <p>Why the first one doesn't return TRUE?
  No matter I use Matrix from the matrix package or the matrix from base package</p>