| 1 | /* $Id: ClpCholeskyDense.hpp 1665 2011-01-04 17:55:54Z lou $ */ |
| 2 | /* |
| 3 | Copyright (C) 2003, International Business Machines Corporation |
| 4 | and others. All Rights Reserved. |
| 5 | |
| 6 | This code is licensed under the terms of the Eclipse Public License (EPL). |
| 7 | */ |
| 8 | #ifndef ClpCholeskyDense_H |
| 9 | #define ClpCholeskyDense_H |
| 10 | |
| 11 | #include "ClpCholeskyBase.hpp" |
| 12 | class ClpMatrixBase; |
| 13 | |
| 14 | class ClpCholeskyDense : public ClpCholeskyBase { |
| 15 | |
| 16 | public: |
| 17 | /**@name Virtual methods that the derived classes provides */ |
| 18 | /**@{*/ |
| 19 | /** Orders rows and saves pointer to matrix.and model. |
| 20 | Returns non-zero if not enough memory */ |
| 21 | virtual int order(ClpInterior * model) ; |
| 22 | /** Does Symbolic factorization given permutation. |
| 23 | This is called immediately after order. If user provides this then |
| 24 | user must provide factorize and solve. Otherwise the default factorization is used |
| 25 | returns non-zero if not enough memory */ |
| 26 | virtual int symbolic(); |
| 27 | /** Factorize - filling in rowsDropped and returning number dropped. |
| 28 | If return code negative then out of memory */ |
| 29 | virtual int factorize(const CoinWorkDouble * diagonal, int * rowsDropped) ; |
| 30 | /** Uses factorization to solve. */ |
| 31 | virtual void solve (CoinWorkDouble * region) ; |
| 32 | /**@}*/ |
| 33 | |
| 34 | /**@name Non virtual methods for ClpCholeskyDense */ |
| 35 | /**@{*/ |
| 36 | /** Reserves space. |
| 37 | If factor not NULL then just uses passed space |
| 38 | Returns non-zero if not enough memory */ |
| 39 | int reserveSpace(const ClpCholeskyBase * factor, int numberRows) ; |
| 40 | /** Returns space needed */ |
| 41 | CoinBigIndex space( int numberRows) const; |
| 42 | /** part 2 of Factorize - filling in rowsDropped */ |
| 43 | void factorizePart2(int * rowsDropped) ; |
| 44 | /** part 2 of Factorize - filling in rowsDropped - blocked */ |
| 45 | void factorizePart3(int * rowsDropped) ; |
| 46 | /** Forward part of solve */ |
| 47 | void solveF1(longDouble * a, int n, CoinWorkDouble * region); |
| 48 | void solveF2(longDouble * a, int n, CoinWorkDouble * region, CoinWorkDouble * region2); |
| 49 | /** Backward part of solve */ |
| 50 | void solveB1(longDouble * a, int n, CoinWorkDouble * region); |
| 51 | void solveB2(longDouble * a, int n, CoinWorkDouble * region, CoinWorkDouble * region2); |
| 52 | int bNumber(const longDouble * array, int &, int&); |
| 53 | /** A */ |
| 54 | inline longDouble * aMatrix() const { |
| 55 | return sparseFactor_; |
| 56 | } |
| 57 | /** Diagonal */ |
| 58 | inline longDouble * diagonal() const { |
| 59 | return diagonal_; |
| 60 | } |
| 61 | /**@}*/ |
| 62 | |
| 63 | |
| 64 | /**@name Constructors, destructor */ |
| 65 | /**@{*/ |
| 66 | /** Default constructor. */ |
| 67 | ClpCholeskyDense(); |
| 68 | /** Destructor */ |
| 69 | virtual ~ClpCholeskyDense(); |
| 70 | /** Copy */ |
| 71 | ClpCholeskyDense(const ClpCholeskyDense&); |
| 72 | /** Assignment */ |
| 73 | ClpCholeskyDense& operator=(const ClpCholeskyDense&); |
| 74 | /** Clone */ |
| 75 | virtual ClpCholeskyBase * clone() const ; |
| 76 | /**@}*/ |
| 77 | |
| 78 | |
| 79 | private: |
| 80 | /**@name Data members */ |
| 81 | /**@{*/ |
| 82 | /** Just borrowing space */ |
| 83 | bool borrowSpace_; |
| 84 | /**@}*/ |
| 85 | }; |
| 86 | |
| 87 | /* structure for C */ |
| 88 | typedef struct { |
| 89 | longDouble * diagonal_; |
| 90 | longDouble * a; |
| 91 | longDouble * work; |
| 92 | int * rowsDropped; |
| 93 | double doubleParameters_[1]; /* corresponds to 10 */ |
| 94 | int integerParameters_[2]; /* corresponds to 34, nThreads */ |
| 95 | int n; |
| 96 | int numberBlocks; |
| 97 | } ClpCholeskyDenseC; |
| 98 | |
| 99 | extern "C" { |
| 100 | void ClpCholeskySpawn(void *); |
| 101 | } |
| 102 | /**Non leaf recursive factor */ |
| 103 | void |
| 104 | ClpCholeskyCfactor(ClpCholeskyDenseC * thisStruct, |
| 105 | longDouble * a, int n, int numberBlocks, |
| 106 | longDouble * diagonal, longDouble * work, int * rowsDropped); |
| 107 | |
| 108 | /**Non leaf recursive triangle rectangle update */ |
| 109 | void |
| 110 | ClpCholeskyCtriRec(ClpCholeskyDenseC * thisStruct, |
| 111 | longDouble * aTri, int nThis, |
| 112 | longDouble * aUnder, longDouble * diagonal, |
| 113 | longDouble * work, |
| 114 | int nLeft, int iBlock, int jBlock, |
| 115 | int numberBlocks); |
| 116 | /**Non leaf recursive rectangle triangle update */ |
| 117 | void |
| 118 | ClpCholeskyCrecTri(ClpCholeskyDenseC * thisStruct, |
| 119 | longDouble * aUnder, int nTri, int nDo, |
| 120 | int iBlock, int jBlock, longDouble * aTri, |
| 121 | longDouble * diagonal, longDouble * work, |
| 122 | int numberBlocks); |
| 123 | /** Non leaf recursive rectangle rectangle update, |
| 124 | nUnder is number of rows in iBlock, |
| 125 | nUnderK is number of rows in kBlock |
| 126 | */ |
| 127 | void |
| 128 | ClpCholeskyCrecRec(ClpCholeskyDenseC * thisStruct, |
| 129 | longDouble * above, int nUnder, int nUnderK, |
| 130 | int nDo, longDouble * aUnder, longDouble *aOther, |
| 131 | longDouble * work, |
| 132 | int iBlock, int jBlock, |
| 133 | int numberBlocks); |
| 134 | /**Leaf recursive factor */ |
| 135 | void |
| 136 | ClpCholeskyCfactorLeaf(ClpCholeskyDenseC * thisStruct, |
| 137 | longDouble * a, int n, |
| 138 | longDouble * diagonal, longDouble * work, |
| 139 | int * rowsDropped); |
| 140 | /**Leaf recursive triangle rectangle update */ |
| 141 | void |
| 142 | ClpCholeskyCtriRecLeaf(/*ClpCholeskyDenseC * thisStruct,*/ |
| 143 | longDouble * aTri, longDouble * aUnder, |
| 144 | longDouble * diagonal, longDouble * work, |
| 145 | int nUnder); |
| 146 | /**Leaf recursive rectangle triangle update */ |
| 147 | void |
| 148 | ClpCholeskyCrecTriLeaf(/*ClpCholeskyDenseC * thisStruct, */ |
| 149 | longDouble * aUnder, longDouble * aTri, |
| 150 | /*longDouble * diagonal,*/ longDouble * work, int nUnder); |
| 151 | /** Leaf recursive rectangle rectangle update, |
| 152 | nUnder is number of rows in iBlock, |
| 153 | nUnderK is number of rows in kBlock |
| 154 | */ |
| 155 | void |
| 156 | ClpCholeskyCrecRecLeaf(/*ClpCholeskyDenseC * thisStruct, */ |
| 157 | const longDouble * COIN_RESTRICT above, |
| 158 | const longDouble * COIN_RESTRICT aUnder, |
| 159 | longDouble * COIN_RESTRICT aOther, |
| 160 | const longDouble * COIN_RESTRICT work, |
| 161 | int nUnder); |
| 162 | #endif |
| 163 | |