18#ifdef COUNT_AND_PRINT_OPERATIONS
38 printf(
"%s [p+p(div) | p*p(div) | m*m(div, -save) | m/m ]",
prefix);
39 printf(
" = [%ld(%ld) | %ld(%ld) | %ld(%d, -%ld) | %ld]\n",
70 for (
int r = 0; r <
k; r++)
75 for (
int c = 0; c <
k; c++)
87 for (
int c = 0; c <
k; c++)
91 for (
int r = 0; r <
k; r++)
222 if (
j == 0 ||
i ==
j)
return 1;
281 _containerColumns(0),
299 string s =
"IntMinorProcessor:";
304 for (
int r = 0; r <
_rows; r++)
315 s +=
"\n considered submatrix has row indices: ";
319 if (
k != 0)
s +=
", ";
322 s +=
" (first row of matrix has index 0)";
323 s +=
"\n considered submatrix has column indices: ";
327 if (
k != 0)
s +=
", ";
330 s +=
" (first column of matrix has index 0)";
331 s +=
"\n size of considered minor(s): ";
366 for (
int i = 0;
i < n;
i++)
439 if (
i == 0)
return 0;
477 int s = 0;
int m = 0;
int as = 0;
int am = 0;
489 for (
int c = 0; c <
k; c++)
500 m +=
mv.getMultiplications();
501 s +=
mv.getAdditions();
502 am +=
mv.getAccumulatedMultiplications();
503 as +=
mv.getAccumulatedAdditions();
509 s++;
m++;
as++, am++;
524 for (
int r = 0; r <
k; r++)
534 m +=
mv.getMultiplications();
535 s +=
mv.getAdditions();
536 am +=
mv.getAccumulatedMultiplications();
537 as +=
mv.getAccumulatedAdditions();
542 s++;
m++;
as++, am++;
589 for (
int r = 0; r <
k; r++)
590 for (
int c = 0; c <
k; c++)
605 for (
int r = 0; r <=
k - 2; r++)
626 for (
int rr = r + 1;
rr <
k;
rr++)
627 for (
int cc = r + 1;
cc <
k;
cc++)
683 int s = 0;
int m = 0;
int as = 0;
int am = 0;
699 for (
int c = 0; c <
k; c++)
712 mv.incrementRetrievals();
726 m +=
mv.getMultiplications();
727 s +=
mv.getAdditions();
731 am +=
mv.getAccumulatedMultiplications();
732 as +=
mv.getAccumulatedAdditions();
737 s++;
m++;
as++; am++;
752 for (
int r = 0; r <
k; r++)
764 mv.incrementRetrievals();
776 m +=
mv.getMultiplications();
777 s +=
mv.getAdditions();
781 am +=
mv.getAccumulatedMultiplications();
782 as +=
mv.getAccumulatedAdditions();
787 s++;
m++;
as++; am++;
834 string s =
"PolyMinorProcessor:";
840 s +=
"\n considered submatrix has row indices: ";
844 if (
k != 0)
s +=
", ";
847 s +=
" (first row of matrix has index 0)";
848 s +=
"\n considered submatrix has column indices: ";
852 if (
k != 0)
s +=
", ";
855 s +=
" (first column of matrix has index 0)";
856 s +=
"\n size of considered minor(s): ";
867 for (
int i = 0;
i < n;
i++)
878 for (
int i = 0;
i < n;
i++)
891 for (
int i = 0;
i < n;
i++)
977 int s = 0;
int m = 0;
int as = 0;
int am = 0;
989 for (
int c = 0; c <
k; c++)
1000 m +=
mv.getMultiplications();
1001 s +=
mv.getAdditions();
1002 am +=
mv.getAccumulatedMultiplications();
1003 as +=
mv.getAccumulatedAdditions();
1009#ifdef COUNT_AND_PRINT_OPERATIONS
1014 s++;
m++;
as++, am++;
1029 for (
int r = 0; r <
k; r++)
1040 m +=
mv.getMultiplications();
1041 s +=
mv.getAdditions();
1042 am +=
mv.getAccumulatedMultiplications();
1043 as +=
mv.getAccumulatedAdditions();
1049#ifdef COUNT_AND_PRINT_OPERATIONS
1054 s++;
m++;
as++, am++;
1063#ifdef COUNT_AND_PRINT_OPERATIONS
1101 0, 0, 0, 0, -1, -1);
1111 int s = 0;
int m = 0;
int as = 0;
int am = 0;
1124 for (
int c = 0; c <
k; c++)
1137 mv.incrementRetrievals();
1151 m +=
mv.getMultiplications();
1152 s +=
mv.getAdditions();
1156 am +=
mv.getAccumulatedMultiplications();
1157 as +=
mv.getAccumulatedAdditions();
1163#ifdef COUNT_AND_PRINT_OPERATIONS
1168 s++;
m++;
as++; am++;
1183 for (
int r = 0; r <
k; r++)
1196 mv.incrementRetrievals();
1209 m +=
mv.getMultiplications();
1210 s +=
mv.getAdditions();
1214 am +=
mv.getAccumulatedMultiplications();
1215 as +=
mv.getAccumulatedAdditions();
1221#ifdef COUNT_AND_PRINT_OPERATIONS
1226 s++;
m++;
as++; am++;
1241#ifdef COUNT_AND_PRINT_OPERATIONS
1267 poly a = f1; poly
b = f2;
1291#ifdef COUNT_AND_PRINT_OPERATIONS
1327#ifdef COUNT_AND_PRINT_OPERATIONS
1365#ifdef COUNT_AND_PRINT_OPERATIONS
1404 0, 0, 0, 0, -1, -1);
1415 for (
int r = 0; r <
k; r++)
1416 for (
int c = 0; c <
k; c++)
1427 poly divisor =
NULL;
1430 for (
int r = 0; r <=
k - 2; r++)
1436 for (
int i = r;
i <
k;
i++)
1480#if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 2)
1482 printf(
"matrix after %d steps:\n", r);
1483 for (
int u = 0; u <
k; u++)
1485 for (
int v = 0;
v <
k;
v++)
1487 if ((
v < r) && (u >
v))
1507 for (
int rr = r + 1;
rr <
k;
rr++)
1508 for (
int cc = r + 1;
cc <
k;
cc++)
1523#if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 2)
1525 printf(
"matrix after %d steps:\n",
k - 1);
1526 for (
int u = 0; u <
k; u++)
1528 for (
int v = 0;
v <
k;
v++)
1530 if ((
v <
k - 1) && (u >
v))
static void addOperationBucket(poly f1, poly f2, kBucket_pt bucket)
int getReduction(const int i, const ideal &iSB)
static void elimOperationBucketNoDiv(poly &p1, poly p2, poly p3, poly p4)
void elimOperationBucket(poly &p1, poly &p2, poly &p3, poly &p4, poly &p5, number &c5, int p5Len)
void printCounters(char *prefix, bool resetToZero)
BOOLEAN dimension(leftv res, leftv args)
Class Cache is a template-implementation of a cache with arbitrary classes for representing keys and ...
std::string toString() const
A method for providing a printable version of the represented MinorProcessor.
~IntMinorProcessor()
A destructor for deleting an instance.
IntMinorProcessor()
A constructor for creating an instance.
int * _intMatrix
private store for integer matrix entries
IntMinorValue getMinorPrivateBareiss(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.
bool isEntryZero(const int absoluteRowIndex, const int absoluteColumnIndex) const
A method for testing whether a matrix entry is zero.
void defineMatrix(const int numberOfRows, const int numberOfColumns, const int *matrix)
A method for defining a matrix with integer entries.
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 without using a cache.
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-...
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, using a cache.
int getEntry(const int rowIndex, const int columnIndex) const
A method for retrieving the matrix entry.
Class IntMinorValue is derived from MinorValue and can be used for representing values in a cache for...
Class MinorKey can be used for representing keys in a cache for sub-determinantes; see class Cache.
void getAbsoluteColumnIndices(int *const target) const
A method for retrieving the 0-based indices of all columns encoded in this MinorKey.
void selectFirstRows(const int k, const MinorKey &mk)
This method redefines the set of rows represented by this MinorKey.
bool selectNextColumns(const int k, const MinorKey &mk)
This method redefines the set of columns represented by this MinorKey.
void reset()
A method for deleting all entries of _rowKey and _columnKey.
void selectFirstColumns(const int k, const MinorKey &mk)
This method redefines the set of columns represented by this MinorKey.
MinorKey getSubMinorKey(const int absoluteEraseRowIndex, const int absoluteEraseColumnIndex) const
A method for retrieving a sub-MinorKey resulting from omitting one row and one column of this MinorKe...
int getAbsoluteColumnIndex(const int i) const
A method for retrieving the (0-based) index of the i-th column in the set of columns encoded in this.
void set(const int lengthOfRowArray, const unsigned int *rowKey, const int lengthOfColumnArray, const unsigned int *columnKey)
A setter method for class MinorKey.
void getAbsoluteRowIndices(int *const target) const
A method for retrieving the 0-based indices of all rows encoded in this MinorKey.
int getRelativeRowIndex(const int i) const
A method for retrieving the (0-based) relative index of the i-th row in this MinorKey.
bool selectNextRows(const int k, const MinorKey &mk)
This method redefines the set of rows represented by this MinorKey.
int getRelativeColumnIndex(const int i) const
A method for retrieving the (0-based) relative index of the i-th column in this MinorKey.
int compare(const MinorKey &mk) const
A comparator for two instances of MinorKey.
int getAbsoluteRowIndex(const int i) const
A method for retrieving the (0-based) index of the i-th row in the set of rows encoded in this.
virtual bool isEntryZero(const int absoluteRowIndex, const int absoluteColumnIndex) const
A method for testing whether a matrix entry is zero.
static int IOverJ(const int i, const int j)
A static method for computing the binomial coefficient i over j.
MinorKey _minor
private store for the rows and columns of the minor of interest; Usually, this minor will encode subs...
void getCurrentColumnIndices(int *const target) const
A method for obtaining the current set of columns corresponding to the current minor when iterating t...
static int NumberOfRetrievals(const int rows, const int columns, const int containerMinorSize, const int minorSize, const bool multipleMinors)
A static method for computing the maximum number of retrievals of a minor.
static int Faculty(const int i)
A static method for computing the factorial of i.
void setMinorSize(const int minorSize)
Sets the size of the minor(s) of interest.
int _containerRows
private store for the number of rows in the container minor; This is set by MinorProcessor::defineSub...
virtual std::string toString() const
A method for providing a printable version of the represented MinorProcessor.
int getBestLine(const int k, const MinorKey &mk) const
A method for identifying the row or column with the most zeros.
bool setNextKeys(const int k)
A method for iterating through all possible subsets of k rows and k columns inside a pre-defined subm...
void print() const
A method for printing a string representation of the given MinorProcessor to std::cout.
int _columns
private store for the number of columns in the underlying matrix
int _minorSize
private store for the dimension of the minor(s) of interest
void defineSubMatrix(const int numberOfRows, const int *rowIndices, const int numberOfColumns, const int *columnIndices)
A method for defining a sub-matrix within a pre-defined matrix.
MinorKey _container
private store for the rows and columns of the container minor within the underlying matrix; _containe...
bool hasNextMinor()
A method for checking whether there is a next choice of rows and columns when iterating through all m...
virtual ~MinorProcessor()
A destructor for deleting an instance.
void getCurrentRowIndices(int *const target) const
A method for obtaining the current set of rows corresponding to the current minor when iterating thro...
MinorProcessor()
The default constructor.
int _rows
private store for the number of rows in the underlying matrix
int _containerColumns
private store for the number of columns in the container minor; This is set by MinorProcessor::define...
~PolyMinorProcessor()
A destructor for deleting an instance.
std::string toString() const
A method for providing a printable version of the represented MinorProcessor.
PolyMinorProcessor()
A constructor for creating an instance.
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-...
bool isEntryZero(const int absoluteRowIndex, const int absoluteColumnIndex) const
A method for testing whether a matrix entry is zero.
poly getEntry(const int rowIndex, const int columnIndex) const
A method for retrieving the matrix entry.
void defineMatrix(const int numberOfRows, const int numberOfColumns, const poly *polyMatrix)
A method for defining a matrix with polynomial entries.
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, without using a cache.
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, using a cache.
PolyMinorValue getMinorPrivateBareiss(const int k, const MinorKey &mk, const ideal &iSB)
A method for computing the value of a minor, without using a cache.
poly * _polyMatrix
private store for polynomial matrix entries
Class PolyMinorValue is derived from MinorValue and can be used for representing values in a cache fo...
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, poly spNoether)
Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m assume (*l <= 0 || pLength(p) == *l...
void kBucketDestroy(kBucket_pt *bucket_pt)
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
void kBucket_Plus_mm_Mult_pp(kBucket_pt bucket, poly m, poly p, int l)
Bpoly == Bpoly + m*p; where m is a monom Does not destroy p and m assume (l <= 0 || pLength(p) == l)
const poly kBucketGetLm(kBucket_pt bucket)
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
#define omFreeSize(addr, size)
static int pLength(poly a)
static poly p_Add_q(poly p, poly q, const ring r)
static poly p_Mult_q(poly p, poly q, const ring r)
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
static poly pReverse(poly p)
static void p_Delete(poly *p, const ring r)
static poly pp_Mult_qq(poly p, poly q, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatibility layer for legacy polynomial operations (over currRing)
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
#define pCopy(p)
return a copy of the poly
void PrintS(const char *s)