Changeset 4f0f42 in git


Ignore:
Timestamp:
Mar 30, 2011, 6:10:59 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
cf5c053a2033583db0824a2b0459625b00d37a26
Parents:
21c6b368221deec3e5484f0c925b9ea662ef2f90
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-03-30 18:10:59+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:04:16+01:00
Message:
FIX: non-commutative interface in nc/*, main header: nc.h
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/structs.h

    r21c6b3 r4f0f42  
    9393};
    9494
    95 // #ifdef HAVE_PLURAL
    96 enum nc_type
    97 {
    98   nc_error = -1, // Something's gone wrong!
    99   nc_general = 0, /* yx=q xy+... */
    100   nc_skew, /*1*/ /* yx=q xy */
    101   nc_comm, /*2*/ /* yx= xy */
    102   nc_lie,  /*3*/ /* yx=xy+... */
    103   nc_undef, /*4*/  /* for internal reasons */
    104 
    105   nc_exterior /*5*/ // Exterior Algebra(SCA): yx= -xy & (!:) x^2 = 0
    106 };
    107 // #endif
    10895
    10996struct snumber;
  • libpolys/polys/monomials/p_polys.h

    r21c6b3 r4f0f42  
    1010 *  Version: $Id$
    1111 *******************************************************************/
     12/***************************************************************
     13 *  Purpose: implementation of poly procs which iter over ExpVector
     14 *  Author:  obachman (Olaf Bachmann)
     15 *  Created: 8/00
     16 *  Version: $Id$
     17 *******************************************************************/
    1218#ifndef P_POLYS_H
    1319#define P_POLYS_H
     20
     21#include <omalloc/omalloc.h>
     22#include <misc/mylimits.h>
     23#include <coeffs/coeffs.h>
    1424
    1525#include <polys/monomials/ring.h>
    1626#include <polys/monomials/monomials.h>
    1727#include <polys/monomials/polys-impl.h>
     28
     29#include <polys/templates/p_MemCmp.h>
     30#include <polys/templates/p_MemAdd.h>
     31#include <polys/templates/p_MemCopy.h>
    1832#include <polys/templates/p_Procs.h>
    19 #include <polys/templates/p_Procs.h>
     33
     34// #include <polys/monomials/p_polys.h>
     35
    2036#include <polys/sbuckets.h>
     37
     38#ifdef HAVE_PLURAL
     39#include <polys/nc/nc.h>
     40#endif
     41
    2142
    2243/***************************************************************
     
    11521173}
    11531174
    1154 /***************************************************************
    1155  *  Purpose: implementation of poly procs which iter over ExpVector
    1156  *  Author:  obachman (Olaf Bachmann)
    1157  *  Created: 8/00
    1158  *  Version: $Id$
    1159  *******************************************************************/
    1160 #include <misc/mylimits.h>
    1161 #include <polys/templates/p_MemCmp.h>
    1162 // #include <polys/structs.h>
    1163 #include <polys/monomials/ring.h>
    1164 #include <coeffs/coeffs.h>
    11651175
    11661176#if PDEBUG > 0
     
    11861196#define pDivAssume(x)   ((void)0)
    11871197
    1188 #include <omalloc/omalloc.h>
    1189 #include <coeffs/coeffs.h>
    1190 #include <polys/monomials/p_polys.h>
    1191 #include <polys/templates/p_MemAdd.h>
    1192 #include <polys/templates/p_MemCopy.h>
     1198
    11931199
    11941200/***************************************************************
  • libpolys/polys/monomials/ring.cc

    r21c6b3 r4f0f42  
    788788typedef char *             char_ptr;
    789789omBin char_ptr_bin = omGetSpecBin(sizeof(char_ptr)); // deallocation?
    790 
    791 
    792 #ifdef HAVE_PLURAL
    793 // NC pProcs:
    794 typedef poly (*mm_Mult_p_Proc_Ptr)(const poly m, poly p, const ring r);
    795 typedef poly (*mm_Mult_pp_Proc_Ptr)(const poly m, const poly p, const ring r);
    796 
    797 typedef ideal (*GB_Proc_Ptr)(const ideal F, const ideal Q, const intvec *w, const intvec *hilb, kStrategy strat);
    798 
    799 typedef poly (*SPoly_Proc_Ptr)(const poly p1, const poly p2, const ring r);
    800 typedef poly (*SPolyReduce_Proc_Ptr)(const poly p1, poly p2, const ring r);
    801 
    802 typedef void (*bucket_Proc_Ptr)(kBucket_pt b, poly p, number *c);
    803 
    804 struct nc_pProcs
    805 {
    806 public:
    807   mm_Mult_p_Proc_Ptr                    mm_Mult_p;
    808   mm_Mult_pp_Proc_Ptr                   mm_Mult_pp;
    809 
    810   bucket_Proc_Ptr                       BucketPolyRed;
    811   bucket_Proc_Ptr                       BucketPolyRed_Z;
    812 
    813   SPoly_Proc_Ptr                        SPoly;
    814   SPolyReduce_Proc_Ptr                  ReduceSPoly;
    815 
    816   GB_Proc_Ptr                           GB;
    817 //                                         GlobalGB, // BBA
    818 //                                         LocalGB;  // MORA
    819 };
    820 
    821 
    822 struct nc_struct
    823 {
    824   nc_type type;
    825   //ring basering; // the ring C,D,.. live in (commutative ring with this NC structure!)
    826 
    827   // initial data: square matrices rVar() x rVar()
    828   // logically: upper triangular!!!
    829   // TODO: eliminate this waste of memory!!!!
    830   matrix C;
    831   matrix D;
    832 
    833   // computed data:
    834   matrix *MT; // size 0.. (rVar()*rVar()-1)/2
    835   matrix COM;
    836   int *MTsize; // size 0.. (rVar()*rVar()-1)/2
    837 
    838   // IsSkewConstant indicates whethere coeffs C_ij are all equal,
    839   // effective together with nc_type=nc_skew
    840   int IsSkewConstant;
    841 
    842   private:
    843     // internal data for different implementations
    844     // if dynamic => must be deallocated in destructor (nc_rKill!)
    845     union
    846     {
    847       struct
    848       {
    849         // treat variables from iAltVarsStart till iAltVarsEnd as alternating vars.
    850         // these variables should have odd degree, though that will not be checked
    851         // iAltVarsStart, iAltVarsEnd are only used together with nc_type=nc_exterior
    852         // 1 <= iAltVarsStart <= iAltVarsEnd <= r->N
    853         unsigned int iFirstAltVar, iLastAltVar; // = 0 by default
    854 
    855         // for factors of super-commutative algebras we need
    856         // the part of general quotient ideal modulo squares!   
    857         ideal idSCAQuotient; // = NULL by default. // must be deleted in Kill!
    858       } sca;
    859     } data;
    860 
    861     CGlobalMultiplier* m_Multiplier;
    862     CFormulaPowerMultiplier* m_PowerMultiplier;
    863 
    864   public:
    865    
    866     inline nc_type& ncRingType() { return (type); };
    867     inline nc_type ncRingType() const { return (type); };
    868 
    869     inline unsigned int& FirstAltVar()
    870         { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
    871     inline unsigned int& LastAltVar ()
    872         { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
    873 
    874     inline unsigned int FirstAltVar() const
    875         { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
    876     inline unsigned int LastAltVar () const
    877         { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
    878 
    879     inline ideal& SCAQuotient()
    880         { assume(ncRingType() == nc_exterior); return (data.sca.idSCAQuotient); };
    881 
    882     inline CGlobalMultiplier* GetGlobalMultiplier() const
    883         { assume(ncRingType() != nc_exterior); return (m_Multiplier); };
    884 
    885     inline CGlobalMultiplier*& GetGlobalMultiplier()
    886         { assume(ncRingType() != nc_exterior); return (m_Multiplier); };
    887 
    888 
    889     inline CFormulaPowerMultiplier* GetFormulaPowerMultiplier() const
    890         { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); };
    891 
    892     inline CFormulaPowerMultiplier*& GetFormulaPowerMultiplier()
    893         { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); };
    894    
    895   public:
    896     nc_pProcs p_Procs; // NC procedures.
    897 
    898 };
    899 #endif
    900790
    901791
  • libpolys/polys/nc/gring.h

    r21c6b3 r4f0f42  
    5757
    5858bool nc_rCopy(ring res, const ring r, bool bSetupQuotient);
    59 
    60 // for p_Minus_mm_Mult_qq in pInline2.h
    61 poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
    62                                     const int, const poly, const ring r);
    63 
    64 // // for p_Plus_mm_Mult_qq in pInline2.h
    65 // returns p + m*q destroys p, const: q, m
    66 poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
    67                               const int, const ring r);
    6859
    6960
  • libpolys/polys/nc/nc.h

    r21c6b3 r4f0f42  
    22#define POLYS_NC_H
    33
    4 /*
     4#ifdef HAVE_PLURAL
     5
     6
    57
    68// TODO: the following is a part of ring.h... would be nice to have a
    79// clear public NC interface defined here!
    8 #ifdef HAVE_PLURAL
    9 struct nc_struct;
    10 typedef struct nc_struct   nc_struct;
     10
     11#include <polys/monomials/ring.h>
     12#include <polys/kbuckets.h>
     13
     14
     15class ip_smatrix;
     16typedef ip_smatrix *       matrix;
     17
     18class skStrategy;
     19typedef skStrategy * kStrategy;
     20
     21
     22
     23enum nc_type
     24{
     25  nc_error = -1, // Something's gone wrong!
     26  nc_general = 0, /* yx=q xy+... */
     27  nc_skew, /*1*/ /* yx=q xy */
     28  nc_comm, /*2*/ /* yx= xy */
     29  nc_lie,  /*3*/ /* yx=xy+... */
     30  nc_undef, /*4*/  /* for internal reasons */
     31
     32  nc_exterior /*5*/ // Exterior Algebra(SCA): yx= -xy & (!:) x^2 = 0
     33};
     34
     35
     36// //////////////////////////////////////////////////////
     37
     38// NC pProcs:
     39typedef poly (*mm_Mult_p_Proc_Ptr)(const poly m, poly p, const ring r);
     40typedef poly (*mm_Mult_pp_Proc_Ptr)(const poly m, const poly p, const ring r);
     41
     42
     43
     44typedef ideal (*GB_Proc_Ptr)(const ideal F, const ideal Q, const intvec *w, const intvec *hilb, kStrategy strat, const ring r);
     45
     46typedef poly (*SPoly_Proc_Ptr)(const poly p1, const poly p2, const ring r);
     47typedef poly (*SPolyReduce_Proc_Ptr)(const poly p1, poly p2, const ring r);
     48
     49typedef void (*bucket_Proc_Ptr)(kBucket_pt b, poly p, number *c);
     50
     51struct nc_pProcs
     52{
     53public:
     54  mm_Mult_p_Proc_Ptr                    mm_Mult_p;
     55  mm_Mult_pp_Proc_Ptr                   mm_Mult_pp;
     56
     57  bucket_Proc_Ptr                       BucketPolyRed;
     58  bucket_Proc_Ptr                       BucketPolyRed_Z;
     59
     60  SPoly_Proc_Ptr                        SPoly;
     61  SPolyReduce_Proc_Ptr                  ReduceSPoly;
     62
     63  GB_Proc_Ptr                           GB;
     64//                                         GlobalGB, // BBA
     65//                                         LocalGB;  // MORA
     66};
     67
     68struct nc_struct
     69{
     70  nc_type type;
     71  //ring basering; // the ring C,D,.. live in (commutative ring with this NC structure!)
     72
     73  // initial data: square matrices rVar() x rVar()
     74  // logically: upper triangular!!!
     75  // TODO: eliminate this waste of memory!!!!
     76  matrix C;
     77  matrix D;
     78
     79  // computed data:
     80  matrix *MT; // size 0.. (rVar()*rVar()-1)/2
     81  matrix COM;
     82  int *MTsize; // size 0.. (rVar()*rVar()-1)/2
     83
     84  // IsSkewConstant indicates whethere coeffs C_ij are all equal,
     85  // effective together with nc_type=nc_skew
     86  int IsSkewConstant;
     87
     88  private:
     89    // internal data for different implementations
     90    // if dynamic => must be deallocated in destructor (nc_rKill!)
     91    union
     92    {
     93      struct
     94      {
     95        // treat variables from iAltVarsStart till iAltVarsEnd as alternating vars.
     96        // these variables should have odd degree, though that will not be checked
     97        // iAltVarsStart, iAltVarsEnd are only used together with nc_type=nc_exterior
     98        // 1 <= iAltVarsStart <= iAltVarsEnd <= r->N
     99        unsigned int iFirstAltVar, iLastAltVar; // = 0 by default
     100
     101        // for factors of super-commutative algebras we need
     102        // the part of general quotient ideal modulo squares!   
     103        ideal idSCAQuotient; // = NULL by default. // must be deleted in Kill!
     104      } sca;
     105    } data;
     106
     107  public:
     108   
     109    inline nc_type& ncRingType() { return (type); };
     110    inline nc_type ncRingType() const { return (type); };
     111
     112    inline unsigned int& FirstAltVar()
     113        { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
     114    inline unsigned int& LastAltVar ()
     115        { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
     116
     117    inline unsigned int FirstAltVar() const
     118        { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
     119    inline unsigned int LastAltVar () const
     120        { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
     121
     122    inline ideal& SCAQuotient()
     123        { assume(ncRingType() == nc_exterior); return (data.sca.idSCAQuotient); };
     124/*
     125  private:
     126
     127   CGlobalMultiplier* m_Multiplier;
     128    CFormulaPowerMultiplier* m_PowerMultiplier;
     129
     130  public:
     131 
     132    inline CGlobalMultiplier* GetGlobalMultiplier() const
     133        { assume(ncRingType() != nc_exterior); return (m_Multiplier); };
     134
     135    inline CGlobalMultiplier*& GetGlobalMultiplier()
     136        { assume(ncRingType() != nc_exterior); return (m_Multiplier); };
     137
     138
     139    inline CFormulaPowerMultiplier* GetFormulaPowerMultiplier() const
     140        { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); };
     141
     142    inline CFormulaPowerMultiplier*& GetFormulaPowerMultiplier()
     143        { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); };
     144*/
     145   
     146  public:
     147    nc_pProcs p_Procs; // NC procedures.
     148
     149};
     150
     151
     152
     153
     154// //////////////////////////////////////////////////////////////////////// //
     155// NC inlines
     156
     157inline nc_struct*& GetNC(ring r)
     158{
     159  return r->GetNC();
     160};
     161
     162inline nc_type& ncRingType(nc_struct* p)
     163{
     164  assume(p!=NULL);
     165  return (p->ncRingType());
     166};
     167
     168inline nc_type ncRingType(ring r) // Get
     169{
     170  if(rIsPluralRing(r))
     171    return (ncRingType(r->GetNC()));
     172  else
     173    return (nc_error);
     174};
     175
     176inline void ncRingType(ring r, nc_type t) // Set
     177{
     178  assume((r != NULL) && (r->GetNC() != NULL));
     179  ncRingType(r->GetNC()) = t;
     180};
     181
     182
     183// //////////////////////////////////////////////////////////////////////// //
     184// NC inlines
     185
     186
     187/// general NC-multiplication with destruction
     188poly _nc_p_Mult_q(poly p, poly q, const ring r);
     189
     190/// general NC-multiplication without destruction
     191poly _nc_pp_Mult_qq(const poly p, const poly q, const ring r);
     192
     193
     194
     195/// for p_Minus_mm_Mult_qq in pInline2.h
     196poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
     197                                    const int, const poly, const ring r);
     198
     199// // for p_Plus_mm_Mult_qq in pInline2.h
     200// returns p + m*q destroys p, const: q, m
     201poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
     202                              const int, const ring r);
     203
     204
     205
     206
     207// returns m*p, does neither destroy p nor m
     208inline poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
     209{
     210  assume(rIsPluralRing(r));
     211  assume(r->GetNC()->p_Procs.mm_Mult_pp!=NULL);
     212  return r->GetNC()->p_Procs.mm_Mult_pp(m, p, r);
     213//  return pp_Mult_mm( p, m, r);
     214}
     215
     216
     217// returns m*p, does destroy p, preserves m
     218inline poly nc_mm_Mult_p(const poly m, poly p, const ring r)
     219{
     220  assume(rIsPluralRing(r));
     221  assume(r->GetNC()->p_Procs.mm_Mult_p!=NULL);
     222  return r->GetNC()->p_Procs.mm_Mult_p(m, p, r);
     223//   return p_Mult_mm( p, m, r);
     224}
     225
     226inline poly nc_CreateSpoly(const poly p1, const poly p2, const ring r)
     227{
     228  assume(rIsPluralRing(r));
     229  assume(r->GetNC()->p_Procs.SPoly!=NULL);
     230  return r->GetNC()->p_Procs.SPoly(p1, p2, r);
     231}
     232
     233inline poly nc_ReduceSpoly(const poly p1, poly p2, const ring r)
     234{
     235  assume(rIsPluralRing(r));
     236  assume(r->GetNC()->p_Procs.ReduceSPoly!=NULL);
     237#ifdef PDEBUG
     238//  assume(p_LmDivisibleBy(p1, p2, r));
    11239#endif
    12 
    13 #inculde <polys/monomials/ring.h>
    14 
    15 /// we must always have this test!
    16 static inline bool rIsPluralRing(const ring r)
    17 {
    18 #ifdef HAVE_PLURAL
    19   nc_struct *n;
    20   return (r != NULL) && ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/;
    21 #else
    22   return false;
    23 #endif
    24 }
    25 
     240  return r->GetNC()->p_Procs.ReduceSPoly(p1, p2, r);
     241}
     242
     243/*
     244inline void nc_PolyReduce(poly &b, const poly p, number *c, const ring r) // nc_PolyPolyRed
     245{
     246  assume(rIsPluralRing(r));
     247//  assume(r->GetNC()->p_Procs.PolyReduce!=NULL);
     248//  r->GetNC()->p_Procs.PolyReduce(b, p, c, r);
     249}
    26250*/
     251
     252inline void nc_kBucketPolyRed(kBucket_pt b, poly p, number *c)
     253{
     254  const ring r = b->bucket_ring;
     255  assume(rIsPluralRing(r));
     256
     257//   return gnc_kBucketPolyRedNew(b, p, c);
     258
     259  assume(r->GetNC()->p_Procs.BucketPolyRed!=NULL);
     260  return r->GetNC()->p_Procs.BucketPolyRed(b, p, c);
     261}
     262
     263inline void nc_BucketPolyRed_Z(kBucket_pt b, poly p, number *c)
     264{
     265  const ring r = b->bucket_ring;
     266  assume(rIsPluralRing(r));
     267
     268//   return gnc_kBucketPolyRed_ZNew(b, p, c);
     269
     270  assume(r->GetNC()->p_Procs.BucketPolyRed_Z!=NULL);
     271  return r->GetNC()->p_Procs.BucketPolyRed_Z(b, p, c);
     272
     273}
     274
     275inline ideal nc_GB(const ideal F, const ideal Q, const intvec *w, const intvec *hilb, kStrategy strat, const ring r)
     276{
     277  assume(rIsPluralRing(r));
     278
     279  assume(r->GetNC()->p_Procs.GB!=NULL);
     280  return r->GetNC()->p_Procs.GB(F, Q, w, hilb, strat, r);
     281}
     282
     283#endif /* HAVE_PLURAL */
     284
    27285#endif /* POLYS_NC_H */
Note: See TracChangeset for help on using the changeset viewer.