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
00020
00021 #include "ColPackHeaders.h"
00022
00023 using namespace std;
00024
00025 namespace ColPack
00026 {
00027
00028 int JacobianRecovery1D::RecoverD2Row_RowCompressedFormat(BipartiteGraphPartialColoringInterface* g, double** dp2_CompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, double*** dp3_JacobianValue) {
00029 if(g==NULL) {
00030 cerr<<"g==NULL"<<endl;
00031 return _FALSE;
00032 }
00033
00034 if(AF_available) reset();
00035
00036 int rowCount = g->GetRowVertexCount();
00037 vector<int> vi_LeftVertexColors;
00038 g->GetLeftVertexColors(vi_LeftVertexColors);
00039 unsigned int numOfNonZeros = 0;
00040
00041
00042 *dp3_JacobianValue = new double*[rowCount];
00043 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00044 numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00045 (*dp3_JacobianValue)[i] = new double[numOfNonZeros+1];
00046 (*dp3_JacobianValue)[i][0] = numOfNonZeros;
00047 for(int j=1; j <= numOfNonZeros; j++) (*dp3_JacobianValue)[i][j] = 0.;
00048 }
00049
00050
00051 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00052 numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00053 for(int j=1; j <= numOfNonZeros; j++) {
00054 (*dp3_JacobianValue)[i][j] = dp2_CompressedMatrix[vi_LeftVertexColors[i]][uip2_JacobianSparsityPattern[i][j]];
00055 }
00056
00057 }
00058
00059 AF_available = true;
00060 i_AF_rowCount = rowCount;
00061 dp2_AF_Value = *dp3_JacobianValue;
00062
00063 return _TRUE;
00064 }
00065
00066 int JacobianRecovery1D::RecoverD2Row_SparseSolversFormat(BipartiteGraphPartialColoringInterface* g, double** dp2_CompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00067 if(g==NULL) {
00068 cerr<<"g==NULL"<<endl;
00069 return _FALSE;
00070 }
00071
00072 if(SSF_available) reset();
00073
00074 int rowCount = g->GetRowVertexCount();
00075 vector<int> vi_LeftVertexColors;
00076 g->GetLeftVertexColors(vi_LeftVertexColors);
00077 unsigned int numOfNonZeros = 0;
00078
00079
00080 g->GetRowVertices(ip2_RowIndex);
00081 numOfNonZeros = g->GetColumnIndices(ip2_ColumnIndex);
00082
00083
00084
00085 (*dp2_JacobianValue) = new double[numOfNonZeros];
00086 for(unsigned int i=0; i < numOfNonZeros; i++) (*dp2_JacobianValue)[i] = 0.;
00087
00088
00089 unsigned int numOfNonZerosInEachRow = 0;
00090 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00091 numOfNonZerosInEachRow = uip2_JacobianSparsityPattern[i][0];
00092 for(int j=1; j <= numOfNonZerosInEachRow; j++) {
00093 (*dp2_JacobianValue)[(*ip2_RowIndex)[i]+j-1] = dp2_CompressedMatrix[vi_LeftVertexColors[i]][uip2_JacobianSparsityPattern[i][j]];
00094 }
00095
00096 }
00097
00098
00099 for(unsigned int i=0; i <= (unsigned int)rowCount; i++) {
00100 (*ip2_RowIndex)[i]++;
00101 }
00102 for(unsigned int i=0; i < numOfNonZeros; i++) {
00103 (*ip2_ColumnIndex)[i]++;
00104 }
00105
00106 SSF_available = true;
00107 i_SSF_rowCount = rowCount;
00108 ip_SSF_RowIndex = *ip2_RowIndex;
00109 ip_SSF_ColumnIndex = *ip2_ColumnIndex;
00110 dp_SSF_Value = *dp2_JacobianValue;
00111
00112 return _TRUE;
00113 }
00114
00115 int JacobianRecovery1D::RecoverD2Row_CoordinateFormat(BipartiteGraphPartialColoringInterface* g, double** dp2_CompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00116 if(g==NULL) {
00117 cerr<<"g==NULL"<<endl;
00118 return _FALSE;
00119 }
00120
00121 if(CF_available) reset();
00122
00123 int rowCount = g->GetRowVertexCount();
00124 vector<int> vi_LeftVertexColors;
00125 g->GetLeftVertexColors(vi_LeftVertexColors);
00126 unsigned int numOfNonZeros = 0;
00127
00128 numOfNonZeros = g->GetEdgeCount();
00129 (*ip2_RowIndex) = new unsigned int[numOfNonZeros];
00130 (*ip2_ColumnIndex) = new unsigned int[numOfNonZeros];
00131 (*dp2_JacobianValue) = new double[numOfNonZeros];
00132
00133
00134 unsigned int numOfNonZeros_count = 0;
00135 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00136 numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00137 for(int j=1; j <= numOfNonZeros; j++) {
00138 (*dp2_JacobianValue)[numOfNonZeros_count] = dp2_CompressedMatrix[vi_LeftVertexColors[i]][uip2_JacobianSparsityPattern[i][j]];
00139 (*ip2_RowIndex)[numOfNonZeros_count] = i;
00140 (*ip2_ColumnIndex)[numOfNonZeros_count] = uip2_JacobianSparsityPattern[i][j];
00141 numOfNonZeros_count++;
00142 }
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 CF_available = true;
00155 i_CF_rowCount = rowCount;
00156 ip_CF_RowIndex = *ip2_RowIndex;
00157 ip_CF_ColumnIndex = *ip2_ColumnIndex;
00158 dp_CF_Value = *dp2_JacobianValue;
00159
00160 return _TRUE;
00161 }
00162
00163 int JacobianRecovery1D::RecoverD2Cln_RowCompressedFormat(BipartiteGraphPartialColoringInterface* g, double** dp2_CompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, double*** dp3_JacobianValue) {
00164 if(g==NULL) {
00165 cerr<<"g==NULL"<<endl;
00166 return _FALSE;
00167 }
00168
00169 if(AF_available) reset();
00170
00171 int rowCount = g->GetRowVertexCount();
00172 vector<int> vi_RightVertexColors;
00173 g->GetRightVertexColors(vi_RightVertexColors);
00174 unsigned int numOfNonZeros = 0;
00175
00176
00177
00178 *dp3_JacobianValue = new double*[rowCount];
00179 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00180 numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00181
00182 (*dp3_JacobianValue)[i] = new double[numOfNonZeros+1];
00183 (*dp3_JacobianValue)[i][0] = numOfNonZeros;
00184 for(unsigned int j=1; j <= numOfNonZeros; j++) (*dp3_JacobianValue)[i][j] = 0.;
00185 }
00186
00187
00188
00189 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00190 numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00191 for(unsigned int j=1; j <= numOfNonZeros; j++) {
00192 (*dp3_JacobianValue)[i][j] = dp2_CompressedMatrix[i][vi_RightVertexColors[uip2_JacobianSparsityPattern[i][j]]];
00193 }
00194
00195 }
00196
00197 AF_available = true;
00198 i_AF_rowCount = rowCount;
00199 dp2_AF_Value = *dp3_JacobianValue;
00200
00201 return _TRUE;
00202 }
00203
00204 int JacobianRecovery1D::RecoverD2Cln_SparseSolversFormat(BipartiteGraphPartialColoringInterface* g, double** dp2_CompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00205 if(g==NULL) {
00206 cerr<<"g==NULL"<<endl;
00207 return _FALSE;
00208 }
00209
00210 if(SSF_available) reset();
00211
00212 int rowCount = g->GetRowVertexCount();
00213 vector<int> vi_RightVertexColors;
00214 g->GetRightVertexColors(vi_RightVertexColors);
00215 unsigned int numOfNonZeros = 0;
00216
00217
00218 g->GetRowVertices(ip2_RowIndex);
00219 numOfNonZeros = g->GetColumnIndices(ip2_ColumnIndex);
00220
00221
00222
00223 (*dp2_JacobianValue) = new double[numOfNonZeros];
00224 for(unsigned int i=0; i < numOfNonZeros; i++) (*dp2_JacobianValue)[i] = 0.;
00225
00226
00227
00228 unsigned int numOfNonZerosInEachRow = 0;
00229 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00230 numOfNonZerosInEachRow = uip2_JacobianSparsityPattern[i][0];
00231 for(unsigned int j=1; j <= numOfNonZerosInEachRow; j++) {
00232 (*dp2_JacobianValue)[(*ip2_RowIndex)[i]+j-1] = dp2_CompressedMatrix[i][vi_RightVertexColors[uip2_JacobianSparsityPattern[i][j]]];
00233 }
00234 }
00235
00236
00237
00238 for(unsigned int i=0; i <= (unsigned int)rowCount; i++) {
00239 (*ip2_RowIndex)[i]++;
00240 }
00241 for(unsigned int i=0; i < numOfNonZeros; i++) {
00242 (*ip2_ColumnIndex)[i]++;
00243 }
00244
00245
00246 SSF_available = true;
00247 i_SSF_rowCount = rowCount;
00248 ip_SSF_RowIndex = *ip2_RowIndex;
00249 ip_SSF_ColumnIndex = *ip2_ColumnIndex;
00250 dp_SSF_Value = *dp2_JacobianValue;
00251
00252 return _TRUE;
00253 }
00254
00255 int JacobianRecovery1D::RecoverD2Cln_CoordinateFormat(BipartiteGraphPartialColoringInterface* g, double** dp2_CompressedMatrix, unsigned int ** uip2_JacobianSparsityPattern, unsigned int** ip2_RowIndex, unsigned int** ip2_ColumnIndex, double** dp2_JacobianValue) {
00256 if(g==NULL) {
00257 cerr<<"g==NULL"<<endl;
00258 return _FALSE;
00259 }
00260
00261 if(CF_available) reset();
00262
00263 int rowCount = g->GetRowVertexCount();
00264 vector<int> vi_RightVertexColors;
00265 g->GetRightVertexColors(vi_RightVertexColors);
00266 unsigned int numOfNonZeros = 0;
00267
00268 numOfNonZeros = g->GetEdgeCount();
00269 (*ip2_RowIndex) = new unsigned int[numOfNonZeros];
00270 (*ip2_ColumnIndex) = new unsigned int[numOfNonZeros];
00271 (*dp2_JacobianValue) = new double[numOfNonZeros];
00272
00273
00274
00275 unsigned int numOfNonZeros_count = 0;
00276 for(unsigned int i=0; i < (unsigned int)rowCount; i++) {
00277 numOfNonZeros = uip2_JacobianSparsityPattern[i][0];
00278 for(unsigned int j=1; j <= numOfNonZeros; j++) {
00279 (*dp2_JacobianValue)[numOfNonZeros_count] = dp2_CompressedMatrix[i][vi_RightVertexColors[uip2_JacobianSparsityPattern[i][j]]];
00280 (*ip2_RowIndex)[numOfNonZeros_count] = i;
00281 (*ip2_ColumnIndex)[numOfNonZeros_count] = uip2_JacobianSparsityPattern[i][j];
00282 numOfNonZeros_count++;
00283 }
00284 }
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 CF_available = true;
00296 i_CF_rowCount = rowCount;
00297 ip_CF_RowIndex = *ip2_RowIndex;
00298 ip_CF_ColumnIndex = *ip2_ColumnIndex;
00299 dp_CF_Value = *dp2_JacobianValue;
00300
00301 return _TRUE;
00302 }
00303 }