24 matrix =
new unsigned long *[
n];
25 for(
int i = 0;
i <
n;
i++)
27 matrix[
i] =
new unsigned long[2 *
n + 1];
30 tmprow =
new unsigned long[2 *
n + 1];
39 for(
int i = 0;
i <
n;
i++)
53 for(
int i = 0;
i <
n;
i++)
70 for(
int j = piv;
j <
n +
rows + 1;
j++)
92 for(
int j =
i + 1;
j < 2 *
n + 1;
j++)
100 for(
int i = 0;
i <
n;
i++)
115 for(
int i = 0;
i <=
n;
i++)
126 for(
int i = 0;
i < 2 *
n + 1;
i++)
142 int width = ((int) log10 (mat.
p)) + 1;
144 out <<
"Pivots: " << std::endl;
145 for(
int j = 0;
j < mat.
n;
j++)
147 out << std::setw (width) << mat.
pivots[
j] <<
" ";
150 out <<
"matrix:" << std::endl;
151 for(
int i = 0;
i < mat.
rows;
i++)
153 for(
int j = 0;
j < mat.
n;
j++)
155 out << std::setw (width) << mat.
matrix[
i][
j] <<
" ";
158 for(
int j = mat.
n;
j <= 2 * mat.
n;
j++)
160 out << std::setw (width) << mat.
matrix[
i][
j] <<
" ";
164 out <<
"tmprow: " << std::endl;
165 for(
int j = 0;
j < mat.
n;
j++)
167 out << std::setw (width) << mat.
tmprow[
j] <<
" ";
170 for(
int j = mat.
n;
j <= 2 * mat.
n;
j++)
172 out << std::setw (width) << mat.
tmprow[
j] <<
" ";
186 matrix =
new unsigned long *[
n];
187 for(
int i = 0;
i <
n;
i++)
196 for (
int i = 0;
i <
n;
i++)
209 for(
int i = 0;
i <
n;
i++)
218 for(
int i = 0;
i <
n;
i++)
230 for(
int j =
i + 1;
j <
n;
j++)
241 unsigned x = row[piv];
250 int smallestNonPivIndex = 0;
251 while (
nonPivots[smallestNonPivIndex] < piv)
253 smallestNonPivIndex++;
256 for (
int j = smallestNonPivIndex;
j <
n-
rows;
j++)
280 for(
int i = 0;
i <
n;
i++)
293 for (
int j = piv;
j <
n;
j++)
333 for(
int i = 0;
i < mat.
rows;
i++)
346 for(
int i = 0;
i <
n;
i++)
348 bool isPivot =
false;
372 for(
int i =
n-1;
i >= 0;
i--)
374 bool isPivot =
false;
394 unsigned **nonzeroIndices,
unsigned *nonzeroCounts,
395 unsigned long *
result,
unsigned n,
unsigned long p)
399 for(
int i = 0;
i < n;
i++)
402 for(
int j = 0;
j < nonzeroCounts[
i];
j++)
416void printVec (
unsigned long *
vec,
int n)
418 for(
int i = 0;
i < n;
i++)
420 std::cout <<
vec[
i] <<
", ";
423 std::cout << std::endl;
434 unsigned long *
result =
new unsigned long[n + 1];
435 unsigned long *mpvec =
new unsigned long[n + 1];
436 unsigned long *tmp =
new unsigned long[n + 1];
439 for(
int i = 0;
i <= n;
i++)
450 unsigned* nonzeroCounts =
new unsigned[n];
451 unsigned** nonzeroIndices =
new unsigned*[n];
452 for (
int i = 0;
i < n;
i++)
454 nonzeroIndices[
i] =
new unsigned[n];
455 nonzeroCounts[
i] = 0;
456 for (
int j = 0;
j < n;
j++)
460 nonzeroIndices[
i][nonzeroCounts[
i]] =
j;
468 unsigned long *
vec =
new unsigned long[n];
469 unsigned long *vecnew =
new unsigned long[n];
471 unsigned loopsEven =
true;
474 for(
int j = 0;
j < n;
j++)
498 unsigned degmpvec = n;
499 while(mpvec[degmpvec] == 0)
518 for(
int j = 0;
j <= n;
j++)
522 degresult =
lcm (tmp,
result, mpvec,
p, degresult, degmpvec);
552 loopsEven = !loopsEven;
555 for (
int i = 0;
i < n;
i++)
557 delete[] nonzeroIndices[
i];
559 delete[] nonzeroIndices;
560 delete[] nonzeroCounts;
572void rem (
unsigned long *a,
unsigned long *q,
unsigned long p,
int °a,
577 unsigned d = dega - degq;
579 for(
int i = degq;
i >= 0;
i--)
589 while(dega >= 0 && a[dega] == 0)
597void quo (
unsigned long *a,
unsigned long *q,
unsigned long p,
int °a,
600 unsigned degres = dega - degq;
601 unsigned long *
result =
new unsigned long[degres + 1];
604 for (
int i = 0;
i <= degres;
i++)
611 unsigned d = dega - degq;
614 for(
int i = degq;
i >= 0;
i--)
624 while(dega >= 0 && a[dega] == 0)
631 for(
int i = 0;
i <= degres;
i++)
636 for(
int i = degres + 1;
i <= degq + degres;
i++)
647void mult (
unsigned long *
result,
unsigned long *a,
unsigned long *
b,
648 unsigned long p,
int dega,
int degb)
652 for(
int i = 0;
i <= dega;
i++)
654 for(
int j = 0;
j <= degb;
j++)
666int gcd (
unsigned long *
g,
unsigned long *a,
unsigned long *
b,
667 unsigned long p,
int dega,
int degb)
669 unsigned long *
tmp1 =
new unsigned long[dega + 1];
670 unsigned long *
tmp2 =
new unsigned long[degb + 1];
671 for(
int i = 0;
i <= dega;
i++)
675 for(
int i = 0;
i <= degb;
i++)
682 unsigned long *swappol;
697 for(
int i = 0;
i <= degtmp1;
i++)
709int lcm (
unsigned long *
l,
unsigned long *a,
unsigned long *
b,
710 unsigned long p,
int dega,
int degb)
712 unsigned long *
g =
new unsigned long[dega + 1];
714 for(
int i = 0;
i <= dega;
i++)
729 if(
l[dega + degb + 1] != 1)
732 for(
int i = 0;
i <= dega + degb;
i++)
753 long long q, t1, t2, t3;
773 return (
unsigned long) u1;
bool findLinearDependency(unsigned long *newRow, unsigned long *dep)
void normalizeTmp(unsigned i)
int firstNonzeroEntry(unsigned long *row)
LinearDependencyMatrix(unsigned n, unsigned long p)
~LinearDependencyMatrix()
void normalizeRow(unsigned long *row, unsigned i)
NewVectorMatrix(unsigned n, unsigned long p)
void insertRow(unsigned long *row)
int findLargestNonpivot()
void insertMatrix(LinearDependencyMatrix &mat)
int firstNonzeroEntry(unsigned long *row)
int findSmallestNonpivot()
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
void quo(unsigned long *a, unsigned long *q, unsigned long p, int °a, int degq)
unsigned long modularInverse(long long x, long long p)
unsigned long * computeMinimalPolynomial(unsigned long **matrix, unsigned n, unsigned long p)
void vectorMatrixMult(unsigned long *vec, unsigned long **mat, unsigned **nonzeroIndices, unsigned *nonzeroCounts, unsigned long *result, unsigned n, unsigned long p)
int gcd(unsigned long *g, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
void rem(unsigned long *a, unsigned long *q, unsigned long p, int °a, int degq)
unsigned long modularInverse(long long x, long long p)
static unsigned long multMod(unsigned long a, unsigned long b, unsigned long p)
ostream & operator<<(ostream &s, const spectrum &spec)