source: git/kernel/tgbgauss.cc @ 06662e

spielwiese
Last change on this file since 06662e was 690e21e, checked in by Hans Schönemann <hannes@…>, 14 years ago
moved option marcos to options.h git-svn-id: file:///usr/local/Singular/svn/trunk@12466 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 18.0 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id$ */
5/*
6* ABSTRACT: gauss implementation for F4
7*/
8#include "mod2.h"
9#include "options.h"
10#include "tgbgauss.h"
11#include <omalloc.h>
12#include <stdlib.h>
13#include "kutil.h"
14#include "febase.h"
15#include "polys.h"
16static const int bundle_size=100;
17
18mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b)
19{
20  mac_poly erg;
21  mac_poly* set_this;
22  set_this=&erg;
23  while((a!=NULL) &&(b!=NULL))
24  {
25    if (a->exp<b->exp)
26    {
27      (*set_this)=a;
28      a=a->next;
29      set_this= &((*set_this)->next);
30    }
31    else
32    {
33      if (a->exp>b->exp)
34      {
35        mac_poly in =new mac_poly_r();
36        in->exp=b->exp;
37        in->coef=nMult(b->coef,f);
38        (*set_this)=in;
39        b=b->next;
40        set_this= &((*set_this)->next);
41      }
42      else
43      {
44        //a->exp==b->ecp
45        number n=nMult(b->coef,f);
46        number n2=nAdd(a->coef,n);
47        nDelete(&n);
48        nDelete(&(a->coef));
49        if (nIsZero(n2))
50        {
51          nDelete(&n2);
52          mac_poly ao=a;
53          a=a->next;
54          delete ao;
55          b=b->next;
56        }
57        else
58        {
59          a->coef=n2;
60          b=b->next;
61          (*set_this)=a;
62          a=a->next;
63          set_this= &((*set_this)->next);
64        }
65      }
66    }
67  }
68  if((a==NULL)&&(b==NULL))
69  {
70    (*set_this)=NULL;
71    return erg;
72  }
73  if (b==NULL)
74  {
75    (*set_this=a);
76    return erg;
77  }
78
79  //a==NULL
80  while(b!=NULL)
81  {
82    mac_poly mp= new mac_poly_r();
83    mp->exp=b->exp;
84    mp->coef=nMult(f,b->coef);
85    (*set_this)=mp;
86    set_this=&(mp->next);
87    b=b->next;
88  }
89  (*set_this)=NULL;
90  return erg;
91}
92
93void mac_mult_cons(mac_poly p,number c)
94{
95  while(p)
96  {
97    number m=nMult(p->coef,c);
98    nDelete(&(p->coef));
99    p->coef=m;
100    p=p->next;
101  }
102}
103
104int mac_length(mac_poly p)
105{
106  int l=0;
107  while(p){
108    l++;
109    p=p->next;
110  }
111  return l;
112}
113
114//contrary to delete on the mac_poly_r, the coefficients are also destroyed here
115void mac_destroy(mac_poly p)
116{
117  mac_poly iter=p;
118  while(iter)
119  {
120    mac_poly next=iter->next;
121    nDelete(&iter->coef);
122    delete iter;
123    iter=next;
124  }
125}
126
127void simple_gauss(tgb_sparse_matrix* mat, slimgb_alg* c)
128{
129  int col, row;
130  int* row_cache=(int*) omalloc(mat->get_rows()*sizeof(int));
131  col=0;
132  row=0;
133  int i;
134  int pn=mat->get_rows();
135  int matcol=mat->get_columns();
136  int* area=(int*) omalloc(sizeof(int)*((matcol-1)/bundle_size+1));
137  const int max_area_index=(matcol-1)/bundle_size;
138    //rows are divided in areas
139  //if row begins with columns col, it is located in [area[col/bundle_size],area[col/bundle_size+1]-1]
140  assume(pn>0);
141  //first clear zeroes
142  for(i=0;i<pn;i++)
143  {
144    if(mat->zero_row(i))
145    {
146      mat->perm_rows(i,pn-1);
147      pn--;
148      if(i!=pn){i--;}
149    }
150
151  }
152  mat->sort_rows();
153  for(i=0;i<pn;i++)
154  {
155      row_cache[i]=mat->min_col_not_zero_in_row(i);
156      // Print("row_cache:%d\n",row_cache[i]);
157  }
158  int last_area=-1;
159  for(i=0;i<pn;i++)
160  {
161    int this_area=row_cache[i]/bundle_size;
162    assume(this_area>=last_area);
163    if(this_area>last_area)
164    {
165      int j;
166      for(j=last_area+1;j<=this_area;j++)
167        area[j]=i;
168      last_area=this_area;
169    }
170  }
171  for(i=last_area+1;i<=max_area_index;i++)
172  {
173    area[i]=pn;
174  }
175  while(row<pn-1)
176  {
177    //row is the row where pivot should be
178    // row== pn-1 means we have only to act on one row so no red nec.
179    //we assume further all rows till the pn-1 row are non-zero
180
181    //select column
182
183    //col=mat->min_col_not_zero_in_row(row);
184    int max_in_area;
185    {
186      int tai=row_cache[row]/bundle_size;
187      assume(tai<=max_area_index);
188      if(tai==max_area_index)
189        max_in_area=pn-1;
190      else
191        max_in_area=area[tai+1]-1;
192    }
193    assume(row_cache[row]==mat->min_col_not_zero_in_row(row));
194    col=row_cache[row];
195
196    assume(col!=matcol);
197    int found_in_row;
198
199    found_in_row=row;
200    BOOLEAN must_reduce=FALSE;
201    assume(pn<=mat->get_rows());
202    for(i=row+1;i<=max_in_area;i++)
203    {
204      int first;//=mat->min_col_not_zero_in_row(i);
205      assume(row_cache[i]==mat->min_col_not_zero_in_row(i));
206      first=row_cache[i];
207      assume(first!=matcol);
208      if(first<col)
209      {
210        col=first;
211        found_in_row=i;
212        must_reduce=FALSE;
213      }
214      else
215      {
216        if(first==col)
217          must_reduce=TRUE;
218      }
219    }
220    //select pivot
221    int act_l=nSize(mat->get(found_in_row,col))*mat->non_zero_entries(found_in_row);
222    if(must_reduce)
223    {
224      for(i=found_in_row+1;i<=max_in_area;i++)
225      {
226        assume(mat->min_col_not_zero_in_row(i)>=col);
227        int first;
228        assume(row_cache[i]==mat->min_col_not_zero_in_row(i));
229        first=row_cache[i];
230        assume(first!=matcol);
231        //      if((!(mat->is_zero_entry(i,col)))&&(mat->non_zero_entries(i)<act_l))
232        int nz;
233        if((row_cache[i]==col)&&((nz=nSize(mat->get(i,col))*mat->non_zero_entries(i))<act_l))
234        {
235          found_in_row=i;
236          act_l=nz;
237        }
238
239      }
240    }
241    mat->perm_rows(row,found_in_row);
242    int h=row_cache[row];
243    row_cache[row]=row_cache[found_in_row];
244    row_cache[found_in_row]=h;
245
246    if(!must_reduce)
247    {
248      row++;
249      continue;
250    }
251    //reduction
252    //must extract content and normalize here
253    mat->row_content(row);
254    mat->row_normalize(row);
255
256    //for(i=row+1;i<pn;i++){
257    for(i=max_in_area;i>row;i--)
258    {
259      int col_area_index=col/bundle_size;
260      assume(col_area_index<=max_area_index);
261      assume(mat->min_col_not_zero_in_row(i)>=col);
262      int first;
263      assume(row_cache[i]==mat->min_col_not_zero_in_row(i));
264      first=row_cache[i];
265      assume(first!=matcol);
266      if(row_cache[i]==col)
267      {
268
269        number c1=mat->get(i,col);
270        number c2=mat->get(row,col);
271        number n1=c1;
272        number n2=c2;
273
274        ksCheckCoeff(&n1,&n2);
275        //nDelete(&c1);
276        n1=nNeg(n1);
277        mat->mult_row(i,n2);
278        mat->add_lambda_times_row(i,row,n1);
279        nDelete(&n1);
280        nDelete(&n2);
281        assume(mat->is_zero_entry(i,col));
282        row_cache[i]=mat->min_col_not_zero_in_row(i);
283        assume(mat->min_col_not_zero_in_row(i)>col);
284        if(row_cache[i]==matcol)
285        {
286          int index;
287          index=i;
288          int last_in_area;
289          int this_cai=col_area_index;
290          while(this_cai<max_area_index)
291          {
292            last_in_area=area[this_cai+1]-1;
293            int h_c=row_cache[last_in_area];
294            row_cache[last_in_area]=row_cache[index];
295            row_cache[index]=h_c;
296            mat->perm_rows(index,last_in_area);
297            index=last_in_area;
298            this_cai++;
299            area[this_cai]--;
300          }
301          mat->perm_rows(index,pn-1);
302          row_cache[index]=row_cache[pn-1];
303          row_cache[pn-1]=matcol;
304          pn--;
305        }
306        else
307        {
308          int index;
309          index=i;
310          int last_in_area;
311          int this_cai=col_area_index;
312          int final_cai=row_cache[index]/bundle_size;
313          assume(final_cai<=max_area_index);
314          while(this_cai<final_cai)
315          {
316            last_in_area=area[this_cai+1]-1;
317            int h_c=row_cache[last_in_area];
318            row_cache[last_in_area]=row_cache[index];
319            row_cache[index]=h_c;
320            mat->perm_rows(index,last_in_area);
321            index=last_in_area;
322            this_cai++;
323            area[this_cai]--;
324          }
325        }
326      }
327      else
328        assume(mat->min_col_not_zero_in_row(i)>col);
329    }
330//     for(i=row+1;i<pn;i++)
331//     {
332//       assume(mat->min_col_not_zero_in_row(i)==row_cache[i]);
333//       // if(mat->zero_row(i))
334//       assume(matcol==mat->get_columns());
335//       if(row_cache[i]==matcol)
336//       {
337//         assume(mat->zero_row(i));
338//         mat->perm_rows(i,pn-1);
339//         row_cache[i]=row_cache[pn-1];
340//         row_cache[pn-1]=matcol;
341//         pn--;
342//         if(i!=pn){i--;}
343//       }
344//     }
345#ifdef TGB_DEBUG
346  {
347    int last=-1;
348    for(i=0;i<pn;i++)
349    {
350      int act=mat->min_col_not_zero_in_row(i);
351      assume(act>last);
352    }
353    for(i=pn;i<mat->get_rows();i++)
354    {
355      assume(mat->zero_row(i));
356    }
357  }
358#endif
359    row++;
360  }
361  omfree(area);
362  omfree(row_cache);
363}
364
365void simple_gauss2(tgb_matrix* mat)
366{
367  int col, row;
368  col=0;
369  row=0;
370  int i;
371  int pn=mat->get_rows();
372  assume(pn>0);
373  //first clear zeroes
374//   for(i=0;i<pn;i++)
375//   {
376//     if(mat->zero_row(i))
377//     {
378//       mat->perm_rows(i,pn-1);
379//       pn--;
380//       if(i!=pn){i--;}
381//     }
382//   }
383  while((row<pn-1)&&(col<mat->get_columns())){
384    //row is the row where pivot should be
385    // row== pn-1 means we have only to act on one row so no red nec.
386    //we assume further all rows till the pn-1 row are non-zero
387
388    //select column
389
390    //    col=mat->min_col_not_zero_in_row(row);
391    assume(col!=mat->get_columns());
392    int found_in_row=-1;
393
394    //    found_in_row=row;
395    assume(pn<=mat->get_rows());
396    for(i=row;i<pn;i++)
397    {
398      //    int first=mat->min_col_not_zero_in_row(i);
399      //  if(first<col)
400      if(!(mat->is_zero_entry(i,col)))
401      {
402        found_in_row=i;
403        break;
404      }
405    }
406    if(found_in_row!=-1)
407    {
408    //select pivot
409      int act_l=mat->non_zero_entries(found_in_row);
410      for(i=i+1;i<pn;i++)
411      {
412        int vgl;
413        assume(mat->min_col_not_zero_in_row(i)>=col);
414        if((!(mat->is_zero_entry(i,col)))
415        &&((vgl=mat->non_zero_entries(i))<act_l))
416        {
417          found_in_row=i;
418          act_l=vgl;
419        }
420
421      }
422      mat->perm_rows(row,found_in_row);
423
424      //reduction
425      for(i=row+1;i<pn;i++){
426        assume(mat->min_col_not_zero_in_row(i)>=col);
427        if(!(mat->is_zero_entry(i,col)))
428        {
429          number c1=nNeg(nCopy(mat->get(i,col)));
430          number c2=mat->get(row,col);
431          number n1=c1;
432          number n2=c2;
433
434          ksCheckCoeff(&n1,&n2);
435          nDelete(&c1);
436          mat->mult_row(i,n2);
437          mat->add_lambda_times_row(i,row,n1);
438          assume(mat->is_zero_entry(i,col));
439        }
440        assume(mat->min_col_not_zero_in_row(i)>col);
441      }
442      row++;
443    }
444    col++;
445    // for(i=row+1;i<pn;i++)
446//     {
447//       if(mat->zero_row(i))
448//       {
449//         mat->perm_rows(i,pn-1);
450//         pn--;
451//         if(i!=pn){i--;}
452//       }
453//     }
454  }
455}
456
457
458tgb_matrix::tgb_matrix(int i, int j)
459{
460  n=(number**) omalloc(i*sizeof (number*));;
461  int z;
462  int z2;
463  for(z=0;z<i;z++)
464  {
465    n[z]=(number*)omalloc(j*sizeof(number));
466    for(z2=0;z2<j;z2++)
467    {
468      n[z][z2]=nInit(0);
469    }
470  }
471  this->columns=j;
472  this->rows=i;
473  free_numbers=FALSE;
474}
475
476tgb_matrix::~tgb_matrix()
477{
478  int z;
479  for(z=0;z<rows;z++)
480  {
481    if(n[z])
482    {
483      if(free_numbers)
484      {
485        int z2;
486        for(z2=0;z2<columns;z2++)
487        {
488          nDelete(&(n[z][z2]));
489        }
490      }
491      omfree(n[z]);
492    }
493  }
494  omfree(n);
495}
496
497void tgb_matrix::print()
498{
499  int i;
500  int j;
501  PrintLn();
502  for(i=0;i<rows;i++)
503  {
504    PrintS("(");
505    for(j=0;j<columns;j++)
506    {
507      StringSetS("");
508      n_Write(n[i][j],currRing);
509      PrintS(StringAppendS(""));
510      PrintS("\t");
511    }
512    PrintS(")\n");
513  }
514}
515
516//transfers ownership of n to the matrix
517void tgb_matrix::set(int i, int j, number n)
518{
519  assume(i<rows);
520  assume(j<columns);
521  this->n[i][j]=n;
522}
523
524int tgb_matrix::get_rows()
525{
526  return rows;
527}
528
529int tgb_matrix::get_columns()
530{
531  return columns;
532}
533
534number tgb_matrix::get(int i, int j)
535{
536  assume(i<rows);
537  assume(j<columns);
538  return n[i][j];
539}
540
541BOOLEAN tgb_matrix::is_zero_entry(int i, int j)
542{
543  return (nIsZero(n[i][j]));
544}
545
546void tgb_matrix::perm_rows(int i, int j)
547{
548  number* h;
549  h=n[i];
550  n[i]=n[j];
551  n[j]=h;
552}
553
554int tgb_matrix::min_col_not_zero_in_row(int row)
555{
556  int i;
557  for(i=0;i<columns;i++)
558  {
559    if(!(nIsZero(n[row][i])))
560      return i;
561  }
562  return columns;//error code
563}
564
565int tgb_matrix::next_col_not_zero(int row,int pre)
566{
567  int i;
568  for(i=pre+1;i<columns;i++)
569  {
570    if(!(nIsZero(n[row][i])))
571      return i;
572  }
573  return columns;//error code
574}
575
576BOOLEAN tgb_matrix::zero_row(int row)
577{
578  int i;
579  for(i=0;i<columns;i++)
580  {
581    if(!(nIsZero(n[row][i])))
582      return FALSE;
583  }
584  return TRUE;
585}
586
587int tgb_matrix::non_zero_entries(int row)
588{
589  int i;
590  int z=0;
591  for(i=0;i<columns;i++)
592  {
593    if(!(nIsZero(n[row][i])))
594      z++;
595  }
596  return z;
597}
598
599//row add_to=row add_to +row summand*factor
600void tgb_matrix::add_lambda_times_row(int add_to,int summand,number factor)
601{
602  int i;
603  for(i=0;i<columns;i++)
604  {
605    if(!(nIsZero(n[summand][i])))
606    {
607      number n1=n[add_to][i];
608      number n2=nMult(factor,n[summand][i]);
609      n[add_to][i]=nAdd(n1,n2);
610      nDelete(&n1);
611      nDelete(&n2);
612    }
613  }
614}
615
616void tgb_matrix::mult_row(int row,number factor)
617{
618  if (nIsOne(factor))
619    return;
620  int i;
621  for(i=0;i<columns;i++)
622  {
623    if(!(nIsZero(n[row][i])))
624    {
625      number n1=n[row][i];
626      n[row][i]=nMult(n1,factor);
627      nDelete(&n1);
628    }
629  }
630}
631
632void tgb_matrix::free_row(int row, BOOLEAN free_non_zeros)
633{
634  int i;
635  for(i=0;i<columns;i++)
636    if((free_non_zeros)||(!(nIsZero(n[row][i]))))
637      nDelete(&(n[row][i]));
638  omfree(n[row]);
639  n[row]=NULL;
640}
641
642tgb_sparse_matrix::tgb_sparse_matrix(int i, int j, ring rarg)
643{
644  mp=(mac_poly*) omalloc(i*sizeof (mac_poly));;
645  int z;
646  int z2;
647  for(z=0;z<i;z++)
648  {
649    mp[z]=NULL;
650  }
651  this->columns=j;
652  this->rows=i;
653  free_numbers=FALSE;
654  r=rarg;
655}
656
657tgb_sparse_matrix::~tgb_sparse_matrix()
658{
659  int z;
660  for(z=0;z<rows;z++)
661  {
662    if(mp[z]!=NULL)
663    {
664      if(free_numbers)
665      {
666        mac_destroy(mp[z]);
667      }
668      else {
669        while(mp[z]!=NULL)
670        {
671          mac_poly next=mp[z]->next;
672          delete mp[z];
673          mp[z]=next;
674        }
675      }
676    }
677  }
678  omfree(mp);
679}
680
681static int row_cmp_gen(const void* a, const void* b)
682{
683  const mac_poly ap= *((mac_poly*) a);
684  const mac_poly bp=*((mac_poly*) b);
685  if (ap==NULL) return 1;
686  if (bp==NULL) return -1;
687  if (ap->exp<bp->exp) return -1;
688  return 1;
689}
690
691void tgb_sparse_matrix::sort_rows()
692{
693  qsort(mp,rows,sizeof(mac_poly),row_cmp_gen);
694}
695
696void tgb_sparse_matrix::print()
697{
698  int i;
699  int j;
700  PrintLn();
701  for(i=0;i<rows;i++)
702  {
703    PrintS("(");
704    for(j=0;j<columns;j++)
705    {
706      StringSetS("");
707      number n=get(i,j);
708      n_Write(n,currRing);
709      PrintS(StringAppendS(""));
710      PrintS("\t");
711    }
712    PrintS(")\n");
713  }
714}
715
716//transfers ownership of n to the matrix
717void tgb_sparse_matrix::set(int i, int j, number n)
718{
719  assume(i<rows);
720  assume(j<columns);
721  mac_poly* set_this=&mp[i];
722  //  while(((*set_this)!=NULL)&&((*set_this)­>exp<j))
723  while(((*set_this)!=NULL) && ((*set_this)->exp<j))
724    set_this=&((*set_this)->next);
725
726  if (((*set_this)==NULL)||((*set_this)->exp>j))
727  {
728    if (nIsZero(n)) return;
729    mac_poly old=(*set_this);
730    (*set_this)=new mac_poly_r();
731    (*set_this)->exp=j;
732    (*set_this)->coef=n;
733    (*set_this)->next=old;
734    return;
735  }
736  assume((*set_this)->exp==j);
737  if(!nIsZero(n))
738  {
739    nDelete(&(*set_this)->coef);
740    (*set_this)->coef=n;
741  }
742  else
743  {
744    nDelete(&(*set_this)->coef);
745    mac_poly dt=(*set_this);
746    (*set_this)=dt->next;
747    delete dt;
748  }
749  return;
750}
751
752int tgb_sparse_matrix::get_rows()
753{
754  return rows;
755}
756
757int tgb_sparse_matrix::get_columns()
758{
759  return columns;
760}
761
762number tgb_sparse_matrix::get(int i, int j)
763{
764  assume(i<rows);
765  assume(j<columns);
766  mac_poly r=mp[i];
767  while((r!=NULL)&&(r->exp<j))
768    r=r->next;
769  if ((r==NULL)||(r->exp>j))
770  {
771    number n=nInit(0);
772    return n;
773  }
774  assume(r->exp==j);
775  return r->coef;
776}
777
778BOOLEAN tgb_sparse_matrix::is_zero_entry(int i, int j)
779{
780  assume(i<rows);
781  assume(j<columns);
782  mac_poly r=mp[i];
783  while((r!=NULL)&&(r->exp<j))
784    r=r->next;
785  if ((r==NULL)||(r->exp>j))
786  {
787    return TRUE;
788  }
789  assume(!nIsZero(r->coef));
790  assume(r->exp==j);
791  return FALSE;
792}
793
794int tgb_sparse_matrix::min_col_not_zero_in_row(int row)
795{
796  if(mp[row]!=NULL)
797  {
798    assume(!nIsZero(mp[row]->coef));
799    return mp[row]->exp;
800  }
801  else
802    return columns;//error code
803}
804
805int tgb_sparse_matrix::next_col_not_zero(int row,int pre)
806{
807  mac_poly r=mp[row];
808  while((r!=NULL)&&(r->exp<=pre))
809    r=r->next;
810  if(r!=NULL)
811  {
812    assume(!nIsZero(r->coef));
813    return r->exp;
814  }
815  return columns;//error code
816}
817
818BOOLEAN tgb_sparse_matrix::zero_row(int row)
819{
820  assume((mp[row]==NULL)||(!nIsZero(mp[row]->coef)));
821  if (mp[row]==NULL)
822    return TRUE;
823  else
824    return FALSE;
825}
826
827void tgb_sparse_matrix::row_normalize(int row)
828{
829  if (!rField_has_simple_inverse(r))  /* Z/p, GF(p,n), R, long R/C */
830  {
831    mac_poly m=mp[row];
832    while (m!=NULL)
833    {
834      if (currRing==r) {nTest(m->coef);}
835      n_Normalize(m->coef,r);
836      m=m->next;
837    }
838  }
839}
840
841void tgb_sparse_matrix::row_content(int row)
842{
843  mac_poly ph=mp[row];
844  number h,d;
845  mac_poly p;
846
847  if(TEST_OPT_CONTENTSB) return;
848  if(ph->next==NULL)
849  {
850    nDelete(&ph->coef);
851    ph->coef=nInit(1);
852  }
853  else
854  {
855    nNormalize(ph->coef);
856    if(!nGreaterZero(ph->coef))
857    {
858      //ph = pNeg(ph);
859      p=ph;
860      while(p!=NULL)
861      {
862        p->coef=nNeg(p->coef);
863        p=p->next;
864      }
865    }
866
867    h=nCopy(ph->coef);
868    p = ph->next;
869
870    while (p!=NULL)
871    {
872      nNormalize(p->coef);
873      d=nGcd(h,p->coef,currRing);
874      nDelete(&h);
875      h = d;
876      if(nIsOne(h))
877      {
878        break;
879      }
880      p=p->next;
881    }
882    p = ph;
883    //number tmp;
884    if(!nIsOne(h))
885    {
886      while (p!=NULL)
887      {
888        d = nIntDiv(pGetCoeff(p),h);
889        nDelete(&p->coef);
890        p->coef=d;
891        p=p->next;
892      }
893    }
894    nDelete(&h);
895  }
896}
897int tgb_sparse_matrix::non_zero_entries(int row)
898{
899  return mac_length(mp[row]);
900}
901
902//row add_to=row add_to +row summand*factor
903void tgb_sparse_matrix::add_lambda_times_row(int add_to,int summand,number factor)
904{
905  mp[add_to]= mac_p_add_ff_qq(mp[add_to], factor,mp[summand]);
906}
907
908void tgb_sparse_matrix::mult_row(int row,number factor)
909{
910  if (nIsZero(factor))
911  {
912    mac_destroy(mp[row]);
913    mp[row]=NULL;
914
915    return;
916  }
917  if(nIsOne(factor))
918    return;
919  mac_mult_cons(mp[row],factor);
920}
921
922void tgb_sparse_matrix::free_row(int row, BOOLEAN free_non_zeros)
923{
924  if(free_non_zeros)
925    mac_destroy(mp[row]);
926  else
927  {
928    while(mp[row]!=NULL)
929    {
930      mac_poly next=mp[row]->next;
931      delete mp[row];
932      mp[row]=next;
933    }
934  }
935  mp[row]=NULL;
936}
Note: See TracBrowser for help on using the repository browser.