Index: tol/btol/vmatrix_type/Jamfile
===================================================================
--- tol/btol/vmatrix_type/Jamfile	(revision 47cbb8f7f5bfd4eae5758652b1d41b98dbf7837d)
+++ tol/btol/vmatrix_type/Jamfile	(revision 912bd1be3e7dd6b5a3a0a807d2175c218f3c64b8)
@@ -4,5 +4,5 @@
     : vmat.cpp vmat_convert.cpp vmat_stats.cpp vmat_arith.cpp vmat_logic.cpp
       vmat_chol.cpp vmat_subtypes.cpp vmat_io.cpp vmat_bsr.cpp 
-      vmat_iterator.cpp vmatgra.cpp
+      vmat_iterator.cpp vmatgra.cpp mmio.c
     : <include>$(TOP)/bmath/gsl_ext
 
Index: tol/btol/vmatrix_type/tol_bvmat.h
===================================================================
--- tol/btol/vmatrix_type/tol_bvmat.h	(revision 47cbb8f7f5bfd4eae5758652b1d41b98dbf7837d)
+++ tol/btol/vmatrix_type/tol_bvmat.h	(revision 912bd1be3e7dd6b5a3a0a807d2175c218f3c64b8)
@@ -324,4 +324,5 @@
   void   Print(FILE* file, const char* name, int level) const;
   void   Scan (FILE* file);
+  void   WriteMatrixMarket(FILE* file);
   size_t Bytes() const;
   bool   Write(BOisCreator& ois, BStream* name) const;
Index: tol/btol/vmatrix_type/vmat_io.cpp
===================================================================
--- tol/btol/vmatrix_type/vmat_io.cpp	(revision 47cbb8f7f5bfd4eae5758652b1d41b98dbf7837d)
+++ tol/btol/vmatrix_type/vmat_io.cpp	(revision 912bd1be3e7dd6b5a3a0a807d2175c218f3c64b8)
@@ -28,5 +28,8 @@
 #include <stdarg.h>
 
-     
+//#define _USE_MM_IO_
+#ifdef _USE_MM_IO_
+#include "mmio.h"
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -190,4 +193,7 @@
         I2("virtual matrix","")+" "+CodeName(a.code_)+
            "("+a.Rows()+"x"+a.Columns()+")"+" ");
+  FILE *f = fopen("/tmp/fail_chol.mtx", "w");
+  ((BVMat&)a).WriteMatrixMarket(f);
+  fclose(f);
 }
 
@@ -300,5 +306,54 @@
   s_.chlmRtriplet_ = cholmod_read_triplet(file,common_);
 };
+
+#ifdef _USE_MM_IO_
+////////////////////////////////////////////////////////////////////////////////
+  void BVMat::WriteMatrixMarket(FILE* file)
+//Exporting method
+////////////////////////////////////////////////////////////////////////////////
+{
+  cholmod_triplet *ptr_triplet = NULL;
+  bool should_free = false;
+  MM_typecode matcode;
   
+  if (code_==ESC_chlmRsparse) {
+    ptr_triplet = cholmod_sparse_to_triplet(s_.chlmRsparse_, common_);
+    should_free = true;
+  } else if (code_==ESC_chlmRtriplet) {
+    ptr_triplet = s_.chlmRtriplet_;
+  }
+  if (ptr_triplet) {
+    mm_initialize_typecode(&matcode);
+    mm_set_matrix(&matcode);
+    mm_set_coordinate(&matcode);
+    mm_set_real(&matcode);
+
+    mm_write_banner(file, matcode); 
+    mm_write_mtx_crd_size(file,
+                          ptr_triplet->nrow,
+                          ptr_triplet->ncol,
+                          ptr_triplet->nnz);
+
+    /* NOTE: matrix market files use 1-based indices, i.e. first element
+       of a vector has index 1, not 0.  */
+
+    int *Ti = (int*)ptr_triplet->i;
+    int *Tj = (int*)ptr_triplet->j;
+    double *Val = (double*)ptr_triplet->x;
+    for (int i=0; i<ptr_triplet->nnz; i++)
+        fprintf(file,
+                "%d %d %10.7g\n", Ti[i]+1, Tj[i]+1, Val[i]);
+    
+    if (should_free) {
+      cholmod_free_triplet(&ptr_triplet, common_);
+    }
+  }
+};
+#else
+void BVMat::WriteMatrixMarket(FILE* file)
+{
+}
+#endif
+
 ////////////////////////////////////////////////////////////////////////////////
   size_t BVMat::bytes_blasRdense() const
