source: git/Singular/clapsing.cc @ bd00313

fieker-DuValspielwiese
Last change on this file since bd00313 was bd00313, checked in by Hans Schönemann <hannes@…>, 27 years ago
*** empty log message *** git-svn-id: file:///usr/local/Singular/svn/trunk@630 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 18.8 KB
Line 
1// emacs edit mode for this file is -*- C++ -*-
2/****************************************
3*  Computer Algebra System SINGULAR     *
4****************************************/
5// $Id: clapsing.cc,v 1.12 1997-08-20 18:48:55 Singular Exp $
6/*
7* ABSTRACT: interface between Singular and factory
8*/
9
10
11#include "mod2.h"
12#ifdef HAVE_FACTORY
13#define SI_DONT_HAVE_GLOBAL_VARS
14#include "tok.h"
15#include "clapsing.h"
16#include "ipid.h"
17#include "numbers.h"
18#include "subexpr.h"
19#include "ipshell.h"
20#include <factory.h>
21#include "clapconv.h"
22#ifdef HAVE_LIBFAC_P
23#include <factor.h>
24#endif
25
26poly singclap_gcd ( poly f, poly g )
27{
28  // for now there is only the possibility to handle polynomials over
29  // Q and Fp ...
30  if ( nGetChar() == 0 || nGetChar() > 1 )
31  {
32    setCharacteristic( nGetChar() );
33    CanonicalForm F( convSingPClapP( f ) ), G( convSingPClapP( g ) );
34    poly res=convClapPSingP( gcd( F, G ) );
35    Off(SW_RATIONAL);
36    return res;
37  }
38  // and over Q(a) / Fp(a)
39  else if (( nGetChar()==1 ) /* Q(a) */
40  || (nGetChar() <-1))       /* Fp(a) */
41  {
42    if (nGetChar()==1) setCharacteristic( 0 );
43    else               setCharacteristic( -nGetChar() );
44    poly res;
45    if (currRing->minpoly!=NULL)
46    {
47      CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
48      Variable a=rootOf(mipo);
49      CanonicalForm F( convSingAPClapAP( f,a ) ), G( convSingAPClapAP( g,a ) );
50      res= convClapAPSingAP( gcd( F, G ) );
51    }
52    else
53    {
54      CanonicalForm F( convSingTrPClapP( f ) ), G( convSingTrPClapP( g ) );
55      res= convClapPSingTrP( gcd( F, G ) );
56    }
57    Off(SW_RATIONAL);
58    return res;
59  }
60  else
61    WerrorS( "not implemented" );
62  return NULL;
63}
64
65//poly singclap_resultant ( poly f, poly g , poly x)
66//{
67//  int i=pIsPurePower(x);
68//  if (i==0)
69//  {
70//    WerrorS("3rd argument must be a ring variable");
71//    return NULL;
72//  }
73//  Variable X(i);
74//  // for now there is only the possibility to handle polynomials over
75//  // Q and Fp ...
76//  if ( nGetChar() == 0 || nGetChar() > 1 )
77//  {
78//    setCharacteristic( nGetChar() );
79//    CanonicalForm F( convSingPClapP( f ) ), G( convSingPClapP( g ) );
80//    poly res=convClapPSingP( resultant( F, G, X ) );
81//    Off(SW_RATIONAL);
82//    return res;
83//  }
84//  // and over Q(a) / Fp(a)
85//  else if (( nGetChar()==1 ) /* Q(a) */
86//  || (nGetChar() <-1))       /* Fp(a) */
87//  {
88//    if (nGetChar()==1) setCharacteristic( 0 );
89//    else               setCharacteristic( -nGetChar() );
90//    poly res;
91//    if (currRing->minpoly!=NULL)
92//    {
93//      CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
94//      Variable a=rootOf(mipo);
95//      CanonicalForm F( convSingAPClapAP( f,a ) ), G( convSingAPClapAP( g,a ) );
96//      res= convClapAPSingAP( resultant( F, G, X ) );
97//    }
98//    else
99//    {
100//      CanonicalForm F( convSingTrPClapP( f ) ), G( convSingTrPClapP( g ) );
101//      res= convClapPSingTrP( resultant( F, G, X ) );
102//    }
103//    Off(SW_RATIONAL);
104//    return res;
105//  }
106//  else
107//    WerrorS( "not implemented" );
108//  return NULL;
109//}
110poly singclap_resultant ( poly f, poly g , poly x)
111{
112  int i=pVar(x);
113  if (i==0)
114  {
115    WerrorS("ringvar expected");
116    return NULL;
117  }
118  ideal I=idInit(1,1);
119
120  // get the coeffs von f wrt. x:
121  I->m[0]=pCopy(f);
122  matrix ffi=mpCoeffs(I,i);
123  ffi->rank=1;
124  ffi->ncols=ffi->nrows;
125  ffi->nrows=1;
126  ideal fi=(ideal)ffi;
127
128  // get the coeffs von g wrt. x:
129  I->m[0]=pCopy(g);
130  matrix ggi=mpCoeffs(I,i);
131  ggi->rank=1;
132  ggi->ncols=ggi->nrows;
133  ggi->nrows=1;
134  ideal gi=(ideal)ggi;
135
136  // contruct the matrix:
137  int fn=IDELEMS(fi); //= deg(f,x)+1
138  int gn=IDELEMS(gi); //= deg(g,x)+1
139  matrix m=mpNew(fn+gn-2,fn+gn-2);
140  if(m==NULL)
141  {
142    return NULL;
143  }
144
145  // enter the coeffs into m:
146  int j;
147  for(i=0;i<gn-1;i++)
148  {
149    for(j=0;j<fn;j++)
150    {
151      MATELEM(m,i+1,fn-j+i)=pCopy(fi->m[j]);
152    }
153  }
154  for(i=0;i<fn-1;i++)
155  {
156    for(j=0;j<gn;j++)
157    {
158      MATELEM(m,gn+i,gn-j+i)=pCopy(gi->m[j]);
159    }
160  }
161
162  poly r=mpDet(m);
163
164  idDelete(&fi);
165  idDelete(&gi);
166  idDelete((ideal *)&m);
167  return r;
168}
169
170lists singclap_extgcd ( poly f, poly g )
171{
172  // for now there is only the possibility to handle univariate
173  // polynomials over
174  // Q and Fp ...
175  poly res=NULL,pa=NULL,pb=NULL;
176  On(SW_SYMMETRIC_FF);
177  if ( nGetChar() == 0 || nGetChar() > 1 )
178  {
179    setCharacteristic( nGetChar() );
180    CanonicalForm F( convSingPClapP( f ) ), G( convSingPClapP( g ) );
181    if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
182    {
183      Off(SW_RATIONAL);
184      WerrorS("not univariate");
185      return NULL;
186    }
187    CanonicalForm Fa,Gb;
188    res=convClapPSingP( extgcd( F, G, Fa, Gb ) );
189    pa=convClapPSingP(Fa);
190    pb=convClapPSingP(Gb);
191    Off(SW_RATIONAL);
192  }
193  // and over Q(a) / Fp(a)
194  else if (( nGetChar()==1 ) /* Q(a) */
195  || (nGetChar() <-1))       /* Fp(a) */
196  {
197    if (nGetChar()==1) setCharacteristic( 0 );
198    else               setCharacteristic( -nGetChar() );
199    CanonicalForm Fa,Gb;
200    if (currRing->minpoly!=NULL)
201    {
202      CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
203      Variable a=rootOf(mipo);
204      CanonicalForm F( convSingAPClapAP( f,a ) ), G( convSingAPClapAP( g,a ) );
205      if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
206      {
207        WerrorS("not univariate");
208        return NULL;
209      }
210      res= convClapAPSingAP( extgcd( F, G, Fa, Gb ) );
211      pa=convClapAPSingAP(Fa);
212      pb=convClapAPSingAP(Gb);
213    }
214    else
215    {
216      CanonicalForm F( convSingTrPClapP( f ) ), G( convSingTrPClapP( g ) );
217      if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
218      {
219        Off(SW_RATIONAL);
220        WerrorS("not univariate");
221        return NULL;
222      }
223      res= convClapPSingTrP( extgcd( F, G, Fa, Gb ) );
224      pa=convClapPSingTrP(Fa);
225      pb=convClapPSingTrP(Gb);
226    }
227    Off(SW_RATIONAL);
228  }
229  else
230  {
231    WerrorS( "not implemented" );
232    return NULL;
233  }
234  lists L=(lists)Alloc(sizeof(slists));
235  L->Init(3);
236  L->m[0].rtyp=POLY_CMD;
237  L->m[0].data=(void *)res;
238  L->m[1].rtyp=POLY_CMD;
239  L->m[1].data=(void *)pa;
240  L->m[2].rtyp=POLY_CMD;
241  L->m[2].data=(void *)pb;
242  return L;
243}
244
245poly singclap_pdivide ( poly f, poly g )
246{
247  // for now there is only the possibility to handle polynomials over
248  // Q and Fp ...
249  if ( nGetChar() == 0 || nGetChar() > 1 )
250  {
251    setCharacteristic( nGetChar() );
252    CanonicalForm F( convSingPClapP( f ) ), G( convSingPClapP( g ) );
253    return convClapPSingP( F / G );
254  }
255  // and over Q(a) / Fp(a)
256  else if (( nGetChar()==1 ) /* Q(a) */
257  || (nGetChar() <-1))       /* Fp(a) */
258  {
259    if (nGetChar()==1) setCharacteristic( 0 );
260    else               setCharacteristic( -nGetChar() );
261    poly res;
262    if (currRing->minpoly!=NULL)
263    {
264      CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
265      Variable a=rootOf(mipo);
266      CanonicalForm F( convSingAPClapAP( f,a ) ), G( convSingAPClapAP( g,a ) );
267      res= convClapAPSingAP(  F / G  );
268    }
269    else
270    {
271      CanonicalForm F( convSingTrPClapP( f ) ), G( convSingTrPClapP( g ) );
272      res= convClapPSingTrP(  F / G  );
273    }
274    Off(SW_RATIONAL);
275    return res;
276  }
277  else
278    WerrorS( "not implemented" );
279  return NULL;
280}
281
282void singclap_divide_content ( poly f )
283{
284  if ( nGetChar() == 1 )
285    setCharacteristic( 0 );
286  else  if ( nGetChar() == -1 )
287    return; /* not implemented for R */
288  else  if ( nGetChar() < 0 )
289    setCharacteristic( -nGetChar() );
290  else
291    setCharacteristic( nGetChar() );
292  if ( f==NULL )
293  {
294    return;
295  }
296  else  if ( pNext( f ) == NULL )
297  {
298    pSetCoeff( f, nInit( 1 ) );
299    return;
300  }
301  else
302  {
303    CFList L;
304    CanonicalForm g, h;
305    poly p = pNext(f);
306    nTest(pGetCoeff(f));
307    g = convSingTrClapP( ((lnumber)pGetCoeff(f))->z );
308    L.append( g );
309    while ( p && (g != 1) )
310    {
311      nTest(pGetCoeff(p));
312      h = convSingTrClapP( ((lnumber)pGetCoeff(p))->z );
313      p = pNext( p );
314      g = gcd( g, h );
315      L.append( h );
316    }
317    if ( g == 1 )
318    {
319      pTest(f);
320      return;
321    }
322    #ifdef LDEBUG
323    else if ( g == 0 )
324    {
325      pTest(f);
326      pWrite(f);
327      PrintS("=> gcd 0 in divide_content\n");
328      return;
329    }
330    #endif
331    else
332    {
333      CFListIterator i;
334      for ( i = L, p = f; i.hasItem(); i++, p=pNext(p) )
335      {
336        lnumber c=(lnumber)pGetCoeff(p);
337        napDelete(&c->z);
338        #ifdef LDEBUG
339        number nt=nInit(1);
340        memset(nt,0,sizeof(slnumber));
341        lnumber nnt=(lnumber)nt;
342        nnt->z=convClapPSingTr( i.getItem());
343        nTest(nt);
344        #endif
345        c->z=convClapPSingTr( i.getItem() / g );
346        nTest((number)c);
347        #ifdef LDEBUG
348        number cn=(number)c;
349        StringSet(""); nWrite(nt); StringAppend(" == ");
350        nWrite(cn);PrintS(StringAppend("\n"));
351        #endif
352      }
353    }
354    pTest(f);
355  }
356}
357
358ideal singclap_factorize ( poly f, intvec ** v , int with_exps)
359{
360  // with_exps: 1 return only true factors
361  //            2 return true factors and exponents
362  //            0 return factors and exponents
363
364  ideal res=NULL;
365  if (f==NULL)
366  {
367    res=idInit(1,1);
368    if (with_exps!=1)
369    {
370      (*v)=new intvec(1);
371    }
372    return res;
373  }
374  Off(SW_RATIONAL);
375  On(SW_SYMMETRIC_FF);
376  CFFList L;
377  number N=NULL;
378
379  if ( (nGetChar() == 0) || (nGetChar() > 1) )
380  {
381    setCharacteristic( nGetChar() );
382    if (nGetChar()==0) /* Q */
383    {
384      if (f!=NULL)
385      {
386        if (with_exps==0)
387          N=nCopy(pGetCoeff(f));
388        pCleardenom(f);
389        if (with_exps==0)
390        {
391          number nn=nDiv(N,pGetCoeff(f));
392          nDelete(&N);
393          N=nn;
394        } 
395      } 
396    }
397    CanonicalForm F( convSingPClapP( f ) );
398    if (nGetChar()==0) /* Q */
399    {
400      L = factorize( F );
401    }
402    else /* Fp */
403    {
404#ifdef HAVE_LIBFAC_P
405      L = Factorize( F );
406#else
407      return NULL;
408#endif
409    }
410  }
411  // and over Q(a) / Fp(a)
412  else if (( nGetChar()==1 ) /* Q(a) */
413  || (nGetChar() <-1))       /* Fp(a) */
414  {
415    if (nGetChar()==1) setCharacteristic( 0 );
416    else               setCharacteristic( -nGetChar() );
417    if (currRing->minpoly!=NULL)
418    {
419      //if (nGetChar()==1)
420      //{
421      //  WerrorS("not implemented");
422      //  return NULL;
423      //}
424      CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
425      Variable a=rootOf(mipo);
426      CanonicalForm F( convSingAPClapAP( f,a ) );
427      L = factorize( F, a );
428    }
429    else
430    {
431      CanonicalForm F( convSingTrPClapP( f ) );
432      if (nGetChar()==1) /* Q(a) */
433      {
434        L = factorize( F );
435      }
436      else /* Fp(a) */
437      {
438#ifdef HAVE_LIBFAC_P
439        L = Factorize( F );
440#else
441        return NULL;
442#endif
443      }
444    }
445  }
446  else
447  {
448    WerrorS( "not implemented" );
449    goto end;
450  }
451  {
452    // the first factor should be a constant
453    if ( getNumVars(L.getFirst().factor()) != 0 )
454      L.insert(CFFactor(1,1));
455    // convert into ideal
456    int n = L.length();
457    CFFListIterator J=L;
458    int j=0;
459    if (with_exps!=1)
460    {
461      if ((with_exps==2)&&(n>1))
462      {
463        n--;
464        J++;
465      }
466      *v = new intvec( n );
467    }
468    res = idInit( n ,1);
469    for ( ; J.hasItem(); J++, j++ )
470    {
471      if (with_exps!=1) (**v)[j] = J.getItem().exp();
472      if ((nGetChar()==0)||(nGetChar()>1))           /* Q, Fp */
473        res->m[j] = convClapPSingP( J.getItem().factor() );
474      else if ((nGetChar()==1)||(nGetChar()<-1))     /* Q(a), Fp(a) */
475      {
476        if (currRing->minpoly==NULL)
477          res->m[j] = convClapPSingTrP( J.getItem().factor() );
478        else
479          res->m[j] = convClapAPSingAP( J.getItem().factor() );
480      }
481    }
482    if (N!=NULL) 
483    {
484      pMultN(res->m[0],N);
485      nDelete(&N);
486    } 
487    // delete constants
488    if ((with_exps!=0) && (res!=NULL))
489    {
490      int i=IDELEMS(res)-1;
491      for(;i>=0;i--)
492      {
493        if (pIsConstant(res->m[i]))
494          pDelete(&(res->m[i]));
495      }
496      idSkipZeroes(res);
497      if (res->m[0]==NULL)
498      {
499        res->m[0]=pOne();
500      }
501    }
502  }
503end:
504  return res;
505}
506
507matrix singclap_irrCharSeries ( ideal I)
508{
509#ifdef HAVE_LIBFAC_P
510  // for now there is only the possibility to handle polynomials over
511  // Q and Fp ...
512  matrix res=NULL;
513  int i;
514  Off(SW_RATIONAL);
515  On(SW_SYMMETRIC_FF);
516  CFList L;
517  ListCFList LL;
518  if ( (nGetChar() == 0) || (nGetChar() > 1) )
519  {
520    setCharacteristic( nGetChar() );
521    for(i=0;i<IDELEMS(I);i++)
522    {
523      L.append(convSingPClapP(I->m[i]));
524    }
525  }
526  // and over Q(a) / Fp(a)
527  else if (( nGetChar()==1 ) /* Q(a) */
528  || (nGetChar() <-1))       /* Fp(a) */
529  {
530    if (nGetChar()==1) setCharacteristic( 0 );
531    else               setCharacteristic( -nGetChar() );
532    for(i=0;i<IDELEMS(I);i++)
533    {
534      L.append(convSingTrPClapP(I->m[i]));
535    }
536  }
537  else
538  {
539    WerrorS("not implemented");
540    return res;
541  }
542
543  LL=IrrCharSeries(L);
544  int m= LL.length(); // Anzahl Zeilen
545  int n=0;
546  ListIterator<CFList> LLi;
547  CFListIterator Li;
548  for ( LLi = LL; LLi.hasItem(); LLi++ )
549  {
550    n = max(LLi.getItem().length(),n);
551  }
552  res=mpNew(m,n);
553  if ((m==0) || (n==0))
554  {
555    Warn("char_series returns %d x %d matrix from %d input polys (%d)\n",m,n,IDELEMS(I)+1,LL.length());
556    iiWriteMatrix((matrix)I,"I",2,0);
557  }
558  for ( m=1, LLi = LL; LLi.hasItem(); LLi++, m++ )
559  {
560    for (n=1, Li = LLi.getItem(); Li.hasItem(); Li++, n++)
561    {
562      if ( (nGetChar() == 0) || (nGetChar() > 1) )
563        MATELEM(res,m,n)=convClapPSingP(Li.getItem());
564      else
565        MATELEM(res,m,n)=convClapPSingTrP(Li.getItem());
566    }
567  }
568  Off(SW_RATIONAL);
569  return res;
570#else
571  return NULL;
572#endif
573}
574
575char* singclap_neworder ( ideal I)
576{
577#ifdef HAVE_LIBFAC_P
578  int i;
579  Off(SW_RATIONAL);
580  On(SW_SYMMETRIC_FF);
581  CFList L;
582  if ( (nGetChar() == 0) || (nGetChar() > 1) )
583  {
584    setCharacteristic( nGetChar() );
585    for(i=0;i<IDELEMS(I);i++)
586    {
587      L.append(convSingPClapP(I->m[i]));
588    }
589  }
590  // and over Q(a) / Fp(a)
591  else if (( nGetChar()==1 ) /* Q(a) */
592  || (nGetChar() <-1))       /* Fp(a) */
593  {
594    if (nGetChar()==1) setCharacteristic( 0 );
595    else               setCharacteristic( -nGetChar() );
596    for(i=0;i<IDELEMS(I);i++)
597    {
598      L.append(convSingTrPClapP(I->m[i]));
599    }
600  }
601  else
602  {
603    WerrorS("not implemented");
604    return NULL;
605  }
606
607  List<int> IL=neworderint(L);
608  ListIterator<int> Li;
609  StringSet("");
610  Li = IL;
611  int* mark=(int*)Alloc0(pVariables*sizeof(int));
612  int cnt=pVariables;
613  loop
614  {
615    i=Li.getItem()-1;
616    mark[i]=1;
617    StringAppend(currRing->names[i]);
618    Li++;
619    cnt--;
620    if(cnt==0) break;
621    StringAppend(",");
622    if(! Li.hasItem()) break;
623  }
624  for(i=0;i<pVariables;i++)
625  {
626    if(mark[i]==0)
627    {
628      StringAppend(currRing->names[i]);
629      cnt--;
630      if(cnt==0) break;
631      StringAppend(",");
632    }
633  }
634  return mstrdup(StringAppend(""));
635#else
636  return NULL;
637#endif
638}
639
640BOOLEAN singclap_isSqrFree(poly f)
641{
642  BOOLEAN b=FALSE;
643  Off(SW_RATIONAL);
644  //  Q / Fp
645  if ( (nGetChar() == 0) || (nGetChar() > 1) )
646  {
647    setCharacteristic( nGetChar() );
648    CanonicalForm F( convSingPClapP( f ) );
649    if((nGetChar()>1)&&(!F.isUnivariate()))
650      goto err;
651    b=(BOOLEAN)isSqrFree(F);
652  }
653  // and over Q(a) / Fp(a)
654  else if (( nGetChar()==1 ) /* Q(a) */
655  || (nGetChar() <-1))       /* Fp(a) */
656  {
657    if (nGetChar()==1) setCharacteristic( 0 );
658    else               setCharacteristic( -nGetChar() );
659    //if (currRing->minpoly!=NULL)
660    //{
661    //  CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
662    //  Variable a=rootOf(mipo);
663    //  CanonicalForm F( convSingAPClapAP( f,a ) );
664    //  ...
665    //}
666    //else
667    {
668      CanonicalForm F( convSingTrPClapP( f ) );
669      b=(BOOLEAN)isSqrFree(F);
670    }
671    Off(SW_RATIONAL);
672  }
673  else
674  {
675err:
676    WerrorS( "not implemented" );
677  }
678  return b;
679}
680
681poly singclap_det( const matrix m )
682{
683  int r=m->rows();
684  if (r!=m->cols())
685  {
686    Werror("det of %d x %d matrix",r,m->cols());
687    return NULL;
688  }
689  poly res=NULL;
690  if ( nGetChar() == 0 || nGetChar() > 1 )
691  {
692    setCharacteristic( nGetChar() );
693    CFMatrix M(r,r);
694    int i,j;
695    for(i=1;i<=r;i++)
696    {
697      for(j=1;j<=r;j++)
698      {
699        M(i,j)=convSingPClapP(MATELEM(m,i,j));
700      }
701    }
702    res= convClapPSingP( determinant(M,r) ) ;
703  }
704  // and over Q(a) / Fp(a)
705  else if (( nGetChar()==1 ) /* Q(a) */
706  || (nGetChar() <-1))       /* Fp(a) */
707  {
708    if (nGetChar()==1) setCharacteristic( 0 );
709    else               setCharacteristic( -nGetChar() );
710    CFMatrix M(r,r);
711    poly res;
712    if (currRing->minpoly!=NULL)
713    {
714      CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
715      Variable a=rootOf(mipo);
716      int i,j;
717      for(i=1;i<=r;i++)
718      {
719        for(j=1;j<=r;j++)
720        {
721          M(i,j)=convSingAPClapAP(MATELEM(m,i,j),a);
722        }
723      }
724      res= convClapAPSingAP( determinant(M,r) ) ;
725    }
726    else
727    {
728      int i,j;
729      for(i=1;i<=r;i++)
730      {
731        for(j=1;j<=r;j++)
732        {
733          M(i,j)=convSingTrPClapP(MATELEM(m,i,j));
734        }
735      }
736      res= convClapPSingTrP( determinant(M,r) );
737    }
738  }
739  else
740    WerrorS( "not implemented" );
741  Off(SW_RATIONAL);
742  return res;
743}
744
745int singclap_det_i( intvec * m )
746{
747  setCharacteristic( 0 );
748  CFMatrix M(m->rows(),m->cols());
749  int i,j;
750  for(i=1;i<=m->rows();i++)
751  {
752    for(j=1;j<=m->cols();j++)
753    {
754      M(i,j)=IMATELEM(*m,i,j);
755    }
756  }
757  int res= convClapISingI( determinant(M,m->rows())) ;
758  Off(SW_RATIONAL);
759  return res;
760}
761/*==============================================================*/
762/* interpreter interface : */
763BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
764{
765  res->data=(void *)singclap_gcd((poly)(u->Data()),((poly)v->Data()));
766  return FALSE;
767}
768
769BOOLEAN jjFAC_P(leftv res, leftv u)
770{
771  intvec *v=NULL;
772  ideal f=singclap_factorize((poly)(u->Data()), &v, 0);
773#ifndef HAVE_LIBFAC_P
774  if (f==NULL) return TRUE;
775#endif
776  lists l=(lists)Alloc(sizeof(slists));
777  l->Init(2);
778  l->m[0].rtyp=IDEAL_CMD;
779  l->m[0].data=(void *)f;
780  l->m[1].rtyp=INTVEC_CMD;
781  l->m[1].data=(void *)v;
782  res->data=(void *)l;
783  return FALSE;
784}
785
786BOOLEAN jjSQR_FREE_DEC(leftv res, leftv u,leftv dummy)
787{
788  intvec *v=NULL;
789  int sw=(int)dummy->Data();
790  ideal f=singclap_factorize((poly)(u->Data()), &v, sw);
791  switch(sw)
792  {
793    case 0:
794    case 2:
795    {
796      lists l=(lists)Alloc(sizeof(slists));
797      l->Init(2);
798      l->m[0].rtyp=IDEAL_CMD;
799      l->m[0].data=(void *)f;
800      l->m[1].rtyp=INTVEC_CMD;
801      l->m[1].data=(void *)v;
802      res->data=(void *)l;
803      res->rtyp=LIST_CMD;
804      return FALSE;
805    }
806    case 1:
807      res->data=(void *)f;
808      return f==NULL;
809  }
810  WerrorS("invalid switch");
811  return TRUE;
812}
813
814#if 0
815BOOLEAN jjIS_SQR_FREE(leftv res, leftv u)
816{
817  BOOLEAN b=singclap_factorize((poly)(u->Data()), &v, 0);
818  res->data=(void *)b;
819}
820#endif
821
822BOOLEAN jjEXTGCD_P(leftv res, leftv u, leftv v)
823{
824  res->data=singclap_extgcd((poly)u->Data(),(poly)v->Data());
825  return (res->data==NULL);
826}
827BOOLEAN jjRESULTANT(leftv res, leftv u, leftv v, leftv w)
828{
829  res->data=singclap_resultant((poly)u->Data(),(poly)v->Data(), (poly)w->Data());
830  return (res->data==NULL);
831}
832BOOLEAN jjCHARSERIES(leftv res, leftv u)
833{
834  res->data=singclap_irrCharSeries((ideal)u->Data());
835  return (res->data==NULL);
836}
837#endif
Note: See TracBrowser for help on using the repository browser.