Ignore:
Timestamp:
May 30, 2009 4:52:38 AM (10 years ago)
Author:
forrest
Message:

changes for cholesky including code from Anshul Gupta

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpCholeskyDense.hpp

    r1367 r1368  
    1 // Copyright (C) 2003, International Business Machines
    2 // Corporation and others.  All Rights Reserved.
     1/* Copyright (C) 2003, International Business Machines Corporation
     2   and others.  All Rights Reserved. */
    33#ifndef ClpCholeskyDense_H
    44#define ClpCholeskyDense_H
     
    77class ClpMatrixBase;
    88
    9 /** Dense class for Clp Cholesky factorization
    10 
    11 */
    129class ClpCholeskyDense : public ClpCholeskyBase {
    1310 
    1411public:
    1512   /**@name Virtual methods that the derived classes provides  */
    16    //@{
     13   /**@{*/
    1714  /** Orders rows and saves pointer to matrix.and model.
    1815   Returns non-zero if not enough memory */
     
    2825  /** Uses factorization to solve. */
    2926  virtual void solve (double * region) ;
    30   //@}
     27  /**@}*/
    3128
    32    /**@name Non virtual methods for ClpCholeskyDense  */
    33    //@{
     29  /**@name Non virtual methods for ClpCholeskyDense  */
     30  /**@{*/
    3431  /** Reserves space.
    3532      If factor not NULL then just uses passed space
     
    4239  /** part 2 of Factorize - filling in rowsDropped - blocked */
    4340  void factorizePart3(int * rowsDropped) ;
    44   /// Non leaf recursive factor
    45   void factor(longDouble * a, int n, int numberBlocks,
    46               longDouble * diagonal, longDouble * work, int * rowsDropped);
    47   /// Non leaf recursive triangle rectangle update
    48   void triRec(longDouble * aTri, int nThis, longDouble * aUnder, longDouble * diagonal, longDouble * work,
    49               int nLeft, int iBlock, int jBlock,
    50               int numberBlocks);
    51   /// Non leaf recursive rectangle triangle update
    52   void recTri(longDouble * aUnder, int nTri, int nDo,
    53               int iBlock, int jBlock,longDouble * aTri,
    54               longDouble * diagonal, longDouble * work,
    55               int numberBlocks);
     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);
    56132  /** Non leaf recursive rectangle rectangle update,
    57133      nUnder is number of rows in iBlock,
    58134      nUnderK is number of rows in kBlock
    59135  */
    60   void recRec(longDouble * above, int nUnder, int nUnderK,
    61               int nDo, longDouble * aUnder, longDouble *aOther,
    62               longDouble * work,
    63               int iBlock, int jBlock,
    64               int numberBlocks);
    65   /// Leaf recursive factor
    66   void factorLeaf(longDouble * a, int n,
    67               longDouble * diagonal, longDouble * work, int * rowsDropped);
    68   /// Leaf recursive triangle rectangle update
    69   void triRecLeaf(longDouble * aTri, longDouble * aUnder,
    70                   longDouble * diagonal, longDouble * work,
    71                   int nUnder);
    72   /// Leaf recursive rectangle triangle update
    73   void recTriLeaf(longDouble * aUnder, longDouble * aTri,
    74                   longDouble * diagonal, longDouble * work, int nUnder);
     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);
    75160  /** Leaf recursive rectangle rectangle update,
    76161      nUnder is number of rows in iBlock,
    77162      nUnderK is number of rows in kBlock
    78163  */
    79   void recRecLeaf(const longDouble * COIN_RESTRICT above,
    80                   const longDouble * COIN_RESTRICT aUnder,
    81                   longDouble * COIN_RESTRICT aOther,
    82                   const longDouble * COIN_RESTRICT work,
    83                   int nUnder);
    84   /// Forward part of solve
    85   void solveF1(longDouble * a,int n,double * region);
    86   void solveF2(longDouble * a,int n,double * region,double * region2);
    87   /// Backward part of solve
    88   void solveB1(longDouble * a,int n,double * region);
    89   void solveB2(longDouble * a,int n,double * region,double * region2);
    90   /** Uses factorization to solve. */
    91   void solveLong (CoinWorkDouble * region) ;
    92   /// Forward part of solve
    93   void solveF1Long(longDouble * a,int n,CoinWorkDouble * region);
    94   void solveF2Long(longDouble * a,int n,CoinWorkDouble * region,CoinWorkDouble * region2);
    95   /// Backward part of solve
    96   void solveB1Long(longDouble * a,int n,CoinWorkDouble * region);
    97   void solveB2Long(longDouble * a,int n,CoinWorkDouble * region,CoinWorkDouble * region2);
    98   /** Uses factorization to solve. */
    99   void solveLongWork (CoinWorkDouble * region) ;
    100   /// Forward part of solve
    101   void solveF1LongWork(longDouble * a,int n,CoinWorkDouble * region);
    102   void solveF2LongWork(longDouble * a,int n,CoinWorkDouble * region,CoinWorkDouble * region2);
    103   /// Backward part of solve
    104   void solveB1LongWork(longDouble * a,int n,CoinWorkDouble * region);
    105   void solveB2LongWork(longDouble * a,int n,CoinWorkDouble * region,CoinWorkDouble * region2);
    106   int bNumber(const longDouble * array,int &, int&);
    107   /// A
    108   inline longDouble * aMatrix() const
    109   { return sparseFactor_;}
    110   /// Diagonal
    111   inline longDouble * diagonal() const
    112   { return diagonal_;}
    113   //@}
    114 
    115 
    116   /**@name Constructors, destructor */
    117   //@{
    118   /** Default constructor. */
    119   ClpCholeskyDense();
    120   /** Destructor  */
    121   virtual ~ClpCholeskyDense();
    122   // Copy
    123   ClpCholeskyDense(const ClpCholeskyDense&);
    124   // Assignment
    125   ClpCholeskyDense& operator=(const ClpCholeskyDense&);
    126   /// Clone
    127   virtual ClpCholeskyBase * clone() const ;
    128   //@}
    129    
    130    
    131 private:
    132   /**@name Data members */
    133   //@{
    134   /// Just borrowing space
    135   bool borrowSpace_;
    136   //@}
    137 };
    138 
     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);
    139171#endif
Note: See TracChangeset for help on using the changeset viewer.