ColPack
Recovery/JacobianRecovery2D.cpp
Go to the documentation of this file.
00001 /************************************************************************************
00002     Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
00003     Alex Pothen
00004 
00005     This file is part of ColPack.
00006 
00007     ColPack is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU Lesser General Public License as published
00009     by the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     ColPack is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public License
00018     along with ColPack.  If not, see <http://www.gnu.org/licenses/>.
00019 ************************************************************************************/
00020 
00021 #include "ColPackHeaders.h"
00022 
00023 using namespace std;
00024 
00025 namespace ColPack
00026 {
00027 
00028         int JacobianRecovery2D::DirectRecover_RowCompressedFormat_usermem(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, double*** dp3_JacobianValue) {
00029                 if(g==NULL) {
00030                         cerr<<"g==NULL"<<endl;
00031                         return _FALSE;
00032                 }
00033 
00034                 int rowCount = g->GetRowVertexCount();
00035 
00036                 vector<int> vi_LeftVertexColors;
00037                 g->GetLeftVertexColors(vi_LeftVertexColors);
00038 
00039                 vector<int> RightVertexColors_Transformed;
00040                 g->GetRightVertexColors_Transformed(RightVertexColors_Transformed);
00041 
00042                 int i_ColumnColorCount = g->GetRightVertexColorCount();
00043                 if (g->GetRightVertexDefaultColor() == 1) i_ColumnColorCount--; //color ID 0 is used, ignore it
00044 
00045                 //Do (column-)color statistic for each row, i.e., see how many elements in that row has color 0, color 1 ...
00046                 int** colorStatistic = new int*[rowCount];      //color statistic for each row. For example, colorStatistic[0] is color statistic for row 0
00047                                                                                                         //If row 0 has 5 columns with color 3 => colorStatistic[0][3] = 5;
00048                 //Allocate memory for colorStatistic[rowCount][colorCount] and initilize the matrix
00049                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00050                         colorStatistic[i] = new int[i_ColumnColorCount];
00051                         for(unsigned int j=0; j < (unsigned int)i_ColumnColorCount; j++) colorStatistic[i][j] = 0;
00052                 }
00053 
00054                 //populate colorStatistic for right (column) vertices
00055                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00056                         int numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00057                         for(unsigned int j=1; j <= (unsigned int)numOfNonZeros; j++) {
00058                                 //non-zero in the Jacobian: [i][uip2_JacobianSparsityPattern[i][j]]
00059                                 //color of that column: RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1
00060                                 if (RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] > 0) {
00061                                         colorStatistic[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1]++;
00062                                 }
00063                         }
00064                 }
00065 
00066                 //Recover value of the Jacobian from dp2_ColumnCompressedMatrix (priority) and dp2_RowCompressedMatrix
00067 //cout<<"Recover value of the Jacobian from dp2_ColumnCompressedMatrix (priority) and dp2_RowCompressedMatrix"<<endl;
00068                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00069                         unsigned int numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00070                         for(unsigned int j=1; j <= numOfNonZeros; j++) {
00071 //printf("Recover uip2_JacobianSparsityPattern[%d][%d] = %d \n", i, j, uip2_JacobianSparsityPattern[i][j]);
00072                                 // Check and see if we can recover the value from dp2_ColumnCompressedMatrix first
00073                                 if (RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] > 0 &&
00074                                         colorStatistic[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] - 1]==1
00075                                         ) {
00076 //printf("\t from COLUMN [%d][%d] = %7.2f \n",i, RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1, dp2_ColumnCompressedMatrix[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1]);
00077 //printf("\t from COLUMN [%d][%d] \n",i, RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1);
00078                                         (*dp3_JacobianValue)[i][j] = dp2_ColumnCompressedMatrix[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1];
00079                                 }
00080                                 else { // If not, then use dp2_RowCompressedMatrix
00081 //printf("\t from ROW [%d][%d] = %7.2f \n",m_vi_LeftVertexColors[i]-1, uip2_JacobianSparsityPattern[i][j], dp2_RowCompressedMatrix[m_vi_LeftVertexColors[i]-1][uip2_JacobianSparsityPattern[i][j]]);
00082 //printf("\t from ROW [%d][%d] \n",m_vi_LeftVertexColors[i]-1, uip2_JacobianSparsityPattern[i][j]);
00083                                         (*dp3_JacobianValue)[i][j] = dp2_RowCompressedMatrix[vi_LeftVertexColors[i]-1][uip2_JacobianSparsityPattern[i][j]];
00084                                 }
00085                         }
00086 
00087                 }
00088 //cout<<"DONE"<<endl;
00089 
00090                 free_2DMatrix(colorStatistic, rowCount);
00091                 colorStatistic = NULL;
00092                 
00093                 return rowCount;
00094         }
00095         
00096         int JacobianRecovery2D::DirectRecover_RowCompressedFormat_unmanaged(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, double*** dp3_JacobianValue) {
00097                 if(g==NULL) {
00098                         cerr<<"g==NULL"<<endl;
00099                         return _FALSE;
00100                 }
00101 
00102                 int rowCount = g->GetRowVertexCount();
00103 
00104                 //allocate memory for *dp3_JacobianValue. The dp3_JacobianValue and uip2_JacobianSparsityPattern matrices should have the same size
00105 //cout<<"allocate memory for *dp3_JacobianValue"<<endl;
00106                 *dp3_JacobianValue = (double**) malloc(rowCount * sizeof(double*));
00107                 for(int i=0; i < rowCount; i++) {
00108                         int numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00109                         (*dp3_JacobianValue)[i] = (double*) malloc( (numOfNonZeros+1) * sizeof(double) );
00110                         (*dp3_JacobianValue)[i][0] = numOfNonZeros; //initialize value of the 1st entry
00111                         for(int j=1; j <= numOfNonZeros; j++) (*dp3_JacobianValue)[i][j] = 0.; //initialize value of other entries
00112                 }
00113                 
00114                 return DirectRecover_RowCompressedFormat_usermem(g, dp2_RowCompressedMatrix, dp2_ColumnCompressedMatrix, uip2_JacobianSparsityPattern, dp3_JacobianValue);
00115         }
00116         
00117         int JacobianRecovery2D::DirectRecover_RowCompressedFormat(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, double*** dp3_JacobianValue) {
00118                 int returnValue = DirectRecover_RowCompressedFormat_unmanaged(g,  dp2_RowCompressedMatrix,  dp2_ColumnCompressedMatrix,  uip2_JacobianSparsityPattern,  dp3_JacobianValue);
00119           
00120                 if(AF_available) {
00121                         //cout<<"AF_available="<<AF_available<<endl; Pause();
00122                         reset();
00123                 }
00124 
00125 
00126                 AF_available = true;
00127                 i_AF_rowCount = g->GetRowVertexCount();
00128                 dp2_AF_Value = *dp3_JacobianValue;
00129 
00130                 return returnValue;
00131         }
00132 
00133 //*/
00134 
00135 
00136         int JacobianRecovery2D::DirectRecover_SparseSolversFormat_usermem(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00137                 if(g==NULL) {
00138                         cerr<<"g==NULL"<<endl;
00139                         return _FALSE;
00140                 }
00141 
00142                 int rowCount = g->GetRowVertexCount();
00143 
00144                 //Making the array indices to start at 0 instead of 1
00145                 for(unsigned int i=0; i <= (unsigned int) rowCount ; i++) {
00146                   (*ip2_RowIndex)[i]--;
00147                 }
00148                 for(unsigned int i=0; i < (unsigned int)g->GetEdgeCount(); i++) {
00149                   (*ip2_ColumnIndex)[i]--;
00150                 }
00151 
00152                 vector<int> vi_LeftVertexColors;
00153                 g->GetLeftVertexColors(vi_LeftVertexColors);
00154 
00155                 vector<int> RightVertexColors_Transformed;
00156                 g->GetRightVertexColors_Transformed(RightVertexColors_Transformed);
00157 
00158                 int i_ColumnColorCount = g->GetRightVertexColorCount();
00159                 if (g->GetRightVertexDefaultColor() == 1) i_ColumnColorCount--; //color ID 0 is used, ignore it
00160 
00161 
00162                 //Do (column-)color statistic for each row, i.e., see how many elements in that row has color 0, color 1 ...
00163                 int** colorStatistic = new int*[rowCount];      //color statistic for each row. For example, colorStatistic[0] is color statistic for row 0
00164                                                                                                         //If row 0 has 5 columns with color 3 => colorStatistic[0][3] = 5;
00165                 //Allocate memory for colorStatistic[rowCount][colorCount] and initilize the matrix
00166                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00167                         colorStatistic[i] = new int[i_ColumnColorCount];
00168                         for(unsigned int j=0; j < (unsigned int)i_ColumnColorCount; j++) colorStatistic[i][j] = 0;
00169                 }
00170 
00171                 //populate colorStatistic for right (column) vertices
00172                 unsigned int numOfNonZeros = 0;
00173                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00174                         numOfNonZeros = (unsigned int)uip2_JacobianSparsityPattern[i][0];
00175                         for(unsigned int j=1; j <= numOfNonZeros; j++) {
00176                                 //non-zero in the Jacobian: [i][uip2_JacobianSparsityPattern[i][j]]
00177                                 //color of that column: RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1
00178                                 if (RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] > 0) {
00179                                         colorStatistic[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1]++;
00180                                 }
00181                         }
00182                 }
00183 
00184 
00185 
00186                 //Recover value of the Jacobian from dp2_ColumnCompressedMatrix (priority) and dp2_RowCompressedMatrix
00187 //cout<<"Recover value of the Jacobian from dp2_ColumnCompressedMatrix (priority) and dp2_RowCompressedMatrix"<<endl;
00188                 unsigned int numOfNonZerosInEachRow = 0;
00189                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00190                         numOfNonZerosInEachRow = uip2_JacobianSparsityPattern[i][0];
00191                         for(unsigned int j=1; j <= numOfNonZerosInEachRow; j++) {
00192 //printf("Recover uip2_JacobianSparsityPattern[%d][%d] = %d \n", i, j, uip2_JacobianSparsityPattern[i][j]);
00193                                 // Check and see if we can recover the value from dp2_ColumnCompressedMatrix first
00194                                 if (RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] > 0 &&
00195                                         colorStatistic[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] - 1]==1
00196                                         ) {
00197 //printf("\t from COLUMN [%d][%d] = %7.2f \n",i, RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1, dp2_ColumnCompressedMatrix[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1]);
00198 //printf("\t from COLUMN [%d][%d] \n",i, RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1);
00199                                         (*dp2_JacobianValue)[(*ip2_RowIndex)[i]+j-1] = dp2_ColumnCompressedMatrix[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1];
00200                                 }
00201                                 else { // If not, then use dp2_RowCompressedMatrix
00202 //printf("\t from ROW [%d][%d] = %7.2f \n",m_vi_LeftVertexColors[i]-1, uip2_JacobianSparsityPattern[i][j], dp2_RowCompressedMatrix[m_vi_LeftVertexColors[i]-1][uip2_JacobianSparsityPattern[i][j]]);
00203 //printf("\t from ROW [%d][%d] \n",m_vi_LeftVertexColors[i]-1, uip2_JacobianSparsityPattern[i][j]);
00204                                         (*dp2_JacobianValue)[(*ip2_RowIndex)[i]+j-1] = dp2_RowCompressedMatrix[vi_LeftVertexColors[i]-1][uip2_JacobianSparsityPattern[i][j]];
00205                                 }
00206                         }
00207 
00208                 }
00209 //cout<<"DONE"<<endl;
00210 
00211 
00212                 //Making the array indices to start at 1 instead of 0 to conform with theIntel MKL sparse storage scheme for the direct sparse solvers
00213                 for(unsigned int i=0; i <= (unsigned int) rowCount ; i++) {
00214                   (*ip2_RowIndex)[i]++;
00215                 }
00216                 for(unsigned int i=0; i < (unsigned int)g->GetEdgeCount(); i++) {
00217                   (*ip2_ColumnIndex)[i]++;
00218                 }
00219 
00220 
00221                 free_2DMatrix(colorStatistic, rowCount);
00222                 colorStatistic = NULL;
00223                 
00224                 return rowCount;
00225         }
00226 
00227         int JacobianRecovery2D::DirectRecover_SparseSolversFormat_unmanaged(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00228                 if(g==NULL) {
00229                         cerr<<"g==NULL"<<endl;
00230                         return _FALSE;
00231                 }
00232 
00233                 int rowCount = g->GetRowVertexCount();
00234                 
00235                 // Allocate memory and populate ip2_RowIndex and ip2_ColumnIndex
00236                 g->GetRowVertices(ip2_RowIndex);
00237                 unsigned int numOfNonZeros = g->GetColumnIndices(ip2_ColumnIndex);
00238 
00239                 //Making the array indices to start at 1 instead of 0 to conform with theIntel MKL sparse storage scheme for the direct sparse solvers
00240                 for(unsigned int i=0; i <= (unsigned int) rowCount ; i++) {
00241                   (*ip2_RowIndex)[i]++;
00242                 }
00243                 for(unsigned int i=0; i < numOfNonZeros; i++) {
00244                   (*ip2_ColumnIndex)[i]++;
00245                 }
00246 
00247                 //cout<<"allocate memory for *dp2_JacobianValue rowCount="<<rowCount<<endl;
00248                 //printf("i=%d\tnumOfNonZeros=%d \n", i, numOfNonZeros);
00249                 (*dp2_JacobianValue) = (double*) malloc(numOfNonZeros * sizeof(double)); //allocate memory for *dp2_JacobianValue.
00250                 for(unsigned int i=0; i < numOfNonZeros; i++) (*dp2_JacobianValue)[i] = 0.; //initialize value of other entries
00251                   
00252                 return DirectRecover_SparseSolversFormat_usermem(g, dp2_RowCompressedMatrix, dp2_ColumnCompressedMatrix, uip2_JacobianSparsityPattern, ip2_RowIndex, ip2_ColumnIndex, dp2_JacobianValue);
00253         }
00254         
00255         int JacobianRecovery2D::DirectRecover_SparseSolversFormat(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00256                 int returnValue = DirectRecover_SparseSolversFormat_unmanaged(g,  dp2_RowCompressedMatrix,  dp2_ColumnCompressedMatrix,  uip2_JacobianSparsityPattern,  ip2_RowIndex,  ip2_ColumnIndex,  dp2_JacobianValue);
00257                 
00258                 if(SSF_available) {
00259                         //cout<<"SSF_available="<<SSF_available<<endl; Pause();
00260                         reset();
00261                 }
00262 
00263                 SSF_available = true;
00264                 i_SSF_rowCount = g->GetRowVertexCount();
00265                 ip_SSF_RowIndex = *ip2_RowIndex;
00266                 ip_SSF_ColumnIndex = *ip2_ColumnIndex;
00267                 dp_SSF_Value = *dp2_JacobianValue;
00268 
00269                 return returnValue;
00270         }
00271 
00272 //*/
00273 
00274 
00275 
00276         int JacobianRecovery2D::DirectRecover_CoordinateFormat_usermem(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00277                 if(g==NULL) {
00278                         cerr<<"g==NULL"<<endl;
00279                         return _FALSE;
00280                 }
00281 
00282                 int rowCount = g->GetRowVertexCount();
00283 
00284                 vector<int> vi_LeftVertexColors;
00285                 g->GetLeftVertexColors(vi_LeftVertexColors);
00286 
00287                 vector<int> RightVertexColors_Transformed;
00288                 g->GetRightVertexColors_Transformed(RightVertexColors_Transformed);
00289 
00290                 int i_ColumnColorCount = g->GetRightVertexColorCount();
00291                 if (g->GetRightVertexDefaultColor() == 1) i_ColumnColorCount--; //color ID 0 is used, ignore it
00292 
00293                 //Do (column-)color statistic for each row, i.e., see how many elements in that row has color 0, color 1 ...
00294                 int** colorStatistic = new int*[rowCount];      //color statistic for each row. For example, colorStatistic[0] is color statistic for row 0
00295                                                                                                         //If row 0 has 5 columns with color 3 => colorStatistic[0][3] = 5;
00296                 //Allocate memory for colorStatistic[rowCount][colorCount] and initilize the matrix
00297                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00298                         colorStatistic[i] = new int[i_ColumnColorCount];
00299                         for(unsigned int j=0; j < (unsigned int)i_ColumnColorCount; j++) colorStatistic[i][j] = 0;
00300                 }
00301 
00302                 //populate colorStatistic for right (column) vertices
00303                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00304                         int numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00305                         for(unsigned int j=1; j <= (unsigned int)numOfNonZeros; j++) {
00306                                 //non-zero in the Jacobian: [i][uip2_JacobianSparsityPattern[i][j]]
00307                                 //color of that column: m_vi_RightVertexColors[uip2_JacobianSparsityPattern[i][j]]-1
00308                                 if (RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] > 0) {
00309                                         colorStatistic[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1]++;
00310                                 }
00311                         }
00312                 }
00313 
00314                 //Recover value of the Jacobian from dp2_ColumnCompressedMatrix (priority) and dp2_RowCompressedMatrix
00315 //cout<<"Recover value of the Jacobian from dp2_ColumnCompressedMatrix (priority) and dp2_RowCompressedMatrix"<<endl;
00316                 unsigned int numOfNonZeros_count = 0;
00317                 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00318                         unsigned int numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00319                         for(unsigned int j=1; j <= numOfNonZeros; j++) {
00320 //printf("Recover uip2_JacobianSparsityPattern[%d][%d] = %d \n", i, j, uip2_JacobianSparsityPattern[i][j]);
00321                                 // Check and see if we can recover the value from dp2_ColumnCompressedMatrix first
00322                                 if (RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] > 0 &&
00323                                         colorStatistic[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]] - 1]==1
00324                                         ) {
00325 //printf("\t from COLUMN [%d][%d] = %7.2f \n",i, RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1, dp2_ColumnCompressedMatrix[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1]);
00326 //printf("\t from COLUMN [%d][%d] \n",i, RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1);
00327                                         (*dp2_JacobianValue)[numOfNonZeros_count] = dp2_ColumnCompressedMatrix[i][RightVertexColors_Transformed[uip2_JacobianSparsityPattern[i][j]]-1];
00328                                 }
00329                                 else { // If not, then use dp2_RowCompressedMatrix
00330 //printf("\t from ROW [%d][%d] = %7.2f \n",m_vi_LeftVertexColors[i]-1, uip2_JacobianSparsityPattern[i][j], dp2_RowCompressedMatrix[m_vi_LeftVertexColors[i]-1][uip2_JacobianSparsityPattern[i][j]]);
00331 //printf("\t from ROW [%d][%d] \n",m_vi_LeftVertexColors[i]-1, uip2_JacobianSparsityPattern[i][j]);
00332                                         (*dp2_JacobianValue)[numOfNonZeros_count] = dp2_RowCompressedMatrix[vi_LeftVertexColors[i]-1][uip2_JacobianSparsityPattern[i][j]];
00333                                 }
00334                                 (*ip2_RowIndex)[numOfNonZeros_count] = i;
00335                                 (*ip2_ColumnIndex)[numOfNonZeros_count] = uip2_JacobianSparsityPattern[i][j];
00336                                 numOfNonZeros_count++;
00337                         }
00338 
00339                 }
00340 //cout<<"DONE"<<endl;
00341 
00342                 free_2DMatrix(colorStatistic, rowCount);
00343                 colorStatistic = NULL;
00344                 
00345                 return numOfNonZeros_count;
00346         }
00347 
00348         int JacobianRecovery2D::DirectRecover_CoordinateFormat_unmanaged(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00349                 if(g==NULL) {
00350                         cerr<<"g==NULL"<<endl;
00351                         return _FALSE;
00352                 }
00353 
00354                 unsigned int numOfNonZeros = g->GetEdgeCount();
00355                 (*ip2_RowIndex) = (unsigned int*) malloc(numOfNonZeros * sizeof(unsigned int));
00356                 (*ip2_ColumnIndex) = (unsigned int*) malloc(numOfNonZeros * sizeof(unsigned int));
00357                 (*dp2_JacobianValue) = (double*) malloc(numOfNonZeros * sizeof(double)); //allocate memory for *dp2_JacobianValue.
00358 
00359                 return DirectRecover_CoordinateFormat_usermem(g, dp2_RowCompressedMatrix, dp2_ColumnCompressedMatrix, uip2_JacobianSparsityPattern, ip2_RowIndex, ip2_ColumnIndex, dp2_JacobianValue);
00360         }
00361         
00362         int JacobianRecovery2D::DirectRecover_CoordinateFormat(BipartiteGraphBicoloringInterface* g, double** dp2_RowCompressedMatrix, double** dp2_ColumnCompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00363                 int returnValue = DirectRecover_CoordinateFormat_unmanaged(g, dp2_RowCompressedMatrix, dp2_ColumnCompressedMatrix,  uip2_JacobianSparsityPattern, ip2_RowIndex,  ip2_ColumnIndex,  dp2_JacobianValue);
00364                 
00365                 if(CF_available) reset();
00366 
00367                 CF_available = true;
00368                 i_CF_rowCount = g->GetRowVertexCount();
00369                 ip_CF_RowIndex = *ip2_RowIndex;
00370                 ip_CF_ColumnIndex = *ip2_ColumnIndex;
00371                 dp_CF_Value = *dp2_JacobianValue;
00372 
00373                 return returnValue;
00374         }
00375 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines