source: trunk/include/ClpPackedMatrix.hpp @ 15

Last change on this file since 15 was 2, checked in by forrest, 18 years ago

Adding Clp to development branch

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