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

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

moving sandbox stuff to trunk

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