code: public static Matrix copy(Matrix matrix) {
          Matrix copiedMatrix = null;
          if (matrix instanceof SparseMatrix)
              copiedMatrix = Matrices.create(
                      matrix.rows(), matrix.columns(), Type.SPARSE_IN_MEMORY);
          else
              copiedMatrix = Matrices.create(
                      matrix.rows(), matrix.columns(), Type.DENSE_IN_MEMORY);
          return copyTo(matrix, copiedMatrix);
      }
docs: Returns a copied version of a given matrix.  The returned matrix will
  have the same dimensionality, values, and sparsity, but it may not have
  the same exact sub-type.
  
  @param matrix the matrix to be copied
  
  @throws IllegalArgumentException when the dimensionality of matrix and
  output do not match
  
  @return a copied version of matrix