source: git/Singular/mpsr_PutPoly.cc @ 91ecf18

fieker-DuValspielwiese
Last change on this file since 91ecf18 was 762407, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
config.h is for sources files only FIX: config.h should only be used by source (not from inside kernel/mod2.h!) NOTE: each source file should better include mod2.h right after config.h, while headers should better not include mod2.h.
  • Property mode set to 100644
File size: 22.1 KB
RevLine 
[f6b5f0]1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4
[341696]5/* $Id$ */
[32df82]6
[0e1846]7/***************************************************************
8 *
9 * File:       mpsr_PutPoly.cc
[a2a93c]10 * Purpose:    rotines which put polys and polynomials (i.e. ring) annotations
[0e1846]11 * Author:     Olaf Bachmann (10/95)
12 *
13 * Change History (most recent first):
14 *  o 1/97 obachman
[a9a7be]15 *    Updated routines to MP and MPP v1.1
[0e1846]16 *
17 ***************************************************************/
[762407]18#include "config.h"
[b1dfaf]19#include <kernel/mod2.h>
[0e1846]20
21#ifdef HAVE_MPSR
22
[599326]23#include <Singular/mpsr_Put.h>
24#include <Singular/mpsr_Tok.h>
[b787fb6]25//#include "kernel/longalg.h"
[b1dfaf]26#include <omalloc/omalloc.h>
[0fb34ba]27#include <polys/monomials/ring.h>
[737a68]28#include <kernel/polys.h>
[a9a7be]29//#include "ipid.h"
[0e1846]30
31#ifdef PARI_BIGINT_TEST
[599326]32#include <Singular/MP_PariBigInt.h>
[0e1846]33MP_Status_t MP_MyPutApIntPacket(MP_Link_pt link, MP_ApInt_t mp_apint,
34                                MP_NumAnnot_t num_annots)
35{
36  GEN pnum = _gmp_to_pari((mpz_ptr) mp_apint);
37  return MP_PutApIntPacket(link, (MP_ApInt_t) pnum, num_annots);
38}
39
40#else
41
42#define MP_MyPutApIntPacket MP_PutApIntPacket
43
44#endif
45
46/***************************************************************
47 *
48 * global variable definitions
49 *
50 ***************************************************************/
51
[550b4c]52static mpsr_Status_t (*PutCoeff)(MP_Link_pt link, number x);
53static mpsr_Status_t (*PutAlgAlgNumber)(MP_Link_pt link, number x);
54static MP_Uint32_t gNalgvars = 0;
55static MP_Sint32_t gNvars = 0;
56static ring        CurrPutRing = NULL;
[0e1846]57
[550b4c]58MP_Sint32_t *gTa = NULL;
59MP_Sint32_t gTa_Length = 0;
[0e1846]60
61/***************************************************************
62 *
63 * prototype declarations
64 *
65 ***************************************************************/
66static void        SetPutFuncs(ring r);
67static mpsr_Status_t PutModuloNumber(MP_Link_pt link, number a);
68static mpsr_Status_t PutFloatNumber(MP_Link_pt link, number a);
69static mpsr_Status_t PutRationalNumber(MP_Link_pt link, number a);
[a2a93c]70static mpsr_Status_t PutAlgPoly(MP_Link_pt link, napoly a, ring ar);
[0e1846]71static mpsr_Status_t PutAlgNumber(MP_Link_pt link, number a);
72
73static mpsr_Status_t PutVarNamesAnnot(MP_Link_pt link, ring r);
74static mpsr_Status_t PutVarNumberAnnot(MP_Link_pt link, ring r, BOOLEAN mv);
75static mpsr_Status_t PutOrderingAnnot(MP_Link_pt link, ring r, BOOLEAN mv);
76static mpsr_Status_t PutSimpleOrdering(MP_Link_pt link, ring r, short index);
77static mpsr_Status_t PutProtoTypeAnnot(MP_Link_pt link, ring r, BOOLEAN mv);
78static mpsr_Status_t PutMinPolyAnnot(MP_Link_pt link, ring r);
79static mpsr_Status_t PutDefRelsAnnot(MP_Link_pt link, ring r);
80
[550b4c]81
[0e1846]82/***************************************************************
83 *
84 * Setting the global Put Functions
85 *
86 ***************************************************************/
87static void SetPutFuncs(ring r)
88{
89  CurrPutRing = r;
90  // first, we set the PutNumber function
[550b4c]91  gNvars = r->N;
92  mpsr_InitTempArray(gNvars+1);
[0e1846]93
[be0d84]94  if (rField_is_Q(r))
[0e1846]95    // rational numbers
96    PutCoeff= PutRationalNumber;
[c56a23]97  else if (rField_is_Zp(r) || rField_is_GF(r))
[0e1846]98    // Form our point of view, ModuloP numbers and numbers from
99    // GF(p,n) are the same, here. They only differ in the annots
100    PutCoeff = PutModuloNumber;
[be0d84]101  else if (rField_is_R(r))
[0e1846]102    PutCoeff = PutFloatNumber;
103  else
104  {
105    // now we come to algebraic numbers
106    gNalgvars = rPar(r);
[550b4c]107    mpsr_InitTempArray(gNalgvars);
[0e1846]108    PutCoeff = PutAlgNumber;
[be0d84]109    if (rField_is_Zp_a(r))
[0e1846]110      // first, Z/p(a)
111      PutAlgAlgNumber = PutModuloNumber;
112    else
113      PutAlgAlgNumber = PutRationalNumber;
114  }
115}
116
117
118
119/***************************************************************
120 *
121 * modulo numbers (i.e. char p, or p^n)
122 *
123 ***************************************************************/
124// we always put modulo numbers without a header, since
125// we have type-spec this before
126static mpsr_Status_t PutModuloNumber(MP_Link_pt link, number a)
127{
128  mp_return(IMP_PutUint32(link, (MP_Uint32_t) a));
129}
130
131static mpsr_Status_t PutFloatNumber(MP_Link_pt link, number a)
132{
133  mp_return(IMP_PutReal32(link , Number_2_Real32(a)));
134}
135
136/***************************************************************
137 *
138 * rational (i.e. char 0) numbers
139 *
140 ***************************************************************/
141// This supposes that number is of char 0, i.e. a rational number
142static mpsr_Status_t PutRationalNumber(MP_Link_pt link, number a)
143{
144  // Check for case number == NULL == 0
145  if (a == NULL)
146    mp_return( MP_PutSint32Packet(link, 0, 0));
[a9a7be]147
[0e1846]148  // check for SR_INT type
149  if (SR_HDL(a) & SR_INT)
150    mp_return( MP_PutSint32Packet(link, SR_TO_INT(a), 0));
151
152  // check for single GMP integer
153  if ((a->s) == 3)
154    mp_return(MP_MyPutApIntPacket(link, (MP_ApInt_t) &(a->z), 0));
155
156  // Now we have a fraction
157  // normalize, if necessary
[eea2b0]158//   if ((a->s) == 0)
159//   {
160// //    nlNormalize(a);
161//     return PutRationalNumber(link, a);
162//   }
[a9a7be]163
[0e1846]164  // send number itself
165  mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]166                                      MP_BasicDict,
167                                      MP_CopBasicDiv,
168                                      0,
169                                      2));
170  // and now sent nominator and denominator
[0e1846]171  mp_failr(MP_MyPutApIntPacket(link, (MP_ApInt_t) &(a->z), 0));
172  mp_return(MP_MyPutApIntPacket(link, (MP_ApInt_t) &(a->n), 0));
173}
174
175/***************************************************************
176 *
177 * Algebraic Numbers (a la Singular)
178 *
179 ***************************************************************/
[40ef69]180static inline MP_Uint32_t GetPlength(napoly a)
[0e1846]181{
[85e36d]182  MP_Uint32_t i = napLength(a);
[0e1846]183  return i;
184}
185
186static mpsr_Status_t PutAlgNumber(MP_Link_pt link, number a)
187{
188  lnumber b;
189
190  if (a == NULL)
191    mp_return(IMP_PutUint32(link, 0));
192
193  b = (lnumber) a;
194  if ((b->n) == NULL) // NULL means there is only one number
195  {
196    // hence, we use the first case of the union
197    mp_failr(IMP_PutUint32(link, 1));
198    mp_failr(IMP_PutUint32(link, GetPlength(b->z)));
[6ccdd3a]199    return PutAlgPoly(link, b->z, CurrPutRing->extRing);
[0e1846]200  }
201  else
202  {
203    // we use the 2nd case of the union
204    mp_failr(IMP_PutUint32(link, 2));
205    mp_failr(IMP_PutUint32(link, GetPlength(b->z)));
[6ccdd3a]206    failr(PutAlgPoly(link, b->z, CurrPutRing->extRing));
[0e1846]207    mp_failr(IMP_PutUint32(link, GetPlength(b->n)));
[6ccdd3a]208    return PutAlgPoly(link, b->n, CurrPutRing->extRing);
[0e1846]209  }
210}
211
212// this is very similar to putting a Poly
[a2a93c]213static mpsr_Status_t PutAlgPoly(MP_Link_pt link, napoly a, ring ar)
[0e1846]214{
[550b4c]215  unsigned int i;
[0e1846]216  int *exp;
217
218  if (gNalgvars > 1)
219    while (a != NULL)
220    {
[85e36d]221      failr(PutAlgAlgNumber(link, napGetCoeff(a)));
[550b4c]222      for (i=0; i<gNalgvars; i++)
[a2a93c]223        gTa[i] = p_GetExp((poly)a,i+1,ar);
[550b4c]224      mp_failr(IMP_PutSint32Vector(link, gTa, gNalgvars));
[1629ab]225      pIter(a);
[0e1846]226    }
227  else
228  {
229    while (a != NULL)
230    {
[85e36d]231      failr(PutAlgAlgNumber(link, napGetCoeff(a)));
[a2a93c]232      IMP_PutSint32(link, (MP_Sint32_t) p_GetExp((poly)a,1,ar));
[1629ab]233      pIter(a);
[0e1846]234    }
235  }
236  return mpsr_Success;
237}
238
239/***************************************************************
240 *
241 *  Putting polys
242 *
243 ***************************************************************/
244mpsr_Status_t mpsr_PutPolyData(MP_Link_pt link, poly p, ring cring)
245{
[9c6003]246  //if (cring != CurrPutRing)
[feaddd]247    SetPutFuncs(cring);
[0e1846]248
249#ifdef MPSR_DEBUG
250  if (currRing == cring)
251    pTest(p);
252#endif
[a9a7be]253
[0e1846]254  if (gNvars > 1)
255  {
256    short i;
257    MP_Sint32_t *ta1 = &(gTa[1]);
[a9a7be]258
[0e1846]259    while (p != NULL)
260    {
261      failr(PutCoeff(link, pGetCoeff(p)));
[427ba9]262      for (i=1; i<=gNvars; i++)
263        gTa[i] = (MP_Sint32_t) pGetExp(p, i);
[0e1846]264      mp_failr(IMP_PutSint32Vector(link, ta1, gNvars));
265      pIter(p);
266    }
267  }
268  else
269    while (p != NULL)
270    {
271      failr(PutCoeff(link, pGetCoeff(p)));
[51c163]272      IMP_PutSint32(link, (MP_Sint32_t) pGetExp(p,1));
[0e1846]273      pIter(p);
274    }
275  return mpsr_Success;
276}
277
278mpsr_Status_t mpsr_PutPolyVectorData(MP_Link_pt link, poly p, ring cring)
279{
280  short i, n1;
281
282  if (cring != CurrPutRing)
283    SetPutFuncs(cring);
[a9a7be]284
[0e1846]285  if (gNvars > 1)
286  {
287    short i, n1= gNvars + 1;
288    while (p != NULL)
289    {
290      failr(PutCoeff(link, pGetCoeff(p)));
[427ba9]291      gTa[0] = pGetComp(p);
292      for (i=1; i< n1; i++)
293        gTa[i] = (MP_Sint32_t) pGetExp(p,i);
[0e1846]294      mp_failr(IMP_PutSint32Vector(link, gTa, n1));
295      pIter(p);
296    }
297  }
298  else
299    while (p != NULL)
300    {
301      failr(PutCoeff(link, pGetCoeff(p)));
[51c163]302      IMP_PutSint32(link, (MP_Sint32_t) pGetComp(p));
303      IMP_PutSint32(link, (MP_Sint32_t) pGetExp(p,1));
[0e1846]304      pIter(p);
305    }
306  return mpsr_Success;
307}
308
309/***************************************************************
310 *
311 *  The putting annotation buisness
312 *
313 ***************************************************************/
314int mpsr_GetNumOfRingAnnots(ring r, BOOLEAN mv)
315{
316  short annots = 4;
317
318  if (mv) annots++;
319  if (r->qideal != NULL) annots++;
320  // we sent the minpoly with the coefficient ring
[20a351]321  if ((r->minpoly != NULL) && (r->parameter == NULL)) annots++;
[0e1846]322
323  return annots;
324}
325
326mpsr_Status_t mpsr_PutRingAnnots(MP_Link_pt link, ring r, BOOLEAN mv)
327{
328  failr(PutProtoTypeAnnot(link,r, mv));
329  failr(PutVarNumberAnnot(link, r, mv));
330  failr(PutVarNamesAnnot(link,r));
331  failr(PutOrderingAnnot(link,r, mv));
332
333  if (mv)
334    mp_failr(MP_PutAnnotationPacket(link,
[feaddd]335                                    MP_PolyDict,
336                                    MP_AnnotPolyModuleVector,
337                                    MP_AnnotRequired));
[0e1846]338  // Hmm .. this is not according to a "proper" Singular ring,
339  // but to be used in a recursive call of mpsr_PutRingAnnots
[c56a23]340  if (r->minpoly != NULL && r->parameter == NULL && r->ch > 0)
[0e1846]341    failr(PutMinPolyAnnot(link,r));
[a9a7be]342
[0e1846]343  if (r->qideal != NULL)
344    return PutDefRelsAnnot(link, r);
345
346  return mpsr_Success;
347}
348
349static mpsr_Status_t PutProtoTypeAnnot(MP_Link_pt link, ring r,
[feaddd]350                                       BOOLEAN mv)
[0e1846]351{
[a9a7be]352  // each element of the poly is a
[0e1846]353  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]354                                  MP_ProtoDict,
355                                  MP_AnnotProtoPrototype,
356                                  MP_AnnotReqValNode));
[0e1846]357  // Monom represented as a struct of 2 elements
358  mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]359                                      MP_ProtoDict,
360                                      MP_CopProtoStruct,
361                                      0,
362                                      2));
[0e1846]363
364  // First element is the coefficient
[be0d84]365  if (rField_is_Q(r))
[0e1846]366  {
367    // rational numbers
[feaddd]368    mp_failr(MP_PutCommonMetaTypePacket(link,
369                                        MP_NumberDict,
[a492d2]370                                        MP_CmtNumberRational,
[feaddd]371                                        1));
[0e1846]372    // are always normalized (and made that way, if necessary)
373    mp_failr(MP_PutAnnotationPacket(link,
[feaddd]374                                    MP_NumberDict,
375                                    MP_AnnotNumberIsNormalized,
376                                    0));
[0e1846]377  }
[c56a23]378  else if (rField_is_Zp(r) || rField_is_GF(r))
[0e1846]379  {
380    // modulo p numbers
381    // are communicated as IMP_Uint32's
[feaddd]382    mp_failr(MP_PutCommonMetaTypePacket(link,
383                                    MP_ProtoDict,
384                                    MP_CmtProtoIMP_Uint32,
385                                    1));
[a9a7be]386    // but are taken as modulo numbers
[0e1846]387    mp_failr(MP_PutAnnotationPacket(link,
[feaddd]388                                    MP_NumberDict,
389                                    MP_AnnotNumberModulos,
390                                    MP_AnnotValuated));
[0e1846]391    // with Modulo
[c56a23]392    mp_failr(MP_PutUint32Packet(link, rInternalChar(r), 1));
[0e1846]393    if (r->parameter == NULL)
394    {
395      // which is (in our case) always a prime number
396      mp_failr(MP_PutAnnotationPacket(link,
[feaddd]397                                      MP_NumberDict,
398                                      MP_AnnotNumberIsPrime,
399                                      0));
[0e1846]400    }
401    else
402    {
403      mp_failr(MP_PutAnnotationPacket(link,
[feaddd]404                                      MP_SingularDict,
405                                      MP_AnnotSingularGalois,
406                                      MP_AnnotValuated));
[0e1846]407      mp_failr(MP_PutStringPacket(link, r->parameter[0], 0));
408    }
409  }
[be0d84]410  else if (rField_is_R(r))
[0e1846]411  {
[a9a7be]412    // floats
[feaddd]413    mp_failr(MP_PutCommonMetaTypePacket(link,
414                                    MP_ProtoDict,
415                                    MP_CmtProtoIMP_Real32,
416                                    0));
[0e1846]417  }
418  else
419  {
420    // alg numbers
421    // create temporary ring for describing the coeeficient domain
[6ccdd3a]422    ring alg_r = r->extRing;
[0e1846]423    alg_r->minpoly = r->minpoly;
424
[a9a7be]425    // Algebraic numbers are
[0e1846]426    // a fraction of two Dense Dist Polys
[5615cd9]427    mp_failr(MP_PutCommonMetaOperatorPacket(link,
428                                            MP_BasicDict,
429                                            MP_CopBasicDiv,
430                                            1,
431                                            0));
432    mp_failr(MP_PutAnnotationPacket(link,
433                                    MP_ProtoDict,
434                                    MP_AnnotProtoPrototype,
435                                    MP_AnnotReqValNode));
[0e1846]436    mp_failr(MP_PutCommonMetaOperatorPacket(link,
[feaddd]437                                            MP_PolyDict,
[5615cd9]438                                            MP_CopPolyDenseDistPoly,
439                                            mpsr_GetNumOfRingAnnots(alg_r, 0),
[feaddd]440                                            0));
[0e1846]441    failr(mpsr_PutRingAnnots(link, alg_r, 0));
442
443    // destroy temporary ring
[a2a93c]444    alg_r->minpoly = NULL;
[0e1846]445  }
446
447  // second element is the exponent vector
448  mp_failr(MP_PutCommonMetaOperatorPacket(link,
[feaddd]449                                          MP_ProtoDict,
450                                          MP_CopProtoArray,
451                                          1,
452                                          (mv ? r->N + 1 : r->N)));
[0e1846]453  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]454                                  MP_ProtoDict,
455                                  MP_AnnotProtoPrototype,
456                                  MP_AnnotReqValNode));
457  mp_return(MP_PutCommonMetaTypePacket(link,
458                                   MP_ProtoDict,
459                                   MP_CmtProtoIMP_Sint32,
460                                   0));
[0e1846]461}
462
[a9a7be]463
[0e1846]464static mpsr_Status_t PutVarNamesAnnot(MP_Link_pt link, ring r)
465{
466  // first, we put the annot packet, with flags (1, 0, 1, 0)
467  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]468                                  MP_PolyDict,
469                                  MP_AnnotPolyVarNames,
470                                  MP_AnnotValuated));
[0e1846]471  // now, the varnames follow
472  if ((r->N) == 1)
473  {
474    // only 1 varname
[feaddd]475    mp_return(MP_PutIdentifierPacket(link, MP_SingularDict, *(r->names), 0));
[0e1846]476  }
477  else
478  {
479    // more than one varname
480    char **names = r->names;
481    int i, n = r->N;
482
483    mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]484                                        MP_ProtoDict,
485                                        MP_CopProtoArray,
486                                        1,
487                                        r->N));
[0e1846]488    mp_failr(MP_PutAnnotationPacket(link,
[feaddd]489                                    MP_ProtoDict,
490                                    MP_AnnotProtoPrototype,
491                                    MP_AnnotReqValNode));
[a9a7be]492
[feaddd]493    mp_failr(MP_PutCommonMetaTypePacket(link,
494                                    MP_ProtoDict,
495                                    MP_CmtProtoIMP_Identifier,
496                                    0));
[0e1846]497    for (i=0; i<n; i++)
498      mp_failr(IMP_PutString(link, names[i]));
499
500    return mpsr_Success;
501  }
502}
503
504static mpsr_Status_t PutVarNumberAnnot(MP_Link_pt link, ring r, BOOLEAN mv)
505{
506  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]507                                  MP_PolyDict,
508                                  MP_AnnotPolyVarNumber,
509                                  MP_AnnotValuated));
[0e1846]510  mp_return(MP_PutUint32Packet(link, (mv ? r->N + 1 : r->N), 0));
511}
512
[a9a7be]513
[0e1846]514static mpsr_Status_t PutOrderingAnnot(MP_Link_pt link, ring r, BOOLEAN mv)
515{
516  int index = 0, nblocks = 0;
517  int *order = r->order;
518
519  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]520                                  MP_PolyDict,
521                                  MP_AnnotPolyOrdering,
522                                  MP_AnnotValuated));
[0e1846]523
524  // let's see whether we have a simple ordering to sent
[a2a93c]525  if ((mv == 0) && (order[1] == ringorder_no))
526  {
527    // ring does not contain a component entry:
528    return PutSimpleOrdering(link, r, 0);
529  }
[0e1846]530  if ((mv == 0) && (order[2] == ringorder_no))
531  {
532    if (order[1] == ringorder_C || order[1] == ringorder_c)
533      index = 0;
534    else
535      index = 1;
536
537    return PutSimpleOrdering(link, r, index);
538  }
539
540  // No -- so we are dealing with a product ordering
541  // First, let's find out how many blocks there are
542  while (order[nblocks] != ringorder_no) nblocks++;
543  // if we deal with a non-vector, we are not going to sent
544  // the vector ordering
545  mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]546                                      MP_BasicDict,
547                                      MP_CopBasicList,
548                                      0,
549                                      (mv ? nblocks : nblocks - 1)));
[0e1846]550
551  for (index = 0; index < nblocks; index ++)
552    // Do not sent vector ordering, if we are sending pure polys
553    if (! (mv == 0 && (order[index] == ringorder_C ||
554                       order[index] == ringorder_c)))
555    {
[a9a7be]556      // a product ordering is sent as triple
[0e1846]557      mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]558                                          MP_BasicDict,
559                                          MP_CopBasicList,
560                                          0,
561                                          3));
[0e1846]562      // first element is the simple ordering
563      failr(PutSimpleOrdering(link, r, index));
564      // second and third for covered variables
565      mp_failr(MP_PutUint32Packet(link, (MP_Uint32_t) r->block0[index], 0));
566      mp_failr(MP_PutUint32Packet(link, (MP_Uint32_t) r->block1[index], 0));
567    }
568
569  return mpsr_Success;
570}
571
572
573static mpsr_Status_t PutSimpleOrdering(MP_Link_pt link, ring r, short index)
574{
575  MP_Uint32_t vlength = 0, i;
576
577  // find out the length of the weight-vector
[cc0296]578  if (r->wvhdl && r->wvhdl[index] != NULL)
[0e1846]579    vlength = r->block1[index] - r->block0[index] + 1;
580
581  mp_failr(MP_PutCommonConstantPacket(link,
[feaddd]582                                      MP_PolyDict,
583                                      mpsr_ord2mp(r->order[index]),
584                                      (vlength == 0 ? 0 : 1)));
[0e1846]585
586  if (vlength == 0) return mpsr_Success;
587
[a9a7be]588  // deal with the weights
[0e1846]589  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]590                                  MP_PolyDict,
591                                  MP_AnnotPolyWeights,
592                                  MP_AnnotValuated));
[0e1846]593  if (r->order[index] == ringorder_M)
594  {
595    // put the matrix header
596    mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]597                                        MP_MatrixDict,
598                                        MP_CopMatrixDenseMatrix,
599                                        2,
600                                        vlength*vlength));
[0e1846]601    mp_failr(MP_PutAnnotationPacket(link,
[feaddd]602                                    MP_ProtoDict,
603                                    MP_AnnotProtoPrototype,
604                                    MP_AnnotReqValNode));
605    mp_failr(MP_PutCommonMetaTypePacket(link,
606                                    MP_ProtoDict,
607                                    MP_CmtProtoIMP_Sint32,
608                                    0));
[0e1846]609    mp_failr(MP_PutAnnotationPacket(link,
[feaddd]610                                    MP_MatrixDict,
611                                    MP_AnnotMatrixDimension,
612                                    MP_AnnotReqValNode));
[0e1846]613    mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]614                                        MP_BasicDict,
615                                        MP_CopBasicList,
616                                        0, 2));
[82dbf50]617    mp_failr(MP_PutSint32Packet(link, (MP_Sint32_t) vlength, 0));
618    mp_failr(MP_PutSint32Packet(link, (MP_Sint32_t) vlength, 0));
[0e1846]619    vlength *= vlength;
620  }
621  else
622  {
623    // vector header
624    mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]625                                        MP_MatrixDict,
626                                        MP_CopMatrixDenseVector,
627                                        1,
628                                        vlength));
[0e1846]629    mp_failr(MP_PutAnnotationPacket(link,
[feaddd]630                                    MP_ProtoDict,
631                                    MP_AnnotProtoPrototype,
632                                    MP_AnnotReqValNode));
633    mp_failr(MP_PutCommonMetaTypePacket(link,
634                                    MP_ProtoDict,
635                                    MP_CmtProtoIMP_Sint32,
636                                    0));
[0e1846]637  }
638
[a9a7be]639  // weights are all what remains
[0e1846]640  for (i=0; i<vlength; i++)
641    mp_failr(IMP_PutSint32(link, (MP_Sint32_t) r->wvhdl[index][i]));
642
643  return mpsr_Success;
644}
645
646static mpsr_Status_t PutMinPolyAnnot(MP_Link_pt link, ring r)
647{
648  mpsr_assume(r->minpoly != NULL && r->ch > 0 && r->parameter == NULL);
[a9a7be]649
[0e1846]650  number minpoly = r->minpoly;
651  r->minpoly = 0;
652
653  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]654                                  MP_PolyDict,
655                                  MP_AnnotPolyDefRel,
656                                  MP_AnnotValuated));
[0e1846]657  mp_failr(MP_PutCommonOperatorPacket(link,
[feaddd]658                                      MP_PolyDict,
659                                      MP_CopPolyDenseDistPoly,
660                                      5,
661                                      GetPlength( ((lnumber) minpoly)->z)));
[0e1846]662  failr(PutProtoTypeAnnot(link, r, 0));
663  failr(PutVarNamesAnnot(link, r));
664  failr(PutVarNumberAnnot(link, r,0));
665  failr(PutOrderingAnnot(link, r, 0));
666  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]667                                  MP_PolyDict,
668                                  MP_AnnotPolyIrreducible,
669                                  0));
[0e1846]670
671  // need to set PutAlgAlgnumber and gNalgVars
672  CurrPutRing = r;
[c56a23]673  if (rField_is_Zp(r) || rField_is_GF(r))
[0e1846]674    PutAlgAlgNumber = PutModuloNumber;
675  else
676    PutAlgAlgNumber = PutRationalNumber;
677  gNalgvars = r->N;
[a9a7be]678
[0e1846]679  r->minpoly = minpoly;
[a2a93c]680  return PutAlgPoly(link, ((lnumber) minpoly)->z, r);
[0e1846]681}
682
[a9a7be]683
[0e1846]684static mpsr_Status_t PutDefRelsAnnot(MP_Link_pt link, ring r)
685{
686  int i, idn;
687  ideal id;
688
689  id = r->qideal;
690  r->qideal = NULL;
691
692  mp_failr(MP_PutAnnotationPacket(link,
[feaddd]693                                  MP_PolyDict,
694                                  MP_AnnotPolyDefRel,
695                                  MP_AnnotValuated));
[0e1846]696  failr(mpsr_PutIdeal(link, id, r));
697  r->qideal = id;
698  return mpsr_Success;
699}
700
701#endif
Note: See TracBrowser for help on using the repository browser.