Changeset 461 for trunk/ClpPackedMatrix.cpp
 Timestamp:
 Oct 1, 2004 4:01:01 PM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ClpPackedMatrix.cpp
r426 r461 1134 1134 } 1135 1135 } 1136 /* If element NULL returns number of elements in column part of basis, 1137 If not NULL fills in as well */ 1136 /// returns number of elements in column part of basis, 1138 1137 CoinBigIndex 1139 ClpPackedMatrix:: fillBasis(ClpSimplex * model,1138 ClpPackedMatrix::countBasis(ClpSimplex * model, 1140 1139 const int * whichColumn, 1141 1140 int numberBasic, 1142 int & numberColumnBasic, 1143 int * indexRowU, int * indexColumnU, 1144 double * elementU) 1141 int & numberColumnBasic) 1145 1142 { 1146 1143 const int * columnLength = matrix_>getVectorLengths(); 1147 1144 int i; 1148 1145 CoinBigIndex numberElements=0; 1149 if (elementU!=NULL) { 1150 // fill 1151 const CoinBigIndex * columnStart = matrix_>getVectorStarts(); 1152 const double * rowScale = model>rowScale(); 1153 const int * row = matrix_>getIndices(); 1154 const double * elementByColumn = matrix_>getElements(); 1155 if (!zeroElements_) { 1156 if (!rowScale) { 1157 // no scaling 1158 for (i=0;i<numberColumnBasic;i++) { 1159 int iColumn = whichColumn[i]; 1160 CoinBigIndex j; 1161 for (j=columnStart[iColumn]; 1162 j<columnStart[iColumn]+columnLength[iColumn];j++) { 1163 indexRowU[numberElements]=row[j]; 1164 indexColumnU[numberElements]=numberBasic; 1165 elementU[numberElements++]=elementByColumn[j]; 1166 } 1167 numberBasic++; 1168 } 1169 } else { 1170 // scaling 1171 const double * columnScale = model>columnScale(); 1172 for (i=0;i<numberColumnBasic;i++) { 1173 int iColumn = whichColumn[i]; 1174 CoinBigIndex j; 1175 double scale = columnScale[iColumn]; 1176 for (j=columnStart[iColumn]; 1177 j<columnStart[iColumn]+columnLength[iColumn];j++) { 1146 // just count  can be over so ignore zero problem 1147 for (i=0;i<numberColumnBasic;i++) { 1148 int iColumn = whichColumn[i]; 1149 numberElements += columnLength[iColumn]; 1150 } 1151 return numberElements; 1152 } 1153 void 1154 ClpPackedMatrix::fillBasis(ClpSimplex * model, 1155 const int * whichColumn, 1156 int & numberColumnBasic, 1157 int * indexRowU, int * start, 1158 int * rowCount, int * columnCount, 1159 double * elementU) 1160 { 1161 const int * columnLength = matrix_>getVectorLengths(); 1162 int i; 1163 CoinBigIndex numberElements=start[0]; 1164 // fill 1165 const CoinBigIndex * columnStart = matrix_>getVectorStarts(); 1166 const double * rowScale = model>rowScale(); 1167 const int * row = matrix_>getIndices(); 1168 const double * elementByColumn = matrix_>getElements(); 1169 if (!zeroElements_) { 1170 if (!rowScale) { 1171 // no scaling 1172 for (i=0;i<numberColumnBasic;i++) { 1173 int iColumn = whichColumn[i]; 1174 CoinBigIndex j; 1175 for (j=columnStart[iColumn]; 1176 j<columnStart[iColumn]+columnLength[iColumn];j++) { 1177 int iRow=row[j]; 1178 indexRowU[numberElements]=iRow; 1179 rowCount[iRow]++; 1180 elementU[numberElements++]=elementByColumn[j]; 1181 } 1182 start[i+1]=numberElements; 1183 columnCount[i]=columnLength[iColumn]; 1184 } 1185 } else { 1186 // scaling 1187 const double * columnScale = model>columnScale(); 1188 for (i=0;i<numberColumnBasic;i++) { 1189 int iColumn = whichColumn[i]; 1190 CoinBigIndex j; 1191 double scale = columnScale[iColumn]; 1192 for (j=columnStart[iColumn]; 1193 j<columnStart[iColumn]+columnLength[iColumn];j++) { 1194 int iRow = row[j]; 1195 indexRowU[numberElements]=iRow; 1196 rowCount[iRow]++; 1197 elementU[numberElements++]= 1198 elementByColumn[j]*scale*rowScale[iRow]; 1199 } 1200 start[i+1]=numberElements; 1201 columnCount[i]=columnLength[iColumn]; 1202 } 1203 } 1204 } else { 1205 // there are zero elements so need to look more closely 1206 if (!rowScale) { 1207 // no scaling 1208 for (i=0;i<numberColumnBasic;i++) { 1209 int iColumn = whichColumn[i]; 1210 CoinBigIndex j; 1211 for (j=columnStart[iColumn]; 1212 j<columnStart[iColumn]+columnLength[iColumn];j++) { 1213 double value = elementByColumn[j]; 1214 if (value) { 1178 1215 int iRow = row[j]; 1179 1216 indexRowU[numberElements]=iRow; 1180 indexColumnU[numberElements]=numberBasic;1181 elementU[numberElements++]= 1182 elementByColumn[j]*scale*rowScale[iRow];1183 1184 numberBasic++;1185 }1217 rowCount[iRow]++; 1218 elementU[numberElements++]=value; 1219 } 1220 } 1221 start[i+1]=numberElements; 1222 columnCount[i]=numberElementsstart[i]; 1186 1223 } 1187 1224 } else { 1188 // there are zero elements so need to look more closely 1189 if (!rowScale) { 1190 // no scaling 1191 for (i=0;i<numberColumnBasic;i++) { 1192 int iColumn = whichColumn[i]; 1193 CoinBigIndex j; 1194 for (j=columnStart[iColumn]; 1195 j<columnStart[iColumn]+columnLength[iColumn];j++) { 1196 double value = elementByColumn[j]; 1197 if (value) { 1198 indexRowU[numberElements]=row[j]; 1199 indexColumnU[numberElements]=numberBasic; 1200 elementU[numberElements++]=value; 1201 } 1202 } 1203 numberBasic++; 1204 } 1205 } else { 1206 // scaling 1207 const double * columnScale = model>columnScale(); 1208 for (i=0;i<numberColumnBasic;i++) { 1209 int iColumn = whichColumn[i]; 1210 CoinBigIndex j; 1211 double scale = columnScale[iColumn]; 1212 for (j=columnStart[iColumn]; 1213 j<columnStart[iColumn]+columnLength[i];j++) { 1214 double value = elementByColumn[j]; 1215 if (value) { 1216 int iRow = row[j]; 1217 indexRowU[numberElements]=iRow; 1218 indexColumnU[numberElements]=numberBasic; 1219 elementU[numberElements++]=value*scale*rowScale[iRow]; 1220 } 1221 } 1222 numberBasic++; 1223 } 1224 } 1225 } 1226 } else { 1227 // just count  can be over so ignore zero problem 1228 for (i=0;i<numberColumnBasic;i++) { 1229 int iColumn = whichColumn[i]; 1230 numberElements += columnLength[iColumn]; 1231 } 1232 } 1233 return numberElements; 1225 // scaling 1226 const double * columnScale = model>columnScale(); 1227 for (i=0;i<numberColumnBasic;i++) { 1228 int iColumn = whichColumn[i]; 1229 CoinBigIndex j; 1230 double scale = columnScale[iColumn]; 1231 for (j=columnStart[iColumn]; 1232 j<columnStart[iColumn]+columnLength[i];j++) { 1233 double value = elementByColumn[j]; 1234 if (value) { 1235 int iRow = row[j]; 1236 indexRowU[numberElements]=iRow; 1237 rowCount[iRow]++; 1238 elementU[numberElements++]=value*scale*rowScale[iRow]; 1239 } 1240 } 1241 start[i+1]=numberElements; 1242 columnCount[i]=numberElementsstart[i]; 1243 } 1244 } 1245 } 1234 1246 } 1235 1247 // Creates scales for column copy (rowCopy in model may be modified)
Note: See TracChangeset
for help on using the changeset viewer.