source: git/Singular/MinorProcessor.h @ d74b89

spielwiese
Last change on this file since d74b89 was 089b98, checked in by Frank Seelisch <seelisch@…>, 14 years ago
some changes to make the compiler happy (should remove some warnings when making Singularg) git-svn-id: file:///usr/local/Singular/svn/trunk@12562 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 34.0 KB
Line 
1#ifndef MINOR_PROCESSOR_H
2#define MINOR_PROCESSOR_H
3
4#include <Cache.h>
5#include <Minor.h>
6#include <assert.h>
7#include <string>
8
9/*! \class MinorProcessor
10    \brief Class MinorProcessor implements the key methods for computing one
11    or all sub-determinantes of a given size in a pre-defined matrix; either
12    without caching or by using a cache.
13
14    After defining the entire matrix (e.g. 10 x 14) using<br>
15    MinorProcessor::defineMatrix (const int, const int, const int*),<br>
16    the user may do two different things:<br>
17    1. He/she can simply compute a minor in this matrix using<br>
18    MinorProcessor::getMinor (const int, const int*, const int*,
19                              Cache<MinorKey, MinorValue>&), or<br>
20    MinorProcessor::getMinor (const int, const int*, const int*);<br>
21    depending on whether a cache shall or shall not be used, respectively.<br>
22    In the first case, the user simply provides all row and column indices of
23    the desired minor.
24    2. He/she may define a smaller sub-matrix (e.g. 8 x 7) using
25    MinorValue::defineSubMatrix (const int, const int*, const int, const int*).
26    Afterwards, he/she may compute all minors of an even smaller size (e.g.
27    5 x 5) that consist exclusively of rows and columns of this (8 x 7)
28    sub-matrix (inside the entire 10 x 14 matrix).<br>
29    The implementation at hand eases the iteration over all such minors. Also
30    in the second case there are both implementations, i.e., with and without
31    using a cache.<br><br>
32    MinorProcessor makes use of MinorKey, MinorValue, and Cache. The
33    implementation of all mentioned classes (MinorKey, MinorValue, and
34    MinorProcessor) is generic to allow for the use of different types of
35    keys and values.
36    \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
37*/
38class MinorProcessor
39{
40  protected:
41    /**
42    * A static method for computing the maximum number of retrievals of a
43    * minor.<br>
44    * More concretely, we are given a matrix of size \c rows x \c columns. We
45    * furthermore assume that we have - as part of this matrix - a minor of
46    * size \c containerMinorSize x \c containerMinorSize. Now we are
47    * interested in the number of times a minor of yet smaller size
48    * \c minorSize x \c minorSize will be needed when we compute the
49    * containerMinor by Laplace's Theorem.<br>
50    * The method returns the combinatorial results for both cases:
51    * containerMinor is fixed within the matrix
52    * (<c>multipleMinors == false</c>), or it can vary inside the matrix
53    * (<c>multipleMinors == true</c>).<br>
54    * The notion is here that we want to cache the small minor of size
55    * \c minorSize x \c minorSize, i.e. compute it just once.
56    * @param rows the number of rows of the underlying matrix
57    * @param columns the number of columns of the underlying matrix
58    * @param containerMinorSize the size of the container minor
59    * @param minorSize the size of the small minor (which may be retrieved
60    *        multiple times)
61    * @param multipleMinors decides whether containerMinor is fixed within
62    *        the underlying matrix or not
63    * @return the number of times, the small minor will be needed when
64    *         computing one or all containerMinors
65    */
66    static int NumberOfRetrievals (const int rows, const int columns,
67                                   const int containerMinorSize,
68                                   const int minorSize,
69                                   const bool multipleMinors);
70    /**
71    * A static method for computing the binomial coefficient i over j.
72    * \par Assert
73    * The method checks whether <em>i >= j >= 0</em>.
74    * @param i a positive integer greater than or equal to \a j
75    * @param j a positive integer less than or equal to \a i, and greater
76    *        than or equal to \e 0.
77    * @return the binomial coefficient i over j
78    */
79    static int IOverJ (const int i, const int j);
80
81    /**
82    * A static method for computing the factorial of i.
83    * \par Assert
84    * The method checks whether <em>i >= 0</em>.
85    * @param i an integer greater than or equal to \a 0
86    * @return the factorial of i
87    */
88    static int Faculty (const int i);
89
90    /**
91    * A method for iterating through all possible subsets of \c k rows and
92    * \c k columns inside a pre-defined submatrix of a pre-defined matrix.<br>
93    * The method will set \c _rowKey and \c columnKey to represent the
94    * next possbile subsets of \c k rows and columns inside the submatrix
95    * determined by \c _globalRowKey and \c _globalColumnKey.<br>
96    * When first called, this method will just shift \c _rowKey and
97    * \c _columnKey to point to the first sensible choices. Every subsequent
98    * call will move to the next \c _columnKey until there is no next.
99    * In this situation, a next \c _rowKey will be set, and \c _columnKey
100    * again to the first possible choice.<br>
101    * Finally, in case there is also no next \c _rowkey, the method returns
102    * \c false. (Otherwise \c true is returned.)
103    * @param k the size of the minor / all minors of interest
104    * @return true iff there is a next possible choice of rows and columns
105    */
106    bool setNextKeys (const int k);
107
108    /**
109    * private store for the rows and columns of the container minor within
110    * the underlying matrix;
111    * \c _container will be used to fix a submatrix (e.g. 40 x 50) of a
112    * larger matrix (e.g. 70 x 100). This is usefull when we would like to
113    * compute all minors of a given size (e.g. 4 x 4) inside such a
114    * pre-defined submatrix.
115    */
116    MinorKey _container;
117
118    /**
119    * private store for the number of rows in the container minor;
120    * This is set by MinorProcessor::defineSubMatrix (const int, const int*,
121    *                                                 const int, const int*).
122    */
123    int _containerRows;
124
125    /**
126    * private store for the number of columns in the container minor;
127    * This is set by MinorProcessor::defineSubMatrix (const int, const int*,
128    *                                                 const int, const int*).
129    */
130    int _containerColumns;
131
132    /**
133    * private store for the rows and columns of the minor of interest;
134    * Usually, this minor will encode subsets of the rows and columns in
135    * _container.
136    */
137    MinorKey _minor;
138
139    /**
140    * private store for the dimension of the minor(s) of interest
141    */
142    int _minorSize;
143
144    /**
145    * private store for the number of rows in the underlying matrix
146    */
147    int _rows;
148
149    /**
150    * private store for the number of columns in the underlying matrix
151    */
152    int _columns;
153
154    /**
155    * A method for identifying the row or column with the most zeros.<br>
156    * Using Laplace's Theorem, a minor can more efficiently be computed when
157    * developing along this best line.
158    * The returned index \c bestIndex is 0-based within the pre-defined
159    * matrix. If some row has the most zeros, then the (0-based) row index is
160    * returned. If, contrarywise, some column has the most zeros, then
161    * <c>x = - 1 - c</c> where \c c is the column index, is returned.
162    * (Note that in this case \c c can be reconstructed by computing
163    * <c>c = - 1 - x</c>.)
164    * @param k the size of the minor / all minors of interest
165    * @param mk the representation of rows and columns of the minor of
166    *        interest
167    * @return an int encoding which row or column has the most zeros
168    */
169    int getBestLine (const int k, const MinorKey& mk) const;
170
171    /**
172    * A method for testing whether a matrix entry is zero.
173    * @param absoluteRowIndex the absolute (zero-based) row index
174    * @param absoluteColumnIndex the absolute (zero-based) column index
175    * @return true iff the specified matrix entry is zero
176    */
177    virtual bool isEntryZero (const int absoluteRowIndex,
178                              const int absoluteColumnIndex) const;
179  public:
180    /**
181    * The default constructor
182    */
183    MinorProcessor ();
184
185    /**
186    * A method for defining a sub-matrix within a pre-defined matrix.
187    * @param numberOfRows the number of rows in the sub-matrix
188    * @param rowIndices an array with the (0-based) indices of rows inside
189    *        the pre-defined matrix
190    * @param numberOfColumns the number of columns in the sub-matrix
191    * @param columnIndices an array with the (0-based) indices of columns
192    *        inside the pre-defined matrix
193    * @see MinorValue::defineMatrix (const int, const int, const int*)
194    */
195    void defineSubMatrix (const int numberOfRows, const int* rowIndices,
196                          const int numberOfColumns, const int* columnIndices);
197
198    /**
199    * Sets the size of the minor(s) of interest.<br>
200    * This method needs to be performed before beginning to compute all minors
201    * of size \a minorSize inside a pre-defined submatrix of an underlying
202    * (also pre-defined) matrix.
203    * @param minorSize the size of the minor(s) of interest
204    * @see MinorValue::defineSubMatrix (const int, const int*, const int,
205    *                                   const int*)
206    */
207    void setMinorSize (const int minorSize);
208
209    /**
210    * A method for checking whether there is a next choice of rows and columns
211    * when iterating through all minors of a given size within a pre-defined
212    * sub-matrix of an underlying matrix.<br>
213    * The number of rows and columns has to be set before using
214    * MinorValue::setMinorSize(const int).<br>
215    * After calling MinorValue::hasNextMinor (), the current sets of rows and
216    * columns may be inspected using
217    * MinorValue::getCurrentRowIndices(int* const) const and
218    * MinorValue::getCurrentColumnIndices(int* const) const.
219    * @return true iff there is a next choice of rows and columns
220    * @see MinorProcessor::getMinor (const int, const int*, const int*)
221    * @see MinorValue::getCurrentRowIndices(int* const) const
222    * @see MinorValue::getCurrentColumnIndices(int* const) const
223    */
224    bool hasNextMinor ();
225
226    /**
227    * A method for obtaining the current set of rows corresponding to the
228    * current minor when iterating through all minors of a given size within
229    * a pre-defined sub-matrix of an underlying matrix.<br>
230    * This method should only be called after MinorProcessor::hasNextMinor ()
231    * had been called and yielded \c true.<br>
232    * The user of this method needs to know the number of rows in order to
233    * know which entries of the newly filled \c target will be valid.
234    * @param target an int array to be filled with the row indices
235    * @see MinorProcessor::hasNextMinor ()
236    */
237    void getCurrentRowIndices (int* const target) const;
238
239    /**
240    * A method for obtaining the current set of columns corresponding to the
241    * current minor when iterating through all minors of a given size within
242    * a pre-defined sub-matrix of an underlying matrix.<br>
243    * This method should only be called after MinorProcessor::hasNextMinor ()
244    * had been called and yielded \c true.<br>
245    * The user of this method needs to know the number of columns in order to
246    * know which entries of the newly filled \c target will be valid.
247    * @param target an int array to be filled with the column indices
248    * @see MinorProcessor::hasNextMinor ()
249    */
250    void getCurrentColumnIndices (int* const target) const;
251
252    /**
253    * A method for providing a printable version of the represented
254    * MinorProcessor.
255    * @return a printable version of the given instance as instance of class
256    * string
257    */
258    virtual string toString () const;
259
260    /**
261    * A method for printing a string representation of the given
262    * MinorProcessor to std::cout.
263    */
264    void print () const;
265};
266
267/*! \class IntMinorProcessor
268    \brief Class IntMinorProcessor is derived from class MinorProcessor.
269   
270    This class implements the special case of integer matrices.
271    \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
272*/
273class IntMinorProcessor : public MinorProcessor
274{
275  private:
276    /**
277    * private store for integer matrix entries
278    */
279    int* _intMatrix;
280   
281    /**
282    * A method for retrieving the matrix entry.
283    * @param rowIndex the absolute (zero-based) row index
284    * @param columnIndex the absolute (zero-based) column index
285    * @return the specified matrix entry
286    */
287    int getEntry (const int rowIndex, const int columnIndex) const;
288
289    /**
290    * A method for computing the value of a minor, using a cache.<br>
291    * The sub-matrix is specified by \c mk. Computation works recursively
292    * using Laplace's Theorem. We always develop along the row or column with
293    * the most zeros; see
294    * MinorProcessor::getBestLine (const int k, const MinorKey& mk).
295    * If an ideal is given, it is assumed to be a standard basis. In this case,
296    * all results will be reduced w.r.t. to this basis. Moreover, if the given
297    * characteristic is non-zero, all results will be computed modulo this
298    * characteristic.
299    * @param k the number of rows and columns in the minor to be comuted
300    * @param mk the representation of rows and columns of the minor to be
301    *        comuted
302    * @param multipleMinors decides whether we compute just one or all minors
303    *        of a specified size
304    * @param c a cache to be used for caching reusable sub-minors
305    * @param characteristic 0 or the characteristic of the underlying
306    *        coefficient ring/field
307    * @param iSB NULL or a standard basis
308    * @return an instance of MinorValue representing the value of the
309    *         corresponding minor
310    * @see MinorProcessor::getMinorPrivateLaplace (const int k,
311                                                   const MinorKey& mk,
312                                                   const int characteristic,
313                                                   const ideal& iSB)
314    */
315    IntMinorValue getMinorPrivateLaplace (const int k, const MinorKey& mk,
316                                          const bool multipleMinors,
317                                          Cache<MinorKey, IntMinorValue>& c,
318                                          int characteristic,
319                                          const ideal& iSB);
320
321    /**
322    * A method for computing the value of a minor, without using a cache.<br>
323    * The sub-matrix is specified by \c mk. Computation works recursively
324    * using Laplace's Theorem. We always develop along the row or column with
325    * the most zeros; see
326    * MinorProcessor::getBestLine (const int k, const MinorKey& mk).
327    * If an ideal is given, it is assumed to be a standard basis. In this case,
328    * all results will be reduced w.r.t. to this basis. Moreover, if the given
329    * characteristic is non-zero, all results will be computed modulo this
330    * characteristic.
331    * @param k the number of rows and columns in the minor to be comuted
332    * @param mk the representation of rows and columns of the minor to be
333    *        comuted
334    * @param characteristic 0 or the characteristic of the underlying
335    *        coefficient ring/field
336    * @param iSB NULL or a standard basis
337    * @return an instance of MinorValue representing the value of the
338    *         corresponding minor
339    * @see MinorProcessor::getMinorPrivateLaplace (const int k,
340                                                   const MinorKey& mk,
341                                                   const bool multipleMinors,
342                                                   Cache<MinorKey,
343                                                         IntMinorValue>& c,
344                                                   int characteristic,
345                                                   const ideal& iSB)
346    */
347    IntMinorValue getMinorPrivateLaplace (const int k, const MinorKey& mk,
348                                          const int characteristic,
349                                          const ideal& iSB);
350
351    /**
352    * A method for computing the value of a minor using Bareiss's
353    * algorithm.<br>
354    * The sub-matrix is specified by \c mk.
355    * If an ideal is given, it is assumed to be a standard basis. In this
356    * case, all results will be reduced w.r.t. to this basis. Moreover, if the
357    * given characteristic is non-zero, all results will be computed modulo
358    * this characteristic.
359    * @param k the number of rows and columns in the minor to be comuted
360    * @param mk the representation of rows and columns of the minor to be
361    *        computed
362    * @param characteristic 0 or the characteristic of the underlying
363    *        coefficient ring/field
364    * @param iSB NULL or a standard basis
365    * @return an instance of MinorValue representing the value of the
366    *         corresponding minor
367    * @see MinorProcessor::getMinorPrivateLaplace (const int k,
368                                                   const MinorKey& mk,
369                                                   const int characteristic,
370                                                   const ideal& iSB)
371    */
372    IntMinorValue getMinorPrivateBareiss (const int k, const MinorKey& mk,
373                                          const int characteristic,
374                                          const ideal& iSB);
375  protected:
376    /**
377    * A method for testing whether a matrix entry is zero.
378    * @param absoluteRowIndex the absolute (zero-based) row index
379    * @param absoluteColumnIndex the absolute (zero-based) column index
380    * @return true iff the specified matrix entry is zero
381    */
382    bool isEntryZero (const int absoluteRowIndex,
383                      const int absoluteColumnIndex) const;
384  public:
385    /**
386    * A constructor for creating an instance.
387    */
388    IntMinorProcessor ();
389
390    /**
391    * A destructor for deleting an instance.
392    */
393    ~IntMinorProcessor ();
394
395    /**
396    * A method for defining a matrix with integer entries.
397    * @param numberOfRows the number of rows
398    * @param numberOfColumns the number of columns
399    * @param matrix the matrix entries in a linear array, i.e., from left to
400    *        right and top to bottom
401    * @see MinorValue::defineSubMatrix (const int, const int*, const int,
402    *                                   const int*)
403    */
404    void defineMatrix (const int numberOfRows, const int numberOfColumns,
405                       const int* matrix);
406
407    /**
408    * A method for computing the value of a minor without using a cache.<br>
409    * The sub-matrix is determined by \c rowIndices and \c columnIndices.
410    * Computation works either by Laplace's algorithm or by Bareiss's
411    * algorithm.<br>
412    * If an ideal is given, it is assumed to be a standard basis. In this
413    * case, all results will be reduced w.r.t. to this basis. Moreover, if the
414    * given characteristic is non-zero, all results will be computed modulo
415    * this characteristic.
416    * @param dimension the size of the minor to be computed
417    * @param rowIndices 0-based indices of the rows of the minor
418    * @param columnIndices 0-based indices of the column of the minor
419    * @param characteristic 0 or the characteristic of the underlying
420    *        coefficient ring/field
421    * @param iSB NULL or a standard basis
422    * @param algorithm either "Bareiss" or "Laplace"
423    * @return an instance of MinorValue representing the value of the
424    *         corresponding minor
425    * @see MinorProcessor::getMinor (const int dimension,
426                                     const int* rowIndices,
427                                     const int* columnIndices,
428                                     Cache<MinorKey, IntMinorValue>& c,
429                                     const int characteristic,
430                                     const ideal& iSB)
431    */
432    IntMinorValue getMinor (const int dimension, const int* rowIndices,
433                            const int* columnIndices,
434                            const int characteristic, const ideal& iSB,
435                            const char* algorithm);
436
437    /**
438    * A method for computing the value of a minor using a cache.<br>
439    * The sub-matrix is determined by \c rowIndices and \c columnIndices.
440    * Computation works by Laplace's algorithm together with caching of
441    * subdeterminants.<br>
442    * If an ideal is given, it is assumed to be a standard basis. In this case,
443    * all results will be reduced w.r.t. to this basis. Moreover, if the given
444    * characteristic is non-zero, all results will be computed modulo this
445    * characteristic.
446    * @param dimension the size of the minor to be computed
447    * @param rowIndices 0-based indices of the rows of the minor
448    * @param columnIndices 0-based indices of the column of the minor
449    * @param c the cache for storing subdeterminants
450    * @param characteristic 0 or the characteristic of the underlying
451    *        coefficient ring/field
452    * @param iSB NULL or a standard basis
453    * @return an instance of MinorValue representing the value of the
454    *         corresponding minor
455    * @see MinorProcessor::getMinor (const int dimension,
456                                     const int* rowIndices,
457                                     const int* columnIndices,
458                                     const int characteristic,
459                                     const ideal& iSB,
460                                     const char* algorithm)
461    */
462    IntMinorValue getMinor (const int dimension, const int* rowIndices,
463                            const int* columnIndices,
464                            Cache<MinorKey, IntMinorValue>& c,
465                            const int characteristic,  const ideal& iSB);
466
467    /**
468    * A method for obtaining the next minor when iterating
469    * through all minors of a given size within a pre-defined sub-matrix of an
470    * underlying matrix.<br>
471    * This method should only be called after MinorProcessor::hasNextMinor ()
472    * had been called and yielded \c true.<br>
473    * Computation works by Laplace's algorithm (without using a cache) or by
474    * Bareiss's algorithm.<br>
475    * If an ideal is given, it is assumed to be a standard basis. In this case,
476    * all results will be reduced w.r.t. to this basis. Moreover, if the given
477    * characteristic is non-zero, all results will be computed modulo this
478    * characteristic.
479    * @param characteristic 0 or the characteristic of the underlying
480    *        coefficient ring/field
481    * @param iSB NULL or a standard basis
482    * @param algorithm either "Bareiss" or "Laplace"
483    * @return the next minor
484    * @see IntMinorValue::getNextMinor (Cache<MinorKey, IntMinorValue>& c,
485    *                                   const int characteristic,
486    *                                   const ideal& iSB)
487    */
488    IntMinorValue getNextMinor (const int characteristic, const ideal& iSB,
489                                const char* algorithm);
490
491    /**
492    * A method for obtaining the next minor when iterating
493    * through all minors of a given size within a pre-defined sub-matrix of an
494    * underlying matrix.<br>
495    * This method should only be called after MinorProcessor::hasNextMinor ()
496    * had been called and yielded \c true.<br>
497    * Computation works using the cache \a c which may already contain useful
498    * results from previous calls of
499    * IntMinorValue::getNextMinor (Cache<MinorKey, IntMinorValue>& c,
500                                   const int characteristic,
501                                   const ideal& iSB).
502    * If an ideal is given, it is assumed to be a standard basis. In this case,
503    * all results will be reduced w.r.t. to this basis. Moreover, if the given
504    * characteristic is non-zero, all results will be computed modulo this
505    * characteristic.
506    * @param c the cache
507    * @param characteristic 0 or the characteristic of the underlying
508    *        coefficient ring/field
509    * @param iSB NULL or a standard basis
510    * @return the next minor
511    * @see IntMinorValue::getNextMinor (const int characteristic,
512    *                                   const ideal& iSB,
513    *                                   const char* algorithm)
514    */
515    IntMinorValue getNextMinor (Cache<MinorKey, IntMinorValue>& c,
516                                const int characteristic,
517                                const ideal& iSB);
518
519    /**
520    * A method for providing a printable version of the represented
521    * MinorProcessor.
522    * @return a printable version of the given instance as instance of class
523    *         string
524    */
525    string toString () const;
526};
527
528/*! \class PolyMinorProcessor
529    \brief Class PolyMinorProcessor is derived from class MinorProcessor.
530   
531    This class implements the special case of polynomial matrices.
532    \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
533*/
534class PolyMinorProcessor : public MinorProcessor
535{
536  private:
537    /**
538    * private store for polynomial matrix entries
539    */
540    poly* _polyMatrix;
541   
542    /**
543    * A method for retrieving the matrix entry.
544    * @param rowIndex the absolute (zero-based) row index
545    * @param columnIndex the absolute (zero-based) column index
546    * @return the specified matrix entry
547    */
548    poly getEntry (const int rowIndex, const int columnIndex) const;
549
550    /**
551    * A method for computing the value of a minor, using a cache.<br>
552    * The sub-matrix is specified by \c mk. Computation works recursively
553    * using Laplace's Theorem. We always develop along the row or column with
554    * the most zeros; see
555    * MinorProcessor::getBestLine (const int k, const MinorKey& mk).
556    * If an ideal is given, it is assumed to be a standard basis. In this case,
557    * all results will be reduced w.r.t. to this basis.
558    * @param k the number of rows and columns in the minor to be comuted
559    * @param mk the representation of rows and columns of the minor to be
560    *        comuted
561    * @param multipleMinors decides whether we compute just one or all minors
562    *        of a specified size
563    * @param c a cache to be used for caching reusable sub-minors
564    * @param iSB NULL or a standard basis
565    * @return an instance of MinorValue representing the value of the
566    *         corresponding minor
567    * @see MinorProcessor::getMinorPrivateLaplace (const int k,
568    *                                              const MinorKey& mk,
569    *                                              const ideal& iSB)
570    */
571    PolyMinorValue getMinorPrivateLaplace (const int k, const MinorKey& mk,
572                                           const bool multipleMinors,
573                                           Cache<MinorKey, PolyMinorValue>& c,
574                                           const ideal& iSB);
575
576    /**
577    * A method for computing the value of a minor, without using a cache.<br>
578    * The sub-matrix is specified by \c mk. Computation works recursively
579    * using Laplace's Theorem. We always develop along the row or column with
580    * the most zeros; see
581    * MinorProcessor::getBestLine (const int k, const MinorKey& mk).
582    * If an ideal is given, it is assumed to be a standard basis. In this case,
583    * all results will be reduced w.r.t. to this basis.
584    * @param k the number of rows and columns in the minor to be comuted
585    * @param mk the representation of rows and columns of the minor to be
586    *        comuted
587    * @param iSB NULL or a standard basis
588    * @return an instance of MinorValue representing the value of the
589    *         corresponding minor
590    * @see MinorProcessor::getMinorPrivate (const int, const MinorKey&,
591    *                                       const bool,
592    *                                       Cache<MinorKey, MinorValue>&)
593    */
594    PolyMinorValue getMinorPrivateLaplace (const int k, const MinorKey& mk,
595                                           const ideal& iSB);
596   
597    /**
598    * A method for computing the value of a minor, without using a cache.<br>
599    * The sub-matrix is specified by \c mk. Computation works
600    * using Bareiss's algorithm.
601    * If an ideal is given, it is assumed to be a standard basis. In this case,
602    * all results will be reduced w.r.t. to this basis.
603    * @param k the number of rows and columns in the minor to be comuted
604    * @param mk the representation of rows and columns of the minor to be
605    *        comuted
606    * @param iSB NULL or a standard basis
607    * @return an instance of MinorValue representing the value of the
608    *         corresponding minor
609    * @see MinorProcessor::getMinorPrivateLaplace (const int k,
610    *                                              const MinorKey& mk,
611    *                                              const ideal& iSB)
612    */
613    PolyMinorValue getMinorPrivateBareiss (const int k, const MinorKey& mk,
614                                           const ideal& iSB);
615  protected:
616    /**
617    * A method for testing whether a matrix entry is zero.
618    * @param absoluteRowIndex the absolute (zero-based) row index
619    * @param absoluteColumnIndex the absolute (zero-based) column index
620    * @return true iff the specified matrix entry is zero
621    */
622    bool isEntryZero (const int absoluteRowIndex,
623                      const int absoluteColumnIndex) const;
624  public:
625    /**
626    * A constructor for creating an instance.
627    */
628    PolyMinorProcessor ();
629
630    /**
631    * A destructor for deleting an instance.
632    */
633    ~PolyMinorProcessor ();
634
635    /**
636    * A method for defining a matrix with polynomial entries.
637    * @param numberOfRows the number of rows
638    * @param numberOfColumns the number of columns
639    * @param polyMatrix the matrix entries in a linear array, i.e., from left
640    *        to right and top to bottom
641    * @see MinorValue::defineSubMatrix (const int, const int*, const int,
642    *                                   const int*)
643    */
644    void defineMatrix (const int numberOfRows, const int numberOfColumns,
645                       const poly* polyMatrix);
646
647    /**
648    * A method for computing the value of a minor, without using a cache.<br>
649    * The sub-matrix is determined by \c rowIndices and \c columnIndices.
650    * Computation works either by Laplace's algorithm or by Bareiss's
651    * algorithm.<br>
652    * If an ideal is given, it is assumed to be a standard basis. In this case,
653    * all results will be reduced w.r.t. to this basis.
654    * @param dimension the size of the minor to be computed
655    * @param rowIndices 0-based indices of the rows of the minor
656    * @param columnIndices 0-based indices of the column of the minor
657    * @param algorithm either "Laplace" or "Bareiss"
658    * @param iSB NULL or a standard basis
659    * @return an instance of MinorValue representing the value of the
660    *         corresponding minor
661    * @see MinorProcessor::getMinor (const int dimension,
662    *                                const int* rowIndices,
663    *                                const int* columnIndices,
664    *                                Cache<MinorKey, PolyMinorValue>& c,
665    *                                const ideal& iSB)
666    */
667    PolyMinorValue getMinor (const int dimension, const int* rowIndices,
668                             const int* columnIndices, const char* algorithm,
669                             const ideal& iSB);
670
671    /**
672    * A method for computing the value of a minor, using a cache.<br>
673    * The sub-matrix is determined by \c rowIndices and \c columnIndices.
674    * Computation works recursively using Laplace's Theorem. We always develop
675    * along the row or column with most zeros; see
676    * MinorProcessor::getBestLine (const int, const int, const int).
677    * If an ideal is given, it is assumed to be a standard basis. In this case,
678    * all results will be reduced w.r.t. to this basis.
679    * @param dimension the size of the minor to be computed
680    * @param rowIndices 0-based indices of the rows of the minor
681    * @param columnIndices 0-based indices of the column of the minor
682    * @param c a cache to be used for caching reusable sub-minors
683    * @param iSB NULL or a standard basis
684    * @return an instance of MinorValue representing the value of the
685    *         corresponding minor
686    * @see MinorProcessor::(const int dimension, const int* rowIndices,
687    *                       const int* columnIndices, const char* algorithm,
688    *                       const ideal& iSB)
689    */
690    PolyMinorValue getMinor (const int dimension, const int* rowIndices,
691                             const int* columnIndices,
692                             Cache<MinorKey, PolyMinorValue>& c,
693                             const ideal& iSB);
694
695    /**
696    * A method for obtaining the next minor when iterating
697    * through all minors of a given size within a pre-defined sub-matrix of an
698    * underlying matrix.<br>
699    * This method should only be called after MinorProcessor::hasNextMinor ()
700    * had been called and yielded \c true.<br>
701    * Computation works either by Laplace's algorithm (without using a cache)
702    * or by Bareiss's algorithm.<br>
703    * If an ideal is given, it is assumed to be a standard basis. In this case,
704    * all results will be reduced w.r.t. to this basis.
705    * @param algorithm either "Laplace" or "Bareiss"
706    * @param iSB NULL or a standard basis
707    * @return true iff there is a next choice of rows and columns
708    * @see PolyMinorValue::getNextMinor (Cache<MinorKey, PolyMinorValue>& c,
709    *                                    const ideal& iSB)
710    */
711    PolyMinorValue getNextMinor (const char* algorithm, const ideal& iSB);
712
713    /**
714    * A method for obtaining the next minor when iterating
715    * through all minors of a given size within a pre-defined sub-matrix of an
716    * underlying matrix.<br>
717    * This method should only be called after MinorProcessor::hasNextMinor ()
718    * had been called and yielded \c true.<br>
719    * Computation works using Laplace's algorithm and a cache \a c which may
720    * already contain useful results from previous calls of
721    * PolyMinorValue::getNextMinor (Cache<MinorKey, PolyMinorValue>& c,
722    *                               const ideal& iSB).
723    * If an ideal is given, it is assumed to be a standard basis. In this case,
724    * all results will be reduced w.r.t. to this basis.
725    * @param iSB NULL or a standard basis
726    * @return the next minor
727    * @see PolyMinorValue::getNextMinor (const char* algorithm,
728    *                                    const ideal& iSB)
729    */
730    PolyMinorValue getNextMinor (Cache<MinorKey, PolyMinorValue>& c,
731                                 const ideal& iSB);
732
733    /**
734    * A method for providing a printable version of the represented
735    * MinorProcessor.
736    * @return a printable version of the given instance as instance of class
737    *         string
738    */
739    string toString () const;
740};
741
742#endif
743/* MINOR_PROCESSOR_H */
Note: See TracBrowser for help on using the repository browser.