ATSuite C++  v1.0
Scientific C++ routines originally developed by Alexis Tantet
Typedefs | Functions
atio.hpp File Reference

Input, output and conversion routines. More...

#include <vector>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>

Go to the source code of this file.

Typedefs

typedef Eigen::SparseMatrix< double, Eigen::RowMajor > SpMatCSR
 Eigen sparse CSR matrix of double type.
 
typedef Eigen::SparseMatrix< double, Eigen::ColMajor > SpMatCSC
 Eigen sparse CSC matrix of double type.
 
typedef Eigen::Triplet< double > Tri
 Eigen triplet of double.
 

Functions

void Eigen2Pajek (FILE *fp, const SpMatCSR *P, const char *dataFormat="%lf")
 Print an Eigen CSR matrix in Pajek format. More...
 
void Eigen2Compressed (FILE *fp, const SpMatCSC *P, const char *dataFormat="%lf")
 Print an Eigen CSC matrix to file in compressed format. More...
 
void Eigen2Compressed (FILE *fp, const SpMatCSR *P, const char *dataFormat="%lf")
 Print an Eigen CSR matrix to file in compressed format. More...
 
SpMatCSCpajek2Eigen (FILE *fp, const char *dataFormat="%lf")
 Scans an Eigen CSC matrix from a Pajek file. More...
 
SpMatCSRCompressed2Eigen (FILE *fp, const char *dataFormat="%lf")
 Scan an Eigen CSR matrix from a file in compressed format. More...
 
gsl_matrix * Compressed2EdgeList (FILE *fp, const char *dataFormat="%lf")
 Scan an edge list from a file in compressed format. More...
 
void Compressed2EdgeList (FILE *src, FILE *dst, const char *dataFormat="%lf")
 Print and edge list to a file in compressed format. More...
 
SpMatCSRCSC2CSR (const SpMatCSC *T)
 Convert an Eigen CSC matrix to an Eigen CSR matrix. More...
 
SpMatCSCCSR2CSC (const SpMatCSR *T)
 Convert an Eigen CSR matrix to an Eigen CSC matrix. More...
 
std::vector< TriEigen2Triplet (const SpMatCSC *T)
 Convert an Eigen CSC matrix to a vector of Eigen triplet. More...
 
std::vector< TriEigen2Triplet (const SpMatCSR *T)
 Convert an Eigen CSR matrix to a vector of Eigen triplet. More...
 
void fprintfEigen (FILE *fp, const SpMatCSR *T, const char *dataFormat)
 Print an Eigen CSR matrix as a dense matrix. More...
 
size_t lineCount (FILE *fp)
 Count the number of lines in a file. More...
 

Detailed Description

ATSuite input, output and conversion routines between various matrices types.

Sparse matrices are printed in the following ascii compressed format:

  1. a header with the matrix type ("CSR" or "CSC"), inner size, outer size and number of nonzero elements,
  2. the data vector,
  3. the indices vector,
  4. the pointer vector.

Definition in file atio.hpp.

Function Documentation

gsl_matrix * Compressed2EdgeList ( FILE *  fp,
const char *  dataFormat = "%lf" 
)

Scan an edge list as a GSL matrix from a matrix file in compressed format (see atio.hpp documentation).

Parameters
[in]fpDescriptor of the file to which to scan.
[in]dataFormatFormat in which to scan each matrix element.
Returns
Edge list as a GSL matrix

Definition at line 263 of file atio.hpp.

Referenced by Compressed2EdgeList().

void Compressed2EdgeList ( FILE *  src,
FILE *  dst,
const char *  dataFormat = "%lf" 
)

Print an edge list to a matrix file in compressed format (see atio.hpp documentation).

Parameters
[in]srcDescriptor of the file to which to scan in compressed matrix format.
[in]dstDescriptor of the file to which to print in edge list format.
[in]dataFormatFormat in which to scan and print each matrix element.

Definition at line 325 of file atio.hpp.

References Compressed2EdgeList().

SpMatCSR * Compressed2Eigen ( FILE *  fp,
const char *  dataFormat = "%lf" 
)

Scan an Eigen CSR matrix from a matrix file in compressed format (see atio.hpp documentation).

Parameters
[in]fpDescriptor of the file to which to scan.
[in]dataFormatFormat in which to scan each matrix element.
Returns
Scanned Eigen matrix.

Definition at line 207 of file atio.hpp.

SpMatCSR * CSC2CSR ( const SpMatCSC T)

Convert an Eigen CSC matrix to an Eigen CSR matrix.

Parameters
[in]TEigen matrix from which to convert.
Returns
Eigen matrix converted.

Definition at line 349 of file atio.hpp.

References Eigen2Triplet().

SpMatCSC * CSR2CSC ( const SpMatCSR T)

Converts an Eigen CSR matrix to an Eigen CSC matrix.

Parameters
[in]TEigen matrix from which to convert.
Returns
Eigen matrix converted.

Definition at line 372 of file atio.hpp.

References Eigen2Triplet().

Referenced by Eigen2AR(), and Eigen2ARSym().

void Eigen2Compressed ( FILE *  fp,
const SpMatCSC P,
const char *  dataFormat = "%lf" 
)

Print an Eigen CSC matrix in compressed format (see atio.hpp documentation).

Parameters
[in]fpDescriptor of the file to which to print.
[in]PEigen matrix to print.
[in]dataFormatFormat in which to print each matrix element.

Definition at line 137 of file atio.hpp.

Referenced by transferOperator::printBackwardTransition(), and transferOperator::printForwardTransition().

void Eigen2Compressed ( FILE *  fp,
const SpMatCSR P,
const char *  dataFormat = "%lf" 
)

Print an Eigen CSR matrix in compressed format (see atio.hpp documentation).

Parameters
[in]fpDescriptor of the file to which to print.
[in]PEigen matrix to print.
[in]dataFormatFormat in which to print each matrix element.

Definition at line 172 of file atio.hpp.

void Eigen2Pajek ( FILE *  fp,
const SpMatCSR P,
const char *  dataFormat = "%lf" 
)

Print an Eigen CSR matrix in Pajek format (see Pajek documentation).

Parameters
[in]fpDescriptor of the file to which to print.
[in]PEigen matrix to print.
[in]dataFormatFormat in which to print each matrix element.

Definition at line 58 of file atio.hpp.

std::vector< Tri > Eigen2Triplet ( const SpMatCSC T)

Convert an Eigen CSC matrix to a vector of Eigen triplet.

Parameters
[in]TEigen matrix from which to convert.
Returns
vector of Eigen triplet converted.

Definition at line 395 of file atio.hpp.

Referenced by CSC2CSR(), and CSR2CSC().

std::vector< Tri > Eigen2Triplet ( const SpMatCSR T)

Convert an Eigen CSR matrix to a vector of Eigen triplet.

Parameters
[in]TEigen matrix from which to convert.
Returns
vector of Eigen triplet converted.

Definition at line 417 of file atio.hpp.

void fprintfEigen ( FILE *  fp,
const SpMatCSR T,
const char *  dataFormat 
)

Print an Eigen CSR matrix as a dense matrix with zero elements marked as "---".

Parameters
[in]fpFile to which to print.
[in]TEigen matrix to print.
[in]dataFormatFormat in which to print each matrix element.

Definition at line 440 of file atio.hpp.

size_t lineCount ( FILE *  fp)

Count the number of lines in a file.

Parameters
[in]fpFile from which to count lines.
Returns
Number of lines in file.

Definition at line 471 of file atio.hpp.

SpMatCSC * pajek2Eigen ( FILE *  fp,
const char *  dataFormat = "%lf" 
)

Scans an Eigen CSC matrix from a Pajek file (see Pajek documentation).

Parameters
[in]fpDescriptor of the file to which to scan.
[in]dataFormatFormat in which to print each matrix element.
Returns
Eigen matrix scanned.

Definition at line 90 of file atio.hpp.