Functions

Utilities/extra.cpp File Reference

#include "extra.h"
#include "Pause.h"
#include "mmio.h"

Go to the source code of this file.

Functions

bool isValidOrdering (vector< int > &ordering, int offset)
 Test and make sure that this is a valid ordering.
int ReadRowCompressedFormat (string s_InputFile, unsigned int ***uip3_SparsityPattern, int &rowCount, int &columnCount)
 Read a Row Compressed Format file.
int RowCompressedFormat_2_SparseSolversFormat_StructureOnly (unsigned int **uip2_HessianSparsityPattern, unsigned int ui_rowCount, unsigned int **ip2_RowIndex, unsigned int **ip2_ColumnIndex)
 Build the index struture from Row Compressed Format to Sparse Solvers Format.
void ConvertDIMACSFormat2MatrixMarketFormat (string fileNameNoExt)
 Covert file with DIMACS format to Matrix Market format.
void randomOrdering (vector< int > &ordering)
string toUpper (string input)
 Convert all the characters in input to upper case, ' ', '\ t', '\ n' will be converted to '_'.
int Times2Plus1point5 (double **dp2_Values, int i_RowCount, int i_ColumnCount)
 just manipulate the value of dp2_Values a little bit. Each non-zero entry in the matrix * 2 + 1.5.
int Times2 (double **dp2_Values, int i_RowCount, int i_ColumnCount)
 just manipulate the value of dp2_Values a little bit. Each non-zero entry in the matrix * 2.
int GenerateValues (unsigned int **uip2_SparsityPattern, int rowCount, double ***dp3_Value)
 Allocate memory and generate random values for dp3_Value.
int GenerateValuesForSymmetricMatrix (unsigned int **uip2_SparsityPattern, int rowCount, double ***dp3_Value)
 Allocate memory and generate random values for dp3_Value of a Symmetric Matrix.
int ConvertMatrixMarketFormatToRowCompressedFormat (string s_InputFile, unsigned int ***uip3_SparsityPattern, double ***dp3_Value, int &rowCount, int &columnCount)
 Read the sparse matrix from Matrix-Market-format file and convert to compress sparse row format "uip3_SparsityPattern" & "dp3_Value".
int MatrixMultiplication_VxS (unsigned int **uip3_SparsityPattern, double **dp3_Value, int rowCount, int columnCount, double **dp2_seed, int colorCount, double ***dp3_CompressedMatrix)
 Multiply the original sparse matrix (uip3_SparsityPattern,dp3_Value) (in compress sparse row format) with the seed matrix dp2_seed and store the result in "dp3_CompressedMatrix".
int MatrixMultiplication_SxV (unsigned int **uip3_SparsityPattern, double **dp3_Value, int rowCount, int columnCount, double **dp2_seed, int colorCount, double ***dp3_CompressedMatrix)
 Multiply the seed matrix dp2_seed with the original sparse matrix (uip3_SparsityPattern,dp3_Value) (in compress sparse row format) and store the result in "dp3_CompressedMatrix".
bool CompressedRowMatricesREqual (double **dp3_Value, double **dp3_NewValue, int rowCount, bool compare_exact, bool print_all)
 Compare dp3_Value with dp3_NewValue and see if all the values are equal.

Function Documentation

bool CompressedRowMatricesREqual ( double **  dp3_Value,
double **  dp3_NewValue,
int  rowCount,
bool  compare_exact = 1,
bool  print_all = 0 
)

Compare dp3_Value with dp3_NewValue and see if all the values are equal.

If (compare_exact == 0) num1 and num2 are consider equal if 0.99 <= num1/num2 <= 1.02 If (print_all == 1) all cases of non-equal will be print out. Normally (when print_all == 0), this rountine will stop after the first non-equal.

Definition at line 494 of file extra.cpp.

Referenced by main().

Here is the caller graph for this function:

void ConvertDIMACSFormat2MatrixMarketFormat ( string  fileNameNoExt  ) 

Covert file with DIMACS format to Matrix Market format.

DIMACS graph format: http://www.dis.uniroma1.it/~challenge9/format.shtml#graph Note: DIMACS graph format is for directed graph => the equivalent matrix is squared and non-systemic

Read input from file "<fileNameNoExt>.gr" (DIMACS graph format) and generate file "<fileNameNoExt>.mtx" (Matrix Market format)

Definition at line 144 of file extra.cpp.

int ConvertMatrixMarketFormatToRowCompressedFormat ( string  s_InputFile,
unsigned int ***  uip3_SparsityPattern,
double ***  dp3_Value,
int &  rowCount,
int &  columnCount 
)

Read the sparse matrix from Matrix-Market-format file and convert to compress sparse row format "uip3_SparsityPattern" & "dp3_Value".

Read in a matrix from matrix-market format file and create a matrix stored in compressed sparse row format The Matrix-Market-format has 3 values in each row, the row index, column index and numerical value of each nonzero. The last 4 parameters of this routine are output parameters (unsigned int *** uip3_SparsityPattern, double*** dp3_Value,int &rowCount, int &columnCount)

Definition at line 266 of file extra.cpp.

References mm_is_coordinate, mm_is_general, mm_is_integer, mm_is_pattern, mm_is_real, mm_is_symmetric, mm_read_banner(), and mm_typecode_to_str().

Referenced by f(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

int GenerateValues ( unsigned int **  uip2_SparsityPattern,
int  rowCount,
double ***  dp3_Value 
)

Allocate memory and generate random values for dp3_Value.

Definition at line 221 of file extra.cpp.

int GenerateValuesForSymmetricMatrix ( unsigned int **  uip2_SparsityPattern,
int  rowCount,
double ***  dp3_Value 
)

Allocate memory and generate random values for dp3_Value of a Symmetric Matrix.

Definition at line 239 of file extra.cpp.

bool isValidOrdering ( vector< int > &  ordering,
int  offset = 0 
)

Test and make sure that this is a valid ordering.

This routine will test for:

  • Duplicated vertices. If there is no duplicated vertex, this ordering is probably ok.
  • Invalid vertex #. The vertex # should be between 0 and ordering.size()

Definition at line 25 of file extra.cpp.

int MatrixMultiplication_SxV ( unsigned int **  uip3_SparsityPattern,
double **  dp3_Value,
int  rowCount,
int  columnCount,
double **  dp2_seed,
int  colorCount,
double ***  dp3_CompressedMatrix 
)

Multiply the seed matrix dp2_seed with the original sparse matrix (uip3_SparsityPattern,dp3_Value) (in compress sparse row format) and store the result in "dp3_CompressedMatrix".

(*dp3_CompressedMatrix) = dp2_seed * (*dp3_Value)

Definition at line 467 of file extra.cpp.

Referenced by main().

Here is the caller graph for this function:

int MatrixMultiplication_VxS ( unsigned int **  uip3_SparsityPattern,
double **  dp3_Value,
int  rowCount,
int  columnCount,
double **  dp2_seed,
int  colorCount,
double ***  dp3_CompressedMatrix 
)

Multiply the original sparse matrix (uip3_SparsityPattern,dp3_Value) (in compress sparse row format) with the seed matrix dp2_seed and store the result in "dp3_CompressedMatrix".

(*dp3_CompressedMatrix) = (*dp3_Value) * dp2_seed

Definition at line 440 of file extra.cpp.

Referenced by main().

Here is the caller graph for this function:

void randomOrdering ( vector< int > &  ordering  ) 
int ReadRowCompressedFormat ( string  s_InputFile,
unsigned int ***  uip3_SparsityPattern,
int &  rowCount,
int &  columnCount 
)

Read a Row Compressed Format file.

Read a Row Compressed Format file Line 1: <# of rows> <# of columns> <# of non-zeros> Line 2-(# of non-zeros + 1): <# of non-zeros in that row> <index of the 1st non-zero> <index of the 2nd non-zero> ... <index of the (# of non-zeros in that row)th non-zero>

Definition at line 47 of file extra.cpp.

int RowCompressedFormat_2_SparseSolversFormat_StructureOnly ( unsigned int **  uip2_HessianSparsityPattern,
unsigned int  ui_rowCount,
unsigned int **  ip2_RowIndex,
unsigned int **  ip2_ColumnIndex 
)

Build the index struture from Row Compressed Format to Sparse Solvers Format.

ip2_RowIndex and ip2_ColumnIndex will be allocated memory and populated with the matrix structure in Sparse Solvers Format

Input:

  • uip2_HessianSparsityPattern in Row Compressed Format
  • ui_rowCount

Output:

  • ip2_RowIndex[ui_rowCount + 1] for Sparse Solvers Format
  • ip2_ColumnIndex[ ip2_RowIndex[ui_rowCount] - 1] for Sparse Solvers Format

Definition at line 105 of file extra.cpp.

References displayVector(), and Pause().

Referenced by ColPack::HessianRecovery::DirectRecover_SparseSolversFormat(), and ColPack::HessianRecovery::IndirectRecover_SparseSolversFormat().

Here is the call graph for this function:

Here is the caller graph for this function:

int Times2 ( double **  dp2_Values,
int  i_RowCount,
int  i_ColumnCount 
)

just manipulate the value of dp2_Values a little bit. Each non-zero entry in the matrix * 2.

Definition at line 211 of file extra.cpp.

int Times2Plus1point5 ( double **  dp2_Values,
int  i_RowCount,
int  i_ColumnCount 
)

just manipulate the value of dp2_Values a little bit. Each non-zero entry in the matrix * 2 + 1.5.

Definition at line 202 of file extra.cpp.

string toUpper ( string  input  ) 

Convert all the characters in input to upper case, ' ', '\ t', '\ n' will be converted to '_'.

Definition at line 186 of file extra.cpp.

Referenced by ColPack::BipartiteGraphBicoloringInterface::Bicoloring(), ColPack::GraphOrdering::OrderVertices(), ColPack::BipartiteGraphPartialOrdering::OrderVertices(), ColPack::BipartiteGraphOrdering::OrderVertices(), and ColPack::BipartiteGraphPartialColoringInterface::PartialDistanceTwoColoring().

Here is the caller graph for this function: