source: trunk/Clp/src/ClpCholeskyDense.hpp @ 1368

Last change on this file since 1368 was 1368, checked in by forrest, 10 years ago

changes for cholesky including code from Anshul Gupta

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