diff --git a/spm.c b/spm.c
index 0fc78f42dc0e3a307b981c2fa52ed99b7676dd97..878f5d813b81e6675fc6b486be352fb272216ac9 100644
--- a/spm.c
+++ b/spm.c
@@ -305,6 +305,43 @@ spmConvert( int ofmttype, pastix_spm_t *spm )
     }
 }
 
+/**
+ *******************************************************************************
+ *
+ * @ingroup pastix_spm
+ *
+ * @brief Convert the spm matrix into a dense matrix for test purpose. DO NOT
+ * USE with large matrices.
+ *
+ *******************************************************************************
+ *
+ * @param[in,out] spm
+ *          The sparse matrix structure to convert.
+ *
+ ********************************************************************************
+ *
+ * @return
+ *        The pointer to the allocated array storing the dense version of the
+ *        matrix.
+ *
+ *******************************************************************************/
+void *
+spm2Dense( const pastix_spm_t *spm )
+{
+    switch (spm->flttype) {
+    case PastixFloat:
+        return s_spm2dense( spm );
+    case PastixComplex32:
+        return c_spm2dense( spm );
+    case PastixComplex64:
+        return z_spm2dense( spm );
+    case PastixDouble:
+        return d_spm2dense( spm );
+    default:
+        return NULL;
+    }
+}
+
 /**
  *******************************************************************************
  *
diff --git a/spm.h b/spm.h
index c91de942ecb26fcdb04b5f172215bd223e01a682..fa0c5f0fa2e49df4366acedb9ec845fbf71d01eb 100644
--- a/spm.h
+++ b/spm.h
@@ -126,6 +126,7 @@ void          spmExit( pastix_spm_t *spm );
 pastix_spm_t *spmCopy( const pastix_spm_t *spm );
 void          spmBase( pastix_spm_t *spm, int baseval );
 int           spmConvert( int ofmttype, pastix_spm_t *ospm );
+void *        spm2Dense( const pastix_spm_t *spm );
 pastix_int_t  spmFindBase( const pastix_spm_t *spm );
 double        spmNorm( int ntype, const pastix_spm_t *spm );
 int           spmMatVec(const pastix_trans_t trans, const void *alpha, const pastix_spm_t *spm, const void *x, const void *beta, void *y );