source: trunk/Clp/src/ClpDummyMatrix.hpp @ 754

Last change on this file since 754 was 754, checked in by andreasw, 14 years ago

first version

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpDummyMatrix_H
4#define ClpDummyMatrix_H
5
6
7#include "CoinPragma.hpp"
8
9#include "ClpMatrixBase.hpp"
10
11/** This implements a dummy matrix as derived from ClpMatrixBase.
12    This is so you can do ClpPdco but may come in useful elsewhere.
13    It just has dimensions but no data
14*/
15
16
17class ClpDummyMatrix : public ClpMatrixBase {
18 
19public:
20  /**@name Useful methods */
21   //@{
22   /// Return a complete CoinPackedMatrix
23   virtual CoinPackedMatrix * getPackedMatrix() const;
24    /** Whether the packed matrix is column major ordered or not. */
25   virtual bool isColOrdered() const { return true; }
26   /** Number of entries in the packed matrix. */
27  virtual  CoinBigIndex getNumElements() const 
28  { return numberElements_; }
29   /** Number of columns. */
30   virtual int getNumCols() const { return numberColumns_; }
31   /** Number of rows. */
32  virtual int getNumRows() const { return numberRows_; };
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   /** A vector containing the minor indices of the elements in the packed
40        matrix. Note that there might be gaps in this list, entries that do not
41        belong to any major-dimension vector. To get the actual elements one
42        should look at this vector together with vectorStarts and
43        vectorLengths. */
44  virtual const int * getIndices() const;
45
46  virtual const CoinBigIndex * getVectorStarts() const;
47   /** The lengths of the major-dimension vectors. */
48  virtual const int * getVectorLengths() const;
49
50    /** Delete the columns whose indices are listed in <code>indDel</code>. */
51  virtual void deleteCols(const int numDel, const int * indDel);
52    /** Delete the rows whose indices are listed in <code>indDel</code>. */
53  virtual void deleteRows(const int numDel, const int * indDel);
54  /** Returns a new matrix in reverse order without gaps */
55  virtual ClpMatrixBase * reverseOrderedCopy() const;
56  /// Returns number of elements in column part of basis
57  virtual CoinBigIndex countBasis(ClpSimplex * model,
58                                 const int * whichColumn, 
59                                 int numberRowBasic,
60                                  int & numberColumnBasic);
61  /// Fills in column part of basis
62  virtual void fillBasis(ClpSimplex * model,
63                                 const int * whichColumn, 
64                                 int & numberColumnBasic,
65                                 int * row, int * start,
66                                 int * rowCount, int * columnCount,
67                                 double * element);
68  /** Unpacks a column into an CoinIndexedvector
69   */
70  virtual void unpack(const ClpSimplex * model,CoinIndexedVector * rowArray,
71                   int column) const ;
72  /** Unpacks a column into an CoinIndexedvector
73   ** in packed foramt
74      Note that model is NOT const.  Bounds and objective could
75      be modified if doing column generation (just for this variable) */
76  virtual void unpackPacked(ClpSimplex * model,
77                            CoinIndexedVector * rowArray,
78                            int column) const;
79  /** Adds multiple of a column into an CoinIndexedvector
80      You can use quickAdd to add to vector */
81  virtual void add(const ClpSimplex * model,CoinIndexedVector * rowArray,
82                   int column, double multiplier) const ;
83  /** Adds multiple of a column into an array */
84  virtual void add(const ClpSimplex * model,double * array,
85                   int column, double multiplier) const;
86   /// Allow any parts of a created CoinMatrix to be deleted
87  /// Allow any parts of a created CoinPackedMatrix to be deleted
88   virtual void releasePackedMatrix() const {};
89   //@}
90
91  /**@name Matrix times vector methods */
92  //@{
93    /** Return <code>y + A * scalar *x</code> in <code>y</code>.
94        @pre <code>x</code> must be of size <code>numColumns()</code>
95        @pre <code>y</code> must be of size <code>numRows()</code> */
96  virtual void times(double scalar,
97                       const double * x, double * y) const;
98  /// And for scaling
99  virtual void times(double scalar,
100                     const double * x, double * y,
101                     const double * rowScale, 
102                     const double * columnScale) const;
103    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
104        @pre <code>x</code> must be of size <code>numRows()</code>
105        @pre <code>y</code> must be of size <code>numColumns()</code> */
106    virtual void transposeTimes(double scalar,
107                                const double * x, double * y) const;
108  /// And for scaling
109    virtual void transposeTimes(double scalar,
110                                const double * x, double * y,
111                                const double * rowScale, 
112                                const double * columnScale) const;
113    /** Return <code>x * scalar * A + y</code> in <code>z</code>.
114        Can use y as temporary array (will be empty at end)
115        Note - If x packed mode - then z packed mode */
116  virtual void transposeTimes(const ClpSimplex * model, double scalar,
117                              const CoinIndexedVector * x,
118                              CoinIndexedVector * y,
119                              CoinIndexedVector * z) const;
120    /** Return <code>x *A</code> in <code>z</code> but
121        just for indices in y.
122        Note - If x packed mode - then z packed mode
123        Squashes small elements and knows about ClpSimplex */
124  virtual void subsetTransposeTimes(const ClpSimplex * model,
125                                    const CoinIndexedVector * x,
126                                    const CoinIndexedVector * y,
127                                    CoinIndexedVector * z) const;
128  //@}
129
130  /**@name Other */
131   //@{
132   //@}
133
134
135  /**@name Constructors, destructor */
136   //@{
137   /** Default constructor. */
138   ClpDummyMatrix();
139  /// Constructor with data
140  ClpDummyMatrix(int numberColumns, int numberRows,
141                   int numberElements);
142   /** Destructor */
143   virtual ~ClpDummyMatrix();
144   //@}
145
146   /**@name Copy method */
147   //@{
148   /** The copy constructor. */
149   ClpDummyMatrix(const ClpDummyMatrix&);
150   /** The copy constructor from an CoinDummyMatrix. */
151   ClpDummyMatrix(const CoinPackedMatrix&);
152
153   ClpDummyMatrix& operator=(const ClpDummyMatrix&);
154  /// Clone
155  virtual ClpMatrixBase * clone() const ;
156   //@}
157   
158   
159protected:
160   /**@name Data members
161      The data members are protected to allow access for derived classes. */
162   //@{
163  /// Number of rows
164  int numberRows_;
165  /// Number of columns
166  int numberColumns_;
167  /// Number of elements
168  int numberElements_;
169 
170   //@}
171};
172
173#endif
Note: See TracBrowser for help on using the repository browser.