00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "ColPackHeaders.h"
00020
00021 using namespace ColPack;
00022 using namespace std;
00023
00024 #ifndef TOP_DIR
00025 #define TOP_DIR "."
00026 #endif
00027
00028
00029 string baseDir=TOP_DIR;
00030
00031 #include "extra.h"
00032
00033
00034 int main()
00035 {
00036
00037 string s_InputFile;
00038 s_InputFile = baseDir;
00039 s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "column-compress.mtx";
00040
00041
00042
00043
00044 unsigned int *** uip3_SparsityPattern = new unsigned int **;
00045 double*** dp3_Value = new double**;
00046 int rowCount, columnCount;
00047 ConvertMatrixMarketFormatToRowCompressedFormat(s_InputFile, uip3_SparsityPattern, dp3_Value,rowCount, columnCount);
00048
00049 cout<<"just for debugging purpose, display the 2 matrices: the matrix with SparsityPattern only and the matrix with Value"<<endl;
00050 cout<<fixed<<showpoint<<setprecision(2);
00051 cout<<"(*uip3_SparsityPattern)"<<endl;
00052 displayCompressedRowMatrix((*uip3_SparsityPattern),rowCount);
00053 cout<<"(*dp3_Value)"<<endl;
00054 displayCompressedRowMatrix((*dp3_Value),rowCount);
00055 cout<<"Finish ConvertMatrixMarketFormatToRowCompressedFormat()"<<endl;
00056 Pause();
00057
00058
00059 double*** dp3_LeftSeed = new double**;
00060 int *ip1_LeftSeedRowCount = new int;
00061 int *ip1_LeftSeedColumnCount = new int;
00062 double*** dp3_RightSeed = new double**;
00063 int *ip1_RightSeedRowCount = new int;
00064 int *ip1_RightSeedColumnCount = new int;
00065
00066
00067
00068 BipartiteGraphBicoloringInterface *g = new BipartiteGraphBicoloringInterface(SRC_MEM_ADOLC, *uip3_SparsityPattern, rowCount, columnCount);
00069
00070
00071 g->Bicoloring( "SMALLEST_LAST", "IMPLICIT_COVERING__STAR_BICOLORING");
00072
00073
00074 (*dp3_LeftSeed) = g->GetLeftSeedMatrix(ip1_LeftSeedRowCount, ip1_LeftSeedColumnCount );
00075 (*dp3_RightSeed) = g->GetRightSeedMatrix(ip1_RightSeedRowCount, ip1_RightSeedColumnCount );
00076
00077
00078
00079
00080
00081
00082
00083 cout<<"Finish GenerateSeed()"<<endl;
00084
00085
00086 printf(" dp3_LeftSeed %d x %d", *ip1_LeftSeedRowCount, *ip1_LeftSeedColumnCount);
00087 displayMatrix(*dp3_LeftSeed, *ip1_LeftSeedRowCount, *ip1_LeftSeedColumnCount);
00088 printf(" dp3_RightSeed %d x %d", *ip1_RightSeedRowCount, *ip1_RightSeedColumnCount);
00089 displayMatrix(*dp3_RightSeed, *ip1_RightSeedRowCount, *ip1_RightSeedColumnCount);
00090 Pause();
00091
00092
00093
00094
00095
00096
00097
00098 double*** dp3_LeftCompressedMatrix = new double**;
00099 double*** dp3_RightCompressedMatrix = new double**;
00100 cout<<"Start MatrixMultiplication() for both direction (left and right)"<<endl;
00101 MatrixMultiplication_SxV(*uip3_SparsityPattern, *dp3_Value, rowCount, columnCount, *dp3_LeftSeed, *ip1_LeftSeedRowCount, dp3_LeftCompressedMatrix);
00102 MatrixMultiplication_VxS(*uip3_SparsityPattern, *dp3_Value, rowCount, columnCount, *dp3_RightSeed, *ip1_RightSeedColumnCount, dp3_RightCompressedMatrix);
00103 cout<<"Finish MatrixMultiplication()"<<endl;
00104
00105 displayMatrix(*dp3_RightCompressedMatrix,rowCount,*ip1_RightSeedColumnCount);
00106 displayMatrix(*dp3_LeftCompressedMatrix,*ip1_LeftSeedRowCount, columnCount);
00107 Pause();
00108
00109
00110
00111 unsigned int** ip2_RowIndex = new unsigned int*;
00112 unsigned int** ip2_ColumnIndex = new unsigned int*;
00113 double** dp2_JacobianValue = new double*;
00114 JacobianRecovery2D* jr2d = new JacobianRecovery2D;
00115 jr2d->DirectRecover_SparseSolversFormat(g, *dp3_LeftCompressedMatrix, *dp3_RightCompressedMatrix, *uip3_SparsityPattern, ip2_RowIndex, ip2_ColumnIndex, dp2_JacobianValue);
00116 cout<<"Finish Recover()"<<endl;
00117
00118 cout<<endl<<"Display result, the structure and values should be similar to the original one"<<endl;
00119 cout<<"Display *ip2_RowIndex"<<endl;
00120 displayVector(*ip2_RowIndex,rowCount+1);
00121 cout<<"Display *ip2_ColumnIndex"<<endl;
00122 displayVector(*ip2_ColumnIndex, (*ip2_RowIndex)[rowCount] - 1 );
00123 cout<<"Display *dp2_JacobianValue"<<endl;
00124 displayVector(*dp2_JacobianValue, (*ip2_RowIndex)[rowCount] - 1 );
00125 Pause();
00126
00127
00128
00129 delete jr2d;
00130 jr2d = NULL;
00131
00132 delete ip2_RowIndex;
00133 delete ip2_ColumnIndex;
00134 delete dp2_JacobianValue;
00135 ip2_RowIndex = NULL;
00136 ip2_ColumnIndex = NULL;
00137 dp2_JacobianValue = NULL;
00138
00139 free_2DMatrix(dp3_RightCompressedMatrix, rowCount);
00140 dp3_RightCompressedMatrix = NULL;
00141
00142 free_2DMatrix(dp3_LeftCompressedMatrix, *ip1_LeftSeedRowCount);
00143 dp3_LeftCompressedMatrix = NULL;
00144
00145 delete dp3_RightSeed;
00146 dp3_RightSeed = NULL;
00147
00148 delete ip1_RightSeedColumnCount;
00149 ip1_RightSeedColumnCount = NULL;
00150
00151 delete ip1_RightSeedRowCount;
00152 ip1_RightSeedRowCount = NULL;
00153
00154 delete dp3_LeftSeed;
00155 dp3_LeftSeed = NULL;
00156
00157 delete ip1_LeftSeedColumnCount;
00158 ip1_LeftSeedColumnCount = NULL;
00159
00160 delete ip1_LeftSeedRowCount;
00161 ip1_LeftSeedRowCount = NULL;
00162
00163 free_2DMatrix(dp3_Value, rowCount);
00164 dp3_Value = NULL;
00165
00166 free_2DMatrix(uip3_SparsityPattern, rowCount);
00167 dp3_Value = NULL;
00168
00169 delete g;
00170 g=NULL;
00171
00172 return 0;
00173 }