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