Changeset 912bd1b in tol


Ignore:
Timestamp:
Nov 3, 2008, 8:05:53 AM (18 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
8b98f904
Parents:
47cbb8f
Message:

WriteMatrixMarket in order to export to MatrixMarket format. This will anable us to check results with SuiteSparse

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@103 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/btol/vmatrix_type
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/vmatrix_type/Jamfile

    r47cbb8f r912bd1b  
    44    : vmat.cpp vmat_convert.cpp vmat_stats.cpp vmat_arith.cpp vmat_logic.cpp
    55      vmat_chol.cpp vmat_subtypes.cpp vmat_io.cpp vmat_bsr.cpp
    6       vmat_iterator.cpp vmatgra.cpp
     6      vmat_iterator.cpp vmatgra.cpp mmio.c
    77    : <include>$(TOP)/bmath/gsl_ext
    88
  • tol/btol/vmatrix_type/tol_bvmat.h

    r47cbb8f r912bd1b  
    324324  void   Print(FILE* file, const char* name, int level) const;
    325325  void   Scan (FILE* file);
     326  void   WriteMatrixMarket(FILE* file);
    326327  size_t Bytes() const;
    327328  bool   Write(BOisCreator& ois, BStream* name) const;
  • tol/btol/vmatrix_type/vmat_io.cpp

    r47cbb8f r912bd1b  
    2828#include <stdarg.h>
    2929
    30      
     30//#define _USE_MM_IO_
     31#ifdef _USE_MM_IO_
     32#include "mmio.h"
     33#endif
    3134
    3235////////////////////////////////////////////////////////////////////////////////
    … …  
    190193        I2("virtual matrix","")+" "+CodeName(a.code_)+
    191194           "("+a.Rows()+"x"+a.Columns()+")"+" ");
     195  FILE *f = fopen("/tmp/fail_chol.mtx", "w");
     196  ((BVMat&)a).WriteMatrixMarket(f);
     197  fclose(f);
    192198}
    193199
    … …  
    300306  s_.chlmRtriplet_ = cholmod_read_triplet(file,common_);
    301307};
     308
     309#ifdef _USE_MM_IO_
     310////////////////////////////////////////////////////////////////////////////////
     311  void BVMat::WriteMatrixMarket(FILE* file)
     312//Exporting method
     313////////////////////////////////////////////////////////////////////////////////
     314{
     315  cholmod_triplet *ptr_triplet = NULL;
     316  bool should_free = false;
     317  MM_typecode matcode;
    302318 
     319  if (code_==ESC_chlmRsparse) {
     320    ptr_triplet = cholmod_sparse_to_triplet(s_.chlmRsparse_, common_);
     321    should_free = true;
     322  } else if (code_==ESC_chlmRtriplet) {
     323    ptr_triplet = s_.chlmRtriplet_;
     324  }
     325  if (ptr_triplet) {
     326    mm_initialize_typecode(&matcode);
     327    mm_set_matrix(&matcode);
     328    mm_set_coordinate(&matcode);
     329    mm_set_real(&matcode);
     330
     331    mm_write_banner(file, matcode);
     332    mm_write_mtx_crd_size(file,
     333                          ptr_triplet->nrow,
     334                          ptr_triplet->ncol,
     335                          ptr_triplet->nnz);
     336
     337    /* NOTE: matrix market files use 1-based indices, i.e. first element
     338       of a vector has index 1, not 0.  */
     339
     340    int *Ti = (int*)ptr_triplet->i;
     341    int *Tj = (int*)ptr_triplet->j;
     342    double *Val = (double*)ptr_triplet->x;
     343    for (int i=0; i<ptr_triplet->nnz; i++)
     344        fprintf(file,
     345                "%d %d %10.7g\n", Ti[i]+1, Tj[i]+1, Val[i]);
     346   
     347    if (should_free) {
     348      cholmod_free_triplet(&ptr_triplet, common_);
     349    }
     350  }
     351};
     352#else
     353void BVMat::WriteMatrixMarket(FILE* file)
     354{
     355}
     356#endif
     357
    303358////////////////////////////////////////////////////////////////////////////////
    304359  size_t BVMat::bytes_blasRdense() const
Note: See TracChangeset for help on using the changeset viewer.