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