Go to the documentation of this file.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_Seed = new double**;
00060 int *ip1_SeedRowCount = new int;
00061 int *ip1_SeedColumnCount = new int;
00062 int *ip1_ColorCount = new int;
00063
00064
00065
00066 BipartiteGraphPartialColoringInterface *g = new BipartiteGraphPartialColoringInterface(SRC_MEM_ADOLC, *uip3_SparsityPattern, rowCount, columnCount);
00067
00068
00069 g->PartialDistanceTwoColoring( "SMALLEST_LAST", "COLUMN_PARTIAL_DISTANCE_TWO");
00070
00071
00072 (*dp3_Seed) = g->GetSeedMatrix(ip1_SeedRowCount, ip1_SeedColumnCount);
00073
00074
00075
00076
00077
00078 cout<<"Finish GenerateSeed()"<<endl;
00079 *ip1_ColorCount = *ip1_SeedColumnCount;
00080
00081
00082 printf(" dp3_Seed %d x %d \n", *ip1_SeedRowCount, *ip1_SeedColumnCount);
00083 displayMatrix(*dp3_Seed, *ip1_SeedRowCount, *ip1_SeedColumnCount);
00084 Pause();
00085
00086
00087
00088
00089 double*** dp3_CompressedMatrix = new double**;
00090 cout<<"Start MatrixMultiplication()"<<endl;
00091 MatrixMultiplication_VxS(*uip3_SparsityPattern, *dp3_Value, rowCount, columnCount, *dp3_Seed, *ip1_ColorCount, dp3_CompressedMatrix);
00092 cout<<"Finish MatrixMultiplication()"<<endl;
00093
00094 displayMatrix(*dp3_CompressedMatrix,rowCount,*ip1_ColorCount);
00095 Pause();
00096
00097
00098
00099 unsigned int** ip2_RowIndex = new unsigned int*;
00100 unsigned int** ip2_ColumnIndex = new unsigned int*;
00101 double** dp2_JacobianValue = new double*;
00102 JacobianRecovery1D* jr1d = new JacobianRecovery1D;
00103 jr1d->RecoverD2Cln_SparseSolversFormat(g, *dp3_CompressedMatrix, *uip3_SparsityPattern, ip2_RowIndex, ip2_ColumnIndex, dp2_JacobianValue);
00104 cout<<"Finish Recover()"<<endl;
00105
00106 cout<<endl<<"Display result, the structure and values should be similar to the original one"<<endl;
00107 cout<<"Display *ip2_RowIndex"<<endl;
00108 displayVector(*ip2_RowIndex,g->GetRowVertexCount()+1);
00109 cout<<"Display *ip2_ColumnIndex"<<endl;
00110 displayVector(*ip2_ColumnIndex, (*ip2_RowIndex)[g->GetRowVertexCount()]-1);
00111 cout<<"Display *dp2_JacobianValue"<<endl;
00112 displayVector(*dp2_JacobianValue, (*ip2_RowIndex)[g->GetRowVertexCount()]-1);
00113 Pause();
00114
00115
00116
00117 free_2DMatrix(uip3_SparsityPattern, rowCount);
00118 uip3_SparsityPattern=NULL;
00119
00120 free_2DMatrix(dp3_Value, rowCount);
00121 dp3_Value=NULL;
00122
00123 delete dp3_Seed;
00124 dp3_Seed = NULL;
00125
00126 delete ip1_SeedRowCount;
00127 ip1_SeedRowCount=NULL;
00128
00129 delete ip1_SeedColumnCount;
00130 ip1_SeedColumnCount = NULL;
00131
00132 free_2DMatrix(dp3_CompressedMatrix, rowCount);
00133 dp3_CompressedMatrix = NULL;
00134
00135 delete ip1_ColorCount;
00136 ip1_ColorCount = NULL;
00137
00138 delete jr1d;
00139 jr1d = NULL;
00140
00141 delete ip2_RowIndex;
00142 delete ip2_ColumnIndex;
00143 delete dp2_JacobianValue;
00144 ip2_RowIndex=NULL;
00145 ip2_ColumnIndex=NULL;
00146 dp2_JacobianValue=NULL;
00147
00148 delete g;
00149 g=NULL;
00150
00151 return 0;
00152 }