430{
433
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];
437
438
439 for(
int i = 0;
i <= n;
i++)
440 {
442 }
444
445 int degresult = 0;
446
447
448
449
450 unsigned* nonzeroCounts = new unsigned[n];
451 unsigned** nonzeroIndices = new unsigned*[n];
452 for (
int i = 0;
i < n;
i++)
453 {
454 nonzeroIndices[
i] =
new unsigned[n];
455 nonzeroCounts[
i] = 0;
456 for (
int j = 0;
j < n;
j++)
457 {
459 {
460 nonzeroIndices[
i][nonzeroCounts[
i]] =
j;
462 }
463 }
464 }
465
467
468 unsigned long *
vec =
new unsigned long[n];
469 unsigned long *vecnew = new unsigned long[n];
470
471 unsigned loopsEven = true;
473 {
474 for(
int j = 0;
j < n;
j++)
475 {
477 }
479
480 lindepmat.resetMatrix ();
481
482 while(true)
483 {
484 bool ld = lindepmat.findLinearDependency (
vec, mpvec);
485
486 if(ld)
487 {
488 break;
489 }
490
495 }
496
497
498 unsigned degmpvec = n;
499 while(mpvec[degmpvec] == 0)
500 {
501 degmpvec--;
502 }
503
504
505
506 if(degmpvec == n)
507 {
512 }
513 else
514 {
515
516
517
518 for(
int j = 0;
j <= n;
j++)
519 {
521 }
522 degresult =
lcm (tmp,
result, mpvec,
p, degresult, degmpvec);
526
527 if(degresult == n)
528 {
529
531 }
532 else
533 {
534 newvectormat.insertMatrix (lindepmat);
535
536
537
538
539
540
541 if (loopsEven)
542 {
543 i = newvectormat.findSmallestNonpivot ();
544 }
545 else
546 {
547 i = newvectormat.findLargestNonpivot ();
548 }
549 }
550 }
551
552 loopsEven = !loopsEven;
553 }
554
555 for (
int i = 0;
i < n;
i++)
556 {
557 delete[] nonzeroIndices[
i];
558 }
559 delete[] nonzeroIndices;
560 delete[] nonzeroCounts;
561
562
563 delete[]vecnew;
565 delete[]tmp;
566 delete[]mpvec;
567
569}
void vectorMatrixMult(unsigned long *vec, unsigned long **mat, unsigned **nonzeroIndices, unsigned *nonzeroCounts, unsigned long *result, unsigned n, unsigned long p)
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)