source: trunk/include/ClpPackedMatrix.hpp @ 78

Last change on this file since 78 was 78, checked in by ladanyi, 17 years ago

Massive documentation updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpPackedMatrix_H
4#define ClpPackedMatrix_H
5
6
7#include "CoinPragma.hpp"
8
9#include "ClpMatrixBase.hpp"
10
11/** This implements OsiPackedMatrix as derived from ClpMatrixBase.
12
13    It adds a few methods that know about model as well as matrix
14
15    For details see OsiPackedMatrix */
16
17class ClpPackedMatrix : public ClpMatrixBase {
18 
19public:
20  /**@name Useful methods */
21   //@{
22   /// Return a complete CoinPackedMatrix
23  virtual CoinPackedMatrix * getPackedMatrix() const { return matrix_;};
24    /** Whether the packed matrix is column major ordered or not. */
25    virtual bool isColOrdered() const { return matrix_->isColOrdered(); }
26   /** Number of entries in the packed matrix. */
27  virtual  CoinBigIndex getNumElements() const 
28  { return matrix_->getNumElements(); }
29   /** Number of columns. */
30   virtual int getNumCols() const { return matrix_->getNumCols(); }
31   /** Number of rows. */
32  virtual int getNumRows() const { return matrix_->getNumRows(); };
33
34   /** A vector containing the elements in the packed matrix. Note that there
35        might be gaps in this list, entries that do not belong to any
36        major-dimension vector. To get the actual elements one should look at
37        this vector together with vectorStarts and vectorLengths. */
38   virtual const double * getElements() const 
39  { return matrix_->getElements();};
40   /** A vector containing the minor indices of the elements in the packed
41        matrix. Note that there might be gaps in this list, entries that do not
42        belong to any major-dimension vector. To get the actual elements one
43        should look at this vector together with vectorStarts and
44        vectorLengths. */
45   virtual const int * getIndices() const 
46  { return matrix_->getIndices();};
47
48   virtual const CoinBigIndex * getVectorStarts() const 
49  { return matrix_->getVectorStarts();};
50   /** The lengths of the major-dimension vectors. */
51   virtual const int * getVectorLengths() const 
52  { return matrix_->getVectorLengths();} ;
53
54    /** Delete the columns whose indices are listed in <code>indDel</code>. */
55    virtual void deleteCols(const int numDel, const int * indDel)
56  { matrix_->deleteCols(numDel,indDel);};
57    /** Delete the rows whose indices are listed in <code>indDel</code>. */
58    virtual void deleteRows(const int numDel, const int * indDel)
59  { matrix_->deleteRows(numDel,indDel);};
60  /** Replace the elements of a vector.  The indices remain the same.
61      This is only needed if scaling and a row copy is used.
62      At most the number specified will be replaced.
63      The index is between 0 and major dimension of matrix */
64  void replaceVector(const int index,
65                       const int numReplace, const double * newElements)
66      {matrix_->replaceVector(index,numReplace,newElements);};
67  /** Returns a new matrix in reverse order without gaps */
68  virtual ClpMatrixBase * reverseOrderedCopy() const;
69  /** Returns number of elements in basis
70      column is basic if entry >=0 */
71  virtual CoinBigIndex numberInBasis(const int * columnIsBasic) const ;
72  /// Fills in basis (Returns number of elements and updates numberBasic)
73  virtual CoinBigIndex fillBasis(const ClpSimplex * model,
74                                const int * columnIsBasic, int & numberBasic,
75                                int * row, int * column,
76                                double * element) const ;
77  /** Creates scales for column copy (rowCopy in model may be modified)
78      returns non-zero if no scaling done */
79  virtual int scale(ClpSimplex * model) const ;
80  /// Creates row copy and scales if necessary
81  virtual ClpMatrixBase * scaledRowCopy(ClpSimplex * model) const;
82  /** Checks if all elements are in valid range.  Can just
83      return true if you are not paranoid.  For Clp I will
84      probably expect no zeros.  Code can modify matrix to get rid of
85      small elements.
86  */
87  virtual bool allElementsInRange(ClpSimplex * model,
88                                  double smallest, double largest);
89
90  /** Unpacks a column into an CoinIndexedvector
91      Note that model is NOT const.  Bounds and objective could
92      be modified if doing column generation */
93  virtual void unpack(ClpSimplex * model,CoinIndexedVector * rowArray,
94                   int column) const ;
95  /** Adds multiple of a column into an CoinIndexedvector
96      You can use quickAdd to add to vector */
97  virtual void add(const ClpSimplex * model,CoinIndexedVector * rowArray,
98                   int column, double multiplier) const ;
99   /// Allow any parts of a created CoinPackedMatrix to be deleted
100   virtual void releasePackedMatrix() const { };
101   //@}
102
103  /**@name Matrix times vector methods */
104  //@{
105    /** Return <code>y + A * scalar *x</code> in <code>y</code>.
106        @pre <code>x</code> must be of size <code>numColumns()</code>
107        @pre <code>y</code> must be of size <code>numRows()</code> */
108  virtual void times(double scalar,
109                       const double * x, double * y) const;
110  /// And for scaling
111  virtual void times(double scalar,
112                     const double * x, double * y,
113                     const double * rowScale, 
114                     const double * columnScale) const;
115    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
116        @pre <code>x</code> must be of size <code>numRows()</code>
117        @pre <code>y</code> must be of size <code>numColumns()</code> */
118    virtual void transposeTimes(double scalar,
119                                const double * x, double * y) const;
120  /// And for scaling
121    virtual void transposeTimes(double scalar,
122                                const double * x, double * y,
123                                const double * rowScale, 
124                                const double * columnScale) const;
125    /** Return <code>x * scalar * A + y</code> in <code>z</code>.
126        Can use y as temporary array (will be empty at end)
127        Squashes small elements and knows about ClpSimplex */
128  virtual void transposeTimes(const ClpSimplex * model, double scalar,
129                              const CoinIndexedVector * x,
130                              CoinIndexedVector * y,
131                              CoinIndexedVector * z) const;
132    /** Return <code>x *A</code> in <code>z</code> but
133        just for indices in y.
134        Squashes small elements and knows about ClpSimplex */
135  virtual void subsetTransposeTimes(const ClpSimplex * model,
136                                    const CoinIndexedVector * x,
137                                    const CoinIndexedVector * y,
138                                    CoinIndexedVector * z) const;
139  //@}
140
141  /**@name Other */
142   //@{
143  /// Returns CoinPackedMatrix (non const)
144  inline CoinPackedMatrix * matrix() const { return matrix_;};
145   //@}
146
147
148  /**@name Constructors, destructor */
149   //@{
150   /** Default constructor. */
151   ClpPackedMatrix();
152   /** Destructor */
153   virtual ~ClpPackedMatrix();
154   //@}
155
156   /**@name Copy method */
157   //@{
158   /** The copy constructor. */
159   ClpPackedMatrix(const ClpPackedMatrix&);
160   /** The copy constructor from an CoinPackedMatrix. */
161   ClpPackedMatrix(const CoinPackedMatrix&);
162
163  /** This takes over ownership (for space reasons) */
164   ClpPackedMatrix(CoinPackedMatrix * matrix);
165
166   ClpPackedMatrix& operator=(const ClpPackedMatrix&);
167  /// Clone
168  virtual ClpMatrixBase * clone() const ;
169   //@}
170   
171   
172protected:
173   /**@name Data members
174      The data members are protected to allow access for derived classes. */
175   //@{
176  /// Data
177  CoinPackedMatrix * matrix_;
178   //@}
179};
180
181#endif
Note: See TracBrowser for help on using the repository browser.