#include <ClpPlusMinusOneMatrix.hpp>
Inheritance diagram for ClpPlusMinusOneMatrix:
Public Member Functions | |
Useful methods | |
virtual CoinPackedMatrix * | getPackedMatrix () const |
Return a complete CoinPackedMatrix. | |
virtual bool | isColOrdered () const |
virtual CoinBigIndex | getNumElements () const |
virtual int | getNumCols () const |
virtual int | getNumRows () const |
virtual const double * | getElements () const |
virtual const int * | getIndices () const |
virtual const CoinBigIndex * | getVectorStarts () const |
virtual const int * | getVectorLengths () const |
virtual void | deleteCols (const int numDel, const int *indDel) |
virtual void | deleteRows (const int numDel, const int *indDel) |
virtual void | appendCols (int number, const CoinPackedVectorBase *const *columns) |
Append Columns. | |
virtual void | appendRows (int number, const CoinPackedVectorBase *const *rows) |
Append Rows. | |
virtual ClpMatrixBase * | reverseOrderedCopy () const |
virtual CoinBigIndex | numberInBasis (const int *columnIsBasic) const |
virtual CoinBigIndex | fillBasis (const ClpSimplex *model, const int *columnIsBasic, int &numberBasic, int *row, int *column, double *element) const |
Fills in basis (Returns number of elements and updates numberBasic). | |
virtual CoinBigIndex | fillBasis (const ClpSimplex *model, const int *whichColumn, int numberRowBasic, int numberColumnBasic, int *row, int *column, double *element) const |
virtual CoinBigIndex * | dubiousWeights (const ClpSimplex *model, int *inputWeights) const |
virtual void | rangeOfElements (double &smallestNegative, double &largestNegative, double &smallestPositive, double &largestPositive) |
virtual void | unpack (const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const |
virtual void | unpackPacked (ClpSimplex *model, CoinIndexedVector *rowArray, int column) const |
virtual void | add (const ClpSimplex *model, CoinIndexedVector *rowArray, int column, double multiplier) const |
virtual void | releasePlusMinusOneMatrix () const |
Allow any parts of a created CoinMatrix to be deleted. | |
Matrix times vector methods | |
virtual void | times (double scalar, const double *x, double *y) const |
virtual void | times (double scalar, const double *x, double *y, const double *rowScale, const double *columnScale) const |
And for scaling. | |
virtual void | transposeTimes (double scalar, const double *x, double *y) const |
virtual void | transposeTimes (double scalar, const double *x, double *y, const double *rowScale, const double *columnScale) const |
And for scaling. | |
virtual void | transposeTimes (const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const |
virtual void | transposeTimesByRow (const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const |
virtual void | subsetTransposeTimes (const ClpSimplex *model, const CoinIndexedVector *x, const CoinIndexedVector *y, CoinIndexedVector *z) const |
Other | |
int * | startPositive () const |
Return starts of +1s. | |
int * | startNegative () const |
Return starts of -1s. | |
Constructors, destructor | |
ClpPlusMinusOneMatrix () | |
virtual | ~ClpPlusMinusOneMatrix () |
Copy method | |
ClpPlusMinusOneMatrix (const ClpPlusMinusOneMatrix &) | |
ClpPlusMinusOneMatrix (const CoinPackedMatrix &) | |
ClpPlusMinusOneMatrix (const ClpPlusMinusOneMatrix &wholeModel, int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) | |
ClpPlusMinusOneMatrix & | operator= (const ClpPlusMinusOneMatrix &) |
virtual ClpMatrixBase * | clone () const |
Clone. | |
virtual ClpMatrixBase * | subsetClone (int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) const |
void | passInCopy (int numberRows, int numberColumns, bool columnOrdered, int *indices, int *startPositive, int *startNegative) |
pass in copy (object takes ownership) | |
virtual bool | canDoPartialPricing () const |
Says whether it can do partial pricing. | |
virtual void | partialPricing (ClpSimplex *model, int start, int end, int &bestSequence, int &numberWanted) |
Partial pricing. | |
Protected Attributes | |
Data members | |
The data members are protected to allow access for derived classes. | |
double * | elements_ |
For fake CoinPackedMatrix. | |
int * | lengths_ |
int * | startPositive_ |
Start of +1's for each. | |
int * | startNegative_ |
Start of -1's for each. | |
int * | indices_ |
Data -1, then +1 rows in pairs (row==-1 if one entry). | |
int | numberRows_ |
Number of rows. | |
int | numberColumns_ |
Number of columns. | |
bool | columnOrdered_ |
True if column ordered. |
Definition at line 15 of file ClpPlusMinusOneMatrix.hpp.
|
Default constructor. Definition at line 24 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, elements_, indices_, numberColumns_, numberRows_, ClpMatrixBase::setType(), startNegative_, and startPositive_. Referenced by clone(), reverseOrderedCopy(), and subsetClone().
00025 : ClpMatrixBase() 00026 { 00027 setType(12); 00028 elements_ = NULL; 00029 startPositive_ = NULL; 00030 startNegative_ = NULL; 00031 lengths_=NULL; 00032 indices_=NULL; 00033 numberRows_=0; 00034 numberColumns_=0; 00035 columnOrdered_=true; 00036 } |
|
Destructor Definition at line 137 of file ClpPlusMinusOneMatrix.cpp. References elements_, indices_, startNegative_, and startPositive_.
00138 { 00139 delete [] elements_; 00140 delete [] startPositive_; 00141 delete [] startNegative_; 00142 delete [] lengths_; 00143 delete [] indices_; 00144 } |
|
The copy constructor. Definition at line 41 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, elements_, indices_, numberColumns_, numberRows_, startNegative_, and startPositive_.
00042 : ClpMatrixBase(rhs) 00043 { 00044 elements_ = NULL; 00045 startPositive_ = NULL; 00046 startNegative_ = NULL; 00047 lengths_=NULL; 00048 indices_=NULL; 00049 numberRows_=rhs.numberRows_; 00050 numberColumns_=rhs.numberColumns_; 00051 columnOrdered_=rhs.columnOrdered_; 00052 if (numberColumns_) { 00053 int numberElements = rhs.startPositive_[numberColumns_]; 00054 indices_ = new int [ numberElements]; 00055 memcpy(indices_,rhs.indices_,numberElements*sizeof(int)); 00056 startPositive_ = new int [ numberColumns_+1]; 00057 memcpy(startPositive_,rhs.startPositive_,(numberColumns_+1)*sizeof(int)); 00058 startNegative_ = new int [ numberColumns_]; 00059 memcpy(startNegative_,rhs.startNegative_,numberColumns_*sizeof(int)); 00060 } 00061 } |
|
The copy constructor from an CoinPlusMinusOneMatrix. Definition at line 63 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, elements_, indices_, numberColumns_, numberRows_, ClpMatrixBase::setType(), startNegative_, and startPositive_.
00064 : ClpMatrixBase() 00065 { 00066 setType(12); 00067 elements_ = NULL; 00068 startPositive_ = NULL; 00069 startNegative_ = NULL; 00070 lengths_=NULL; 00071 indices_=NULL; 00072 int iColumn; 00073 assert (rhs.isColOrdered()); 00074 // get matrix data pointers 00075 const int * row = rhs.getIndices(); 00076 const CoinBigIndex * columnStart = rhs.getVectorStarts(); 00077 const int * columnLength = rhs.getVectorLengths(); 00078 const double * elementByColumn = rhs.getElements(); 00079 numberColumns_ = rhs.getNumCols(); 00080 bool goodPlusMinusOne=true; 00081 numberRows_=-1; 00082 indices_ = new int[rhs.getNumElements()]; 00083 startPositive_ = new int [numberColumns_+1]; 00084 startNegative_ = new int [numberColumns_]; 00085 int * temp = new int [rhs.getNumRows()]; 00086 CoinBigIndex j=0; 00087 for (iColumn=0;iColumn<numberColumns_;iColumn++) { 00088 CoinBigIndex k; 00089 int iNeg=0; 00090 startPositive_[iColumn]=j; 00091 for (k=columnStart[iColumn];k<columnStart[iColumn]+columnLength[iColumn]; 00092 k++) { 00093 int iRow; 00094 if (fabs(elementByColumn[k]-1.0)<1.0e-10) { 00095 iRow = row[k]; 00096 numberRows_ = max(numberRows_,iRow); 00097 indices_[j++]=iRow; 00098 } else if (fabs(elementByColumn[k]+1.0)<1.0e-10) { 00099 iRow = row[k]; 00100 numberRows_ = max(numberRows_,iRow); 00101 temp[iNeg++]=iRow; 00102 } else { 00103 goodPlusMinusOne = false; // not a network 00104 } 00105 } 00106 if (goodPlusMinusOne) { 00107 // move negative 00108 startNegative_[iColumn]=j; 00109 for (k=0;k<iNeg;k++) { 00110 indices_[j++] = temp[k]; 00111 } 00112 } else { 00113 break; 00114 } 00115 } 00116 startPositive_[numberColumns_]=j; 00117 delete [] temp; 00118 if (!goodPlusMinusOne) { 00119 delete [] indices_; 00120 // put in message 00121 indices_=NULL; 00122 numberRows_=0; 00123 numberColumns_=0; 00124 delete [] startPositive_; 00125 delete [] startNegative_; 00126 startPositive_ = NULL; 00127 startNegative_ = NULL; 00128 } else { 00129 numberRows_ ++; // correct 00130 columnOrdered_ = true; 00131 } 00132 } |
|
Subset constructor (without gaps). Duplicates are allowed and order is as given Definition at line 197 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, elements_, indices_, numberColumns_, numberRows_, startNegative_, and startPositive_.
00201 : ClpMatrixBase(rhs) 00202 { 00203 elements_ = NULL; 00204 startPositive_ = NULL; 00205 startNegative_ = NULL; 00206 lengths_=NULL; 00207 indices_=NULL; 00208 numberRows_=0; 00209 numberColumns_=0; 00210 columnOrdered_=rhs.columnOrdered_; 00211 if (numberRows<=0||numberColumns<=0) { 00212 startPositive_ = new int[1]; 00213 startPositive_[0] = 0; 00214 } else { 00215 numberColumns_ = numberColumns; 00216 numberRows_ = numberRows; 00217 const int * index1 = rhs.indices_; 00218 int * startPositive1 = rhs.startPositive_; 00219 00220 int numberMinor = (!columnOrdered_) ? numberColumns_ : numberRows_; 00221 int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_; 00222 int numberMinor1 = (!columnOrdered_) ? rhs.numberColumns_ : rhs.numberRows_; 00223 int numberMajor1 = (columnOrdered_) ? rhs.numberColumns_ : rhs.numberRows_; 00224 // Also swap incoming if not column ordered 00225 if (!columnOrdered_) { 00226 int temp1 = numberRows; 00227 numberRows = numberColumns; 00228 numberColumns = temp1; 00229 const int * temp2; 00230 temp2 = whichRow; 00231 whichRow = whichColumn; 00232 whichColumn = temp2; 00233 } 00234 // Throw exception if rhs empty 00235 if (numberMajor1 <= 0 || numberMinor1 <= 0) 00236 throw CoinError("empty rhs", "subset constructor", "ClpPlusMinusOneMatrix"); 00237 // Array to say if an old row is in new copy 00238 int * newRow = new int [numberMinor1]; 00239 int iRow; 00240 for (iRow=0;iRow<numberMinor1;iRow++) 00241 newRow[iRow] = -1; 00242 // and array for duplicating rows 00243 int * duplicateRow = new int [numberMinor]; 00244 int numberBad=0; 00245 for (iRow=0;iRow<numberMinor;iRow++) { 00246 duplicateRow[iRow] = -1; 00247 int kRow = whichRow[iRow]; 00248 if (kRow>=0 && kRow < numberMinor1) { 00249 if (newRow[kRow]<0) { 00250 // first time 00251 newRow[kRow]=iRow; 00252 } else { 00253 // duplicate 00254 int lastRow = newRow[kRow]; 00255 newRow[kRow]=iRow; 00256 duplicateRow[iRow] = lastRow; 00257 } 00258 } else { 00259 // bad row 00260 numberBad++; 00261 } 00262 } 00263 00264 if (numberBad) 00265 throw CoinError("bad minor entries", 00266 "subset constructor", "ClpPlusMinusOneMatrix"); 00267 // now get size and check columns 00268 int size = 0; 00269 int iColumn; 00270 numberBad=0; 00271 for (iColumn=0;iColumn<numberMajor;iColumn++) { 00272 int kColumn = whichColumn[iColumn]; 00273 if (kColumn>=0 && kColumn <numberMajor1) { 00274 int i; 00275 for (i=startPositive1[kColumn];i<startPositive1[kColumn+1];i++) { 00276 int kRow = index1[i]; 00277 kRow = newRow[kRow]; 00278 while (kRow>=0) { 00279 size++; 00280 kRow = duplicateRow[kRow]; 00281 } 00282 } 00283 } else { 00284 // bad column 00285 numberBad++; 00286 printf("%d %d %d %d\n",iColumn,numberMajor,numberMajor1,kColumn); 00287 } 00288 } 00289 if (numberBad) 00290 throw CoinError("bad major entries", 00291 "subset constructor", "ClpPlusMinusOneMatrix"); 00292 // now create arrays 00293 startPositive_ = new int [numberMajor+1]; 00294 startNegative_ = new int [numberMajor]; 00295 indices_ = new int[size]; 00296 // and fill them 00297 size = 0; 00298 startPositive_[0]=0; 00299 int * startNegative1 = rhs.startNegative_; 00300 for (iColumn=0;iColumn<numberMajor;iColumn++) { 00301 int kColumn = whichColumn[iColumn]; 00302 int i; 00303 for (i=startPositive1[kColumn];i<startNegative1[kColumn];i++) { 00304 int kRow = index1[i]; 00305 kRow = newRow[kRow]; 00306 while (kRow>=0) { 00307 indices_[size++] = kRow; 00308 kRow = duplicateRow[kRow]; 00309 } 00310 } 00311 startNegative_[iColumn] = size; 00312 for (;i<startPositive1[kColumn+1];i++) { 00313 int kRow = index1[i]; 00314 kRow = newRow[kRow]; 00315 while (kRow>=0) { 00316 indices_[size++] = kRow; 00317 kRow = duplicateRow[kRow]; 00318 } 00319 } 00320 startPositive_[iColumn+1] = size; 00321 } 00322 delete [] newRow; 00323 delete [] duplicateRow; 00324 } 00325 } |
|
Adds multiple of a column into an CoinIndexedvector You can use quickAdd to add to vector Implements ClpMatrixBase. Definition at line 1016 of file ClpPlusMinusOneMatrix.cpp. References indices_, CoinIndexedVector::quickAdd(), startNegative_, and startPositive_.
01018 { 01019 CoinBigIndex j=startPositive_[iColumn]; 01020 for (;j<startNegative_[iColumn];j++) { 01021 int iRow = indices_[j]; 01022 rowArray->quickAdd(iRow,multiplier); 01023 } 01024 for (;j<startPositive_[iColumn+1];j++) { 01025 int iRow = indices_[j]; 01026 rowArray->quickAdd(iRow,-multiplier); 01027 } 01028 } |
|
Delete the columns whose indices are listed in Implements ClpMatrixBase. Definition at line 1088 of file ClpPlusMinusOneMatrix.cpp. References elements_, indices_, numberColumns_, startNegative_, and startPositive_.
01089 { 01090 int iColumn; 01091 int newSize=startPositive_[numberColumns_];; 01092 int numberBad=0; 01093 // Use array to make sure we can have duplicates 01094 int * which = new int[numberColumns_]; 01095 memset(which,0,numberColumns_*sizeof(int)); 01096 int nDuplicate=0; 01097 for (iColumn=0;iColumn<numDel;iColumn++) { 01098 int jColumn = indDel[iColumn]; 01099 if (jColumn<0||jColumn>=numberColumns_) { 01100 numberBad++; 01101 } else { 01102 newSize -= startPositive_[jColumn+1]-startPositive_[jColumn]; 01103 if (which[jColumn]) 01104 nDuplicate++; 01105 else 01106 which[jColumn]=1; 01107 } 01108 } 01109 if (numberBad) 01110 throw CoinError("Indices out of range", "deleteCols", "ClpPlusMinusOneMatrix"); 01111 int newNumber = numberColumns_-numDel+nDuplicate; 01112 // Get rid of temporary arrays 01113 delete [] lengths_; 01114 lengths_=NULL; 01115 delete [] elements_; 01116 elements_= NULL; 01117 int * newPositive = new int [newNumber+1]; 01118 int * newNegative = new int [newNumber]; 01119 int * newIndices = new int [newSize]; 01120 newNumber=0; 01121 newSize=0; 01122 for (iColumn=0;iColumn<numberColumns_;iColumn++) { 01123 if (!which[iColumn]) { 01124 int start,end; 01125 int i; 01126 start = startPositive_[iColumn]; 01127 end=startNegative_[iColumn]; 01128 newPositive[newNumber]=newSize; 01129 for (i=start;i<end;i++) 01130 newIndices[newSize++]=indices_[i]; 01131 start = startNegative_[iColumn]; 01132 end=startPositive_[iColumn+1]; 01133 newNegative[newNumber++]=newSize; 01134 for (i=start;i<end;i++) 01135 newIndices[newSize++]=indices_[i]; 01136 } 01137 } 01138 newPositive[newNumber]=newSize; 01139 delete [] which; 01140 delete [] startPositive_; 01141 startPositive_= newPositive; 01142 delete [] startNegative_; 01143 startNegative_= newNegative; 01144 delete [] indices_; 01145 indices_= newIndices; 01146 numberColumns_ = newNumber; 01147 } |
|
Delete the rows whose indices are listed in Implements ClpMatrixBase. Definition at line 1150 of file ClpPlusMinusOneMatrix.cpp. References elements_, indices_, numberColumns_, numberRows_, startNegative_, and startPositive_.
01151 { 01152 int iRow; 01153 int numberBad=0; 01154 // Use array to make sure we can have duplicates 01155 int * which = new int[numberRows_]; 01156 memset(which,0,numberRows_*sizeof(int)); 01157 int nDuplicate=0; 01158 for (iRow=0;iRow<numDel;iRow++) { 01159 int jRow = indDel[iRow]; 01160 if (jRow<0||jRow>=numberRows_) { 01161 numberBad++; 01162 } else { 01163 if (which[jRow]) 01164 nDuplicate++; 01165 else 01166 which[jRow]=1; 01167 } 01168 } 01169 if (numberBad) 01170 throw CoinError("Indices out of range", "deleteCols", "ClpPlusMinusOneMatrix"); 01171 int iElement; 01172 int numberElements=startPositive_[numberColumns_]; 01173 int newSize=0; 01174 for (iElement=0;iElement<numberElements;iElement++) { 01175 iRow = indices_[iElement]; 01176 if (!which[iRow]) 01177 newSize++; 01178 } 01179 int newNumber = numberRows_-numDel+nDuplicate; 01180 // Get rid of temporary arrays 01181 delete [] lengths_; 01182 lengths_=NULL; 01183 delete [] elements_; 01184 elements_= NULL; 01185 int * newIndices = new int [newSize]; 01186 newSize=0; 01187 int iColumn; 01188 for (iColumn=0;iColumn<numberColumns_;iColumn++) { 01189 int start,end; 01190 int i; 01191 start = startPositive_[iColumn]; 01192 end=startNegative_[iColumn]; 01193 startPositive_[newNumber]=newSize; 01194 for (i=start;i<end;i++) { 01195 iRow = indices_[i]; 01196 if (!which[iRow]) 01197 newIndices[newSize++]=iRow; 01198 } 01199 start = startNegative_[iColumn]; 01200 end=startPositive_[iColumn+1]; 01201 startNegative_[newNumber]=newSize; 01202 for (i=start;i<end;i++) { 01203 iRow = indices_[i]; 01204 if (!which[iRow]) 01205 newIndices[newSize++]=iRow; 01206 } 01207 } 01208 startPositive_[numberColumns_]=newSize; 01209 delete [] which; 01210 delete [] indices_; 01211 indices_= newIndices; 01212 numberRows_ = newNumber; 01213 } |
|
Given positive integer weights for each row fills in sum of weights for each column (and slack). Returns weights vector Reimplemented from ClpMatrixBase. Definition at line 1247 of file ClpPlusMinusOneMatrix.cpp. References indices_, ClpModel::numberColumns(), ClpModel::numberRows(), and startPositive_.
01248 { 01249 int numberRows = model->numberRows(); 01250 int numberColumns =model->numberColumns(); 01251 int number = numberRows+numberColumns; 01252 CoinBigIndex * weights = new CoinBigIndex[number]; 01253 int i; 01254 for (i=0;i<numberColumns;i++) { 01255 CoinBigIndex j; 01256 CoinBigIndex count=0; 01257 for (j=startPositive_[i];j<startPositive_[i+1];j++) { 01258 int iRow=indices_[j]; 01259 count += inputWeights[iRow]; 01260 } 01261 weights[i]=count; 01262 } 01263 for (i=0;i<numberRows;i++) { 01264 weights[i+numberColumns]=inputWeights[i]; 01265 } 01266 return weights; 01267 } |
|
If element NULL returns number of elements in column part of basis, If not NULL fills in as well Implements ClpMatrixBase. Definition at line 934 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, indices_, startNegative_, and startPositive_.
00940 { 00941 int i; 00942 CoinBigIndex numberElements=0; 00943 if (elementU!=NULL) { 00944 assert (columnOrdered_); 00945 for (i=0;i<numberColumnBasic;i++) { 00946 int iColumn = whichColumn[i]; 00947 CoinBigIndex j=startPositive_[iColumn]; 00948 for (;j<startNegative_[iColumn];j++) { 00949 int iRow = indices_[j]; 00950 indexRowU[numberElements]=iRow; 00951 indexColumnU[numberElements]=numberBasic; 00952 elementU[numberElements++]=1.0; 00953 } 00954 for (;j<startPositive_[iColumn+1];j++) { 00955 int iRow = indices_[j]; 00956 indexRowU[numberElements]=iRow; 00957 indexColumnU[numberElements]=numberBasic; 00958 elementU[numberElements++]=-1.0; 00959 } 00960 numberBasic++; 00961 } 00962 } else { 00963 for (i=0;i<numberColumnBasic;i++) { 00964 int iColumn = whichColumn[i]; 00965 numberElements += startPositive_[iColumn+1]-startPositive_[iColumn]; 00966 } 00967 } 00968 return numberElements; 00969 } |
|
A vector containing the elements in the packed matrix. Note that there might be gaps in this list, entries that do not belong to any major-dimension vector. To get the actual elements one should look at this vector together with vectorStarts and vectorLengths. Implements ClpMatrixBase. Definition at line 1047 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, elements_, numberColumns_, numberRows_, startNegative_, and startPositive_. Referenced by getPackedMatrix().
01048 { 01049 if (!elements_) { 01050 int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_; 01051 int numberElements = startPositive_[numberMajor]; 01052 elements_ = new double [numberElements]; 01053 CoinBigIndex j=0; 01054 int i; 01055 for (i=0;i<numberMajor;i++) { 01056 for (;j<startNegative_[i];j++) { 01057 elements_[j]=1.0; 01058 } 01059 for (;j<startPositive_[i+1];j++) { 01060 elements_[j]=-1.0; 01061 } 01062 } 01063 } 01064 return elements_; 01065 } |
|
A vector containing the minor indices of the elements in the packed matrix. Note that there might be gaps in this list, entries that do not belong to any major-dimension vector. To get the actual elements one should look at this vector together with vectorStarts and vectorLengths. Implements ClpMatrixBase. Definition at line 41 of file ClpPlusMinusOneMatrix.hpp. References indices_. Referenced by ClpSimplex::initialSolve().
00042 { return indices_;}; |
|
Number of columns. Implements ClpMatrixBase. Definition at line 27 of file ClpPlusMinusOneMatrix.hpp. References numberColumns_.
00027 { return numberColumns_; } |
|
Number of entries in the packed matrix. Implements ClpMatrixBase. Definition at line 1221 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, numberColumns_, numberRows_, and startPositive_. Referenced by getPackedMatrix().
01222 { 01223 int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_; 01224 if (startPositive_) 01225 return startPositive_[numberMajor]; 01226 else 01227 return 0; 01228 } |
|
Number of rows. Implements ClpMatrixBase. Definition at line 29 of file ClpPlusMinusOneMatrix.hpp. References numberRows_.
00029 { return numberRows_; }; |
|
The lengths of the major-dimension vectors. Implements ClpMatrixBase. Definition at line 1074 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, numberColumns_, numberRows_, and startPositive_. Referenced by getPackedMatrix().
01075 { 01076 if (!lengths_) { 01077 int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_; 01078 lengths_ = new int [numberMajor]; 01079 int i; 01080 for (i=0;i<numberMajor;i++) { 01081 lengths_[i]=startPositive_[i+1]-startPositive_[i]; 01082 } 01083 } 01084 return lengths_; 01085 } |
|
Whether the packed matrix is column major ordered or not. Implements ClpMatrixBase. Definition at line 1215 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_.
01216 { 01217 return columnOrdered_; 01218 } |
|
Returns number of elements in basis column is basic if entry >=0 Implements ClpMatrixBase. Definition at line 886 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, numberColumns_, and startPositive_.
00887 { 00888 int i; 00889 CoinBigIndex numberElements=0; 00890 assert (columnOrdered_); 00891 for (i=0;i<numberColumns_;i++) { 00892 if (columnIsBasic[i]>=0) 00893 numberElements += startPositive_[i+1]-startPositive_[i]; 00894 } 00895 return numberElements; 00896 } |
|
Returns largest and smallest elements of both signs. Largest refers to largest absolute value. Reimplemented from ClpMatrixBase. Definition at line 1416 of file ClpPlusMinusOneMatrix.cpp. References numberColumns_, startNegative_, and startPositive_.
01418 { 01419 int iColumn; 01420 bool plusOne=false; 01421 bool minusOne=false; 01422 for (iColumn=0;iColumn<numberColumns_;iColumn++) { 01423 if (startNegative_[iColumn]>startPositive_[iColumn]) 01424 plusOne=true; 01425 if (startPositive_[iColumn+1]>startNegative_[iColumn]) 01426 minusOne=true; 01427 } 01428 if (minusOne) { 01429 smallestNegative=-1.0; 01430 largestNegative=-1.0; 01431 } else { 01432 smallestNegative=0.0; 01433 largestNegative=0.0; 01434 } 01435 if (plusOne) { 01436 smallestPositive=1.0; 01437 largestPositive=1.0; 01438 } else { 01439 smallestPositive=0.0; 01440 largestPositive=0.0; 01441 } 01442 } |
|
Returns a new matrix in reverse order without gaps Reimplemented from ClpMatrixBase. Definition at line 330 of file ClpPlusMinusOneMatrix.cpp. References ClpPlusMinusOneMatrix(), columnOrdered_, indices_, numberColumns_, numberRows_, passInCopy(), startNegative_, and startPositive_.
00331 { 00332 int numberMinor = (!columnOrdered_) ? numberColumns_ : numberRows_; 00333 int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_; 00334 // count number in each row/column 00335 int * tempP = new int [numberMinor]; 00336 int * tempN = new int [numberMinor]; 00337 memset(tempP,0,numberMinor*sizeof(int)); 00338 memset(tempN,0,numberMinor*sizeof(int)); 00339 CoinBigIndex j=0; 00340 int i; 00341 for (i=0;i<numberMajor;i++) { 00342 for (;j<startNegative_[i];j++) { 00343 int iRow = indices_[j]; 00344 tempP[iRow]++; 00345 } 00346 for (;j<startPositive_[i+1];j++) { 00347 int iRow = indices_[j]; 00348 tempN[iRow]++; 00349 } 00350 } 00351 int * newIndices = new int [startPositive_[numberMajor]]; 00352 int * newP = new int [numberMinor+1]; 00353 int * newN = new int[numberMinor]; 00354 int iRow; 00355 j=0; 00356 // do starts 00357 for (iRow=0;iRow<numberMinor;iRow++) { 00358 newP[iRow]=j; 00359 j += tempP[iRow]; 00360 tempP[iRow]=newP[iRow]; 00361 newN[iRow] = j; 00362 j += tempN[iRow]; 00363 tempN[iRow]=newN[iRow]; 00364 } 00365 newP[numberMinor]=j; 00366 j=0; 00367 for (i=0;i<numberMajor;i++) { 00368 for (;j<startNegative_[i];j++) { 00369 int iRow = indices_[j]; 00370 int put = tempP[iRow]; 00371 newIndices[put++] = i; 00372 tempP[iRow] = put; 00373 } 00374 for (;j<startPositive_[i+1];j++) { 00375 int iRow = indices_[j]; 00376 int put = tempN[iRow]; 00377 newIndices[put++] = i; 00378 tempN[iRow] = put; 00379 } 00380 } 00381 delete [] tempP; 00382 delete [] tempN; 00383 ClpPlusMinusOneMatrix * newCopy = new ClpPlusMinusOneMatrix(); 00384 newCopy->passInCopy(numberMinor, numberMajor, 00385 !columnOrdered_, newIndices, newP, newN); 00386 return newCopy; 00387 } |
|
Subset clone (without gaps). Duplicates are allowed and order is as given Reimplemented from ClpMatrixBase. Definition at line 188 of file ClpPlusMinusOneMatrix.cpp. References ClpPlusMinusOneMatrix().
00191 { 00192 return new ClpPlusMinusOneMatrix(*this, numberRows, whichRows, 00193 numberColumns, whichColumns); 00194 } |
|
Return Implements ClpMatrixBase. Definition at line 855 of file ClpPlusMinusOneMatrix.cpp. References CoinIndexedVector::clear(), CoinIndexedVector::denseVector(), CoinIndexedVector::getIndices(), CoinIndexedVector::getNumElements(), indices_, CoinIndexedVector::packedMode(), CoinIndexedVector::setPacked(), startNegative_, and startPositive_.
00859 { 00860 columnArray->clear(); 00861 double * pi = rowArray->denseVector(); 00862 double * array = columnArray->denseVector(); 00863 int jColumn; 00864 int numberToDo = y->getNumElements(); 00865 const int * which = y->getIndices(); 00866 assert (!rowArray->packedMode()); 00867 columnArray->setPacked(); 00868 for (jColumn=0;jColumn<numberToDo;jColumn++) { 00869 int iColumn = which[jColumn]; 00870 double value = 0.0; 00871 CoinBigIndex j=startPositive_[iColumn]; 00872 for (;j<startNegative_[iColumn];j++) { 00873 int iRow = indices_[j]; 00874 value += pi[iRow]; 00875 } 00876 for (;j<startPositive_[iColumn+1];j++) { 00877 int iRow = indices_[j]; 00878 value -= pi[iRow]; 00879 } 00880 array[jColumn]=value; 00881 } 00882 } |
|
Return
Implements ClpMatrixBase. Definition at line 390 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, indices_, numberColumns_, numberRows_, startNegative_, and startPositive_. Referenced by times().
00392 { 00393 int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_; 00394 int i; 00395 CoinBigIndex j; 00396 assert (columnOrdered_); 00397 for (i=0;i<numberMajor;i++) { 00398 double value = scalar*x[i]; 00399 if (value) { 00400 for (j=startPositive_[i];j<startNegative_[i];j++) { 00401 int iRow = indices_[j]; 00402 y[iRow] += value; 00403 } 00404 for (;j<startPositive_[i+1];j++) { 00405 int iRow = indices_[j]; 00406 y[iRow] -= value; 00407 } 00408 } 00409 } 00410 } |
|
Return Implements ClpMatrixBase. Definition at line 453 of file ClpPlusMinusOneMatrix.cpp. References CoinIndexedVector::capacity(), CoinIndexedVector::clear(), columnOrdered_, CoinIndexedVector::denseVector(), ClpSimplex::factorization(), CoinIndexedVector::getIndices(), CoinIndexedVector::getNumElements(), indices_, ClpModel::numberColumns(), numberColumns_, ClpModel::numberRows(), CoinIndexedVector::packedMode(), ClpModel::rowCopy(), CoinIndexedVector::setNumElements(), startNegative_, startPositive_, and transposeTimesByRow().
00457 { 00458 // we know it is not scaled 00459 columnArray->clear(); 00460 double * pi = rowArray->denseVector(); 00461 int numberNonZero=0; 00462 int * index = columnArray->getIndices(); 00463 double * array = columnArray->denseVector(); 00464 int numberInRowArray = rowArray->getNumElements(); 00465 // maybe I need one in OsiSimplex 00466 double zeroTolerance = model->factorization()->zeroTolerance(); 00467 int numberRows = model->numberRows(); 00468 bool packed = rowArray->packedMode(); 00469 ClpPlusMinusOneMatrix* rowCopy = 00470 dynamic_cast< ClpPlusMinusOneMatrix*>(model->rowCopy()); 00471 double factor = 0.3; 00472 // We may not want to do by row if there may be cache problems 00473 int numberColumns = model->numberColumns(); 00474 // It would be nice to find L2 cache size - for moment 512K 00475 // Be slightly optimistic 00476 if (numberColumns*sizeof(double)>1000000) { 00477 if (numberRows*10<numberColumns) 00478 factor=0.1; 00479 else if (numberRows*4<numberColumns) 00480 factor=0.15; 00481 else if (numberRows*2<numberColumns) 00482 factor=0.2; 00483 } 00484 if (numberInRowArray>factor*numberRows||!rowCopy) { 00485 assert (!y->getNumElements()); 00486 // do by column 00487 // Need to expand if packed mode 00488 int iColumn; 00489 CoinBigIndex j=0; 00490 assert (columnOrdered_); 00491 if (packed) { 00492 // need to expand pi into y 00493 assert(y->capacity()>=numberRows); 00494 double * piOld = pi; 00495 pi = y->denseVector(); 00496 const int * whichRow = rowArray->getIndices(); 00497 int i; 00498 // modify pi so can collapse to one loop 00499 for (i=0;i<numberInRowArray;i++) { 00500 int iRow = whichRow[i]; 00501 pi[iRow]=scalar*piOld[i]; 00502 } 00503 for (iColumn=0;iColumn<numberColumns_;iColumn++) { 00504 double value = 0.0; 00505 for (;j<startNegative_[iColumn];j++) { 00506 int iRow = indices_[j]; 00507 value += pi[iRow]; 00508 } 00509 for (;j<startPositive_[iColumn+1];j++) { 00510 int iRow = indices_[j]; 00511 value -= pi[iRow]; 00512 } 00513 if (fabs(value)>zeroTolerance) { 00514 array[numberNonZero]=value; 00515 index[numberNonZero++]=iColumn; 00516 } 00517 } 00518 for (i=0;i<numberInRowArray;i++) { 00519 int iRow = whichRow[i]; 00520 pi[iRow]=0.0; 00521 } 00522 } else { 00523 for (iColumn=0;iColumn<numberColumns_;iColumn++) { 00524 double value = 0.0; 00525 for (;j<startNegative_[iColumn];j++) { 00526 int iRow = indices_[j]; 00527 value += pi[iRow]; 00528 } 00529 for (;j<startPositive_[iColumn+1];j++) { 00530 int iRow = indices_[j]; 00531 value -= pi[iRow]; 00532 } 00533 value *= scalar; 00534 if (fabs(value)>zeroTolerance) { 00535 index[numberNonZero++]=iColumn; 00536 array[iColumn]=value; 00537 } 00538 } 00539 } 00540 columnArray->setNumElements(numberNonZero); 00541 } else { 00542 // do by row 00543 rowCopy->transposeTimesByRow(model, scalar, rowArray, y, columnArray); 00544 } 00545 } |
|
Return
Implements ClpMatrixBase. Definition at line 412 of file ClpPlusMinusOneMatrix.cpp. References columnOrdered_, indices_, numberColumns_, numberRows_, startNegative_, and startPositive_. Referenced by transposeTimes().
00414 { 00415 int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_; 00416 int i; 00417 CoinBigIndex j=0; 00418 assert (columnOrdered_); 00419 for (i=0;i<numberMajor;i++) { 00420 double value = 0.0; 00421 for (;j<startNegative_[i];j++) { 00422 int iRow = indices_[j]; 00423 value += x[iRow]; 00424 } 00425 for (;j<startPositive_[i+1];j++) { 00426 int iRow = indices_[j]; 00427 value -= x[iRow]; 00428 } 00429 y[i] += scalar*value; 00430 } 00431 } |
|
Return Definition at line 549 of file ClpPlusMinusOneMatrix.cpp. References CoinIndexedVector::capacity(), CoinIndexedVector::clear(), CoinIndexedVector::denseVector(), ClpSimplex::factorization(), CoinIndexedVector::getIndices(), CoinIndexedVector::getNumElements(), indices_, ClpModel::numberColumns(), CoinIndexedVector::packedMode(), CoinIndexedVector::setNumElements(), startNegative(), startNegative_, startPositive(), and startPositive_. Referenced by transposeTimes(), and ClpNetworkMatrix::transposeTimes().
00553 { 00554 columnArray->clear(); 00555 double * pi = rowArray->denseVector(); 00556 int numberNonZero=0; 00557 int * index = columnArray->getIndices(); 00558 double * array = columnArray->denseVector(); 00559 int numberInRowArray = rowArray->getNumElements(); 00560 // maybe I need one in OsiSimplex 00561 double zeroTolerance = model->factorization()->zeroTolerance(); 00562 const int * column = indices_; 00563 const CoinBigIndex * startPositive = startPositive_; 00564 const CoinBigIndex * startNegative = startNegative_; 00565 const int * whichRow = rowArray->getIndices(); 00566 bool packed = rowArray->packedMode(); 00567 if (numberInRowArray>2||y->getNumElements()) { 00568 // do by rows 00569 int iRow; 00570 double * markVector = y->denseVector(); // probably empty .. but 00571 int * mark = y->getIndices(); 00572 int numberOriginal=y->getNumElements(); 00573 int i; 00574 if (packed) { 00575 assert(!numberOriginal); 00576 numberNonZero=0; 00577 // and set up mark as char array 00578 char * marked = (char *) (index+columnArray->capacity()); 00579 double * array2 = y->denseVector(); 00580 #ifdef CLP_DEBUG 00581 int numberColumns = model->numberColumns(); 00582 for (i=0;i<numberColumns;i++) { 00583 assert(!marked[i]); 00584 assert(!array2[i]); 00585 } 00586 #endif 00587 for (i=0;i<numberInRowArray;i++) { 00588 iRow = whichRow[i]; 00589 double value = pi[i]*scalar; 00590 CoinBigIndex j; 00591 for (j=startPositive[iRow];j<startNegative[iRow];j++) { 00592 int iColumn = column[j]; 00593 if (!marked[iColumn]) { 00594 marked[iColumn]=1; 00595 index[numberNonZero++]=iColumn; 00596 } 00597 array2[iColumn] += value; 00598 } 00599 for (j=startNegative[iRow];j<startPositive[iRow+1];j++) { 00600 int iColumn = column[j]; 00601 if (!marked[iColumn]) { 00602 marked[iColumn]=1; 00603 index[numberNonZero++]=iColumn; 00604 } 00605 array2[iColumn] -= value; 00606 } 00607 } 00608 // get rid of tiny values and zero out marked 00609 numberOriginal=numberNonZero; 00610 numberNonZero=0; 00611 for (i=0;i<numberOriginal;i++) { 00612 int iColumn = index[i]; 00613 if (marked[iColumn]) { 00614 double value = array2[iColumn]; 00615 array2[iColumn]=0.0; 00616 marked[iColumn]=0; 00617 if (fabs(value)>zeroTolerance) { 00618 array[numberNonZero]=value; 00619 index[numberNonZero++]=iColumn; 00620 } 00621 } 00622 } 00623 } else { 00624 for (i=0;i<numberOriginal;i++) { 00625 int iColumn = mark[i]; 00626 index[i]=iColumn; 00627 array[iColumn]=markVector[iColumn]; 00628 markVector[iColumn]=0.0; 00629 } 00630 numberNonZero=numberOriginal; 00631 // and set up mark as char array 00632 char * marked = (char *) markVector; 00633 for (i=0;i<numberOriginal;i++) { 00634 int iColumn = index[i]; 00635 marked[iColumn]=0; 00636 } 00637 for (i=0;i<numberInRowArray;i++) { 00638 iRow = whichRow[i]; 00639 double value = pi[iRow]*scalar; 00640 CoinBigIndex j; 00641 for (j=startPositive[iRow];j<startNegative[iRow];j++) { 00642 int iColumn = column[j]; 00643 if (!marked[iColumn]) { 00644 marked[iColumn]=1; 00645 index[numberNonZero++]=iColumn; 00646 } 00647 array[iColumn] += value; 00648 } 00649 for (j=startNegative[iRow];j<startPositive[iRow+1];j++) { 00650 int iColumn = column[j]; 00651 if (!marked[iColumn]) { 00652 marked[iColumn]=1; 00653 index[numberNonZero++]=iColumn; 00654 } 00655 array[iColumn] -= value; 00656 } 00657 } 00658 // get rid of tiny values and zero out marked 00659 numberOriginal=numberNonZero; 00660 numberNonZero=0; 00661 for (i=0;i<numberOriginal;i++) { 00662 int iColumn = index[i]; 00663 marked[iColumn]=0; 00664 if (fabs(array[iColumn])>zeroTolerance) { 00665 index[numberNonZero++]=iColumn; 00666 } else { 00667 array[iColumn]=0.0; 00668 } 00669 } 00670 } 00671 } else if (numberInRowArray==2) { 00672 /* do by rows when two rows (do longer first when not packed 00673 and shorter first if packed */ 00674 int iRow0 = whichRow[0]; 00675 int iRow1 = whichRow[1]; 00676 int j; 00677 if (packed) { 00678 double pi0 = pi[0]; 00679 double pi1 = pi[1]; 00680 if (startPositive[iRow0+1]-startPositive[iRow0]> 00681 startPositive[iRow1+1]-startPositive[iRow1]) { 00682 int temp = iRow0; 00683 iRow0 = iRow1; 00684 iRow1 = temp; 00685 pi0=pi1; 00686 pi1=pi[0]; 00687 } 00688 // and set up mark as char array 00689 char * marked = (char *) (index+columnArray->capacity()); 00690 int * lookup = y->getIndices(); 00691 double value = pi0*scalar; 00692 for (j=startPositive[iRow0];j<startNegative[iRow0];j++) { 00693 int iColumn = column[j]; 00694 array[numberNonZero] = value; 00695 marked[iColumn]=1; 00696 lookup[iColumn]=numberNonZero; 00697 index[numberNonZero++]=iColumn; 00698 } 00699 for (j=startNegative[iRow0];j<startPositive[iRow0+1];j++) { 00700 int iColumn = column[j]; 00701 array[numberNonZero] = -value; 00702 marked[iColumn]=1; 00703 lookup[iColumn]=numberNonZero; 00704 index[numberNonZero++]=iColumn; 00705 } 00706 int numberOriginal = numberNonZero; 00707 value = pi1*scalar; 00708 for (j=startPositive[iRow1];j<startNegative[iRow1];j++) { 00709 int iColumn = column[j]; 00710 if (marked[iColumn]) { 00711 int iLookup = lookup[iColumn]; 00712 array[iLookup] += value; 00713 } else { 00714 if (fabs(value)>zeroTolerance) { 00715 array[numberNonZero] = value; 00716 index[numberNonZero++]=iColumn; 00717 } 00718 } 00719 } 00720 for (j=startNegative[iRow1];j<startPositive[iRow1+1];j++) { 00721 int iColumn = column[j]; 00722 if (marked[iColumn]) { 00723 int iLookup = lookup[iColumn]; 00724 array[iLookup] -= value; 00725 } else { 00726 if (fabs(value)>zeroTolerance) { 00727 array[numberNonZero] = -value; 00728 index[numberNonZero++]=iColumn; 00729 } 00730 } 00731 } 00732 // get rid of tiny values and zero out marked 00733 int nDelete=0; 00734 for (j=0;j<numberOriginal;j++) { 00735 int iColumn = index[j]; 00736 marked[iColumn]=0; 00737 if (fabs(array[j])<=zeroTolerance) 00738 nDelete++; 00739 } 00740 if (nDelete) { 00741 numberOriginal=numberNonZero; 00742 numberNonZero=0; 00743 for (j=0;j<numberOriginal;j++) { 00744 int iColumn = index[j]; 00745 double value = array[j]; 00746 array[j]=0.0; 00747 if (fabs(value)>zeroTolerance) { 00748 array[numberNonZero]=value; 00749 index[numberNonZero++]=iColumn; 00750 } 00751 } 00752 } 00753 } else { 00754 if (startPositive[iRow0+1]-startPositive[iRow0]< 00755 startPositive[iRow1+1]-startPositive[iRow1]) { 00756 int temp = iRow0; 00757 iRow0 = iRow1; 00758 iRow1 = temp; 00759 } 00760 int numberOriginal; 00761 int i; 00762 numberNonZero=0; 00763 double value; 00764 value = pi[iRow0]*scalar; 00765 CoinBigIndex j; 00766 for (j=startPositive[iRow0];j<startNegative[iRow0];j++) { 00767 int iColumn = column[j]; 00768 index[numberNonZero++]=iColumn; 00769 array[iColumn] = value; 00770 } 00771 for (j=startNegative[iRow0];j<startPositive[iRow0+1];j++) { 00772 int iColumn = column[j]; 00773 index[numberNonZero++]=iColumn; 00774 array[iColumn] = -value; 00775 } 00776 value = pi[iRow1]*scalar; 00777 for (j=startPositive[iRow1];j<startNegative[iRow1];j++) { 00778 int iColumn = column[j]; 00779 double value2= array[iColumn]; 00780 if (value2) { 00781 value2 += value; 00782 } else { 00783 value2 = value; 00784 index[numberNonZero++]=iColumn; 00785 } 00786 array[iColumn] = value2; 00787 } 00788 for (j=startNegative[iRow1];j<startPositive[iRow1+1];j++) { 00789 int iColumn = column[j]; 00790 double value2= array[iColumn]; 00791 if (value2) { 00792 value2 -= value; 00793 } else { 00794 value2 = -value; 00795 index[numberNonZero++]=iColumn; 00796 } 00797 array[iColumn] = value2; 00798 } 00799 // get rid of tiny values and zero out marked 00800 numberOriginal=numberNonZero; 00801 numberNonZero=0; 00802 for (i=0;i<numberOriginal;i++) { 00803 int iColumn = index[i]; 00804 if (fabs(array[iColumn])>zeroTolerance) { 00805 index[numberNonZero++]=iColumn; 00806 } else { 00807 array[iColumn]=0.0; 00808 } 00809 } 00810 } 00811 } else if (numberInRowArray==1) { 00812 // Just one row 00813 int iRow=rowArray->getIndices()[0]; 00814 numberNonZero=0; 00815 double value; 00816 iRow = whichRow[0]; 00817 CoinBigIndex j; 00818 if (packed) { 00819 value = pi[0]*scalar; 00820 if (fabs(value)>zeroTolerance) { 00821 for (j=startPositive[iRow];j<startNegative[iRow];j++) { 00822 int iColumn = column[j]; 00823 array[numberNonZero] = value; 00824 index[numberNonZero++]=iColumn; 00825 } 00826 for (j=startNegative[iRow];j<startPositive[iRow+1];j++) { 00827 int iColumn = column[j]; 00828 array[numberNonZero] = -value; 00829 index[numberNonZero++]=iColumn; 00830 } 00831 } 00832 } else { 00833 value = pi[iRow]*scalar; 00834 if (fabs(value)>zeroTolerance) { 00835 for (j=startPositive[iRow];j<startNegative[iRow];j++) { 00836 int iColumn = column[j]; 00837 array[iColumn] = value; 00838 index[numberNonZero++]=iColumn; 00839 } 00840 for (j=startNegative[iRow];j<startPositive[iRow+1];j++) { 00841 int iColumn = column[j]; 00842 array[iColumn] = -value; 00843 index[numberNonZero++]=iColumn; 00844 } 00845 } 00846 } 00847 } 00848 columnArray->setNumElements(numberNonZero); 00849 y->setNumElements(0); 00850 } |
|
Unpacks a column into an CoinIndexedvector Implements ClpMatrixBase. Definition at line 973 of file ClpPlusMinusOneMatrix.cpp. References CoinIndexedVector::add(), indices_, startNegative_, and startPositive_.
00976 { 00977 CoinBigIndex j=startPositive_[iColumn]; 00978 for (;j<startNegative_[iColumn];j++) { 00979 int iRow = indices_[j]; 00980 rowArray->add(iRow,1.0); 00981 } 00982 for (;j<startPositive_[iColumn+1];j++) { 00983 int iRow = indices_[j]; 00984 rowArray->add(iRow,-1.0); 00985 } 00986 } |
|
Unpacks a column into an CoinIndexedvector in packed foramt Note that model is NOT const. Bounds and objective could be modified if doing column generation (just for this variable) Implements ClpMatrixBase. Definition at line 992 of file ClpPlusMinusOneMatrix.cpp. References CoinIndexedVector::denseVector(), CoinIndexedVector::getIndices(), indices_, CoinIndexedVector::setNumElements(), CoinIndexedVector::setPackedMode(), startNegative_, and startPositive_.
00995 { 00996 int * index = rowArray->getIndices(); 00997 double * array = rowArray->denseVector(); 00998 int number = 0; 00999 CoinBigIndex j=startPositive_[iColumn]; 01000 for (;j<startNegative_[iColumn];j++) { 01001 int iRow = indices_[j]; 01002 array[number]=1.0; 01003 index[number++]=iRow; 01004 } 01005 for (;j<startPositive_[iColumn+1];j++) { 01006 int iRow = indices_[j]; 01007 array[number]=-1.0; 01008 index[number++]=iRow; 01009 } 01010 rowArray->setNumElements(number); 01011 rowArray->setPackedMode(true); 01012 } |