Loading...
Searching...
No Matches
p_Procs_Set.h
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/***************************************************************
* File: p_Procs_Set.h
* Purpose: Procedures for setting p_Procs at run time
* Note: this file is included by p_Procs_Dynamic/Static.cc
* The macros
* DoSetProc(what, field, length, ord)
* InitSetProc(field, length ord)
* have to be defined before this file is included
* Author: obachman (Olaf Bachmann)
* Created: 12/00
*******************************************************************/
#include "reporter/reporter.h"
#include "misc/auxiliary.h"
#ifdef HAVE_SHIFTBBA
#include "shiftop.h"
#endif
// extract p_Procs properties from a ring
static inline p_Field p_FieldIs(ring r)
{
if (rField_is_Zp(r))
return FieldZp;
if (rField_is_R(r)) return FieldR;
if (rField_is_GF(r)) return FieldGF;
if (rField_is_Q(r)) return FieldQ;
#ifdef HAVE_MORE_FIELDS_IMPLEMENTED
if (rField_is_long_R(r)) return FieldLong_R;
if (rField_is_long_C(r)) return FieldLong_C;
if (rField_is_Zp_a(r)) return FieldZp_a;
if (rField_is_Q_a(r)) return FieldQ_a;
#endif
if (rField_is_Ring(r)) return RingGeneral;
return FieldGeneral;
}
static inline p_Length p_LengthIs(ring r)
{
assume(r->ExpL_Size > 0);
// here is a quick hack to take care of p_MemAddAdjust
if (r->NegWeightL_Offset != NULL) return LengthGeneral;
if (r->ExpL_Size == 1) return LengthOne;
if (r->ExpL_Size == 2) return LengthTwo;
if (r->ExpL_Size == 3) return LengthThree;
if (r->ExpL_Size == 4) return LengthFour;
if (r->ExpL_Size == 5) return LengthFive;
if (r->ExpL_Size == 6) return LengthSix;
if (r->ExpL_Size == 7) return LengthSeven;
if (r->ExpL_Size == 8) return LengthEight;
return LengthGeneral;
}
static inline int p_IsNomog(long* sgn, int l)
{
int i;
for (i=0;i<l;i++)
if (sgn[i] > 0) return 0;
return 1;
}
static inline int p_IsPomog(long* sgn, int l)
{
int i;
for (i=0;i<l;i++)
if (sgn[i] < 0) return 0;
return 1;
}
static inline p_Ord p_OrdIs(ring r)
{
long* sgn = r->ordsgn;
long l = r->ExpL_Size;
int zero = 0;
if (sgn[l-1] == 0)
{
l--;
zero = 1;
}
// we always favour the pomog cases
if (p_IsPomog(sgn,l)) return (zero ? OrdPomogZero : OrdPomog);
if (p_IsNomog(sgn,l)) return (zero ? OrdNomogZero : OrdNomog);
assume(l > 1);
if (sgn[0] == -1 && p_IsPomog(&sgn[1], l-1))
return (zero ? OrdNegPomogZero : OrdNegPomog);
if (sgn[l-1] == -1 && p_IsPomog(sgn, l-1))
return (zero ? OrdPomogNegZero : OrdPomogNeg);
if (sgn[0] == 1 && p_IsNomog(&sgn[1], l-1))
return (zero ? OrdPosNomogZero : OrdPosNomog);
if (sgn[l-1] == 1 && p_IsNomog(sgn, l-1))
return (zero ? OrdNomogPosZero : OrdNomogPos);
assume(l > 2);
if (sgn[0] == 1 && sgn[1] == 1 && p_IsNomog(&sgn[2], l-2))
return (zero ? OrdPosPosNomogZero : OrdPosPosNomog);
if (sgn[0] == 1 && sgn[l-1] == 1 && p_IsNomog(&sgn[1], l-2))
return (zero ? OrdPosNomogPosZero : OrdPosNomogPos);
if (sgn[0] == -1 && sgn[1] == 1 && p_IsNomog(&sgn[2], l-2))
return (zero ? OrdNegPosNomogZero : OrdNegPosNomog);
return OrdGeneral;
}
// fields of this struct are set by DoSetProc
STATIC_VAR p_Procs_s *_p_procs;
#ifdef RDEBUG
// if set, then SetProcs sets only names, instead of functions
STATIC_VAR int set_names = 0;
#endif
// (which##_Proc_Ptr)F ->-> cast_vptr_to_A<which##_Proc_Ptr>(F)?
#define CheckProc(which) \
do \
{ \
if (p_Procs->which == NULL) \
{ \
dReportBug("p_Procs is NULL"); \
WarnS("Singular will work properly, but much slower"); \
WarnS("If you chose a coef ring, it may not work at all");\
p_Procs->which = (which##_Proc_Ptr)( \
which##__FieldGeneral_LengthGeneral_OrdGeneral); \
} \
} \
while (0);
void nc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs);
// Choose a set of p_Procs
void p_ProcsSet(ring r, p_Procs_s* p_Procs)
{
p_Field field = p_FieldIs(r);
p_Length length = p_LengthIs(r);
p_Ord ord = p_OrdIs(r);
assume(p_Procs != NULL);
memset(p_Procs, 0, sizeof(p_Procs_s));
_p_procs = p_Procs;
SetProcs(field, length, ord);
extern poly p_Mult_nn_pthread(poly p, const number n, const ring r);
#ifdef NV_OPS
if ((field==FieldZp) && (r->cf->ch>NV_MAX_PRIME))
{
// set all (mult/div.) routines to FieldGeneral-variants
SetProcs(FieldGeneral, length,ord); // p_Mult_nn, ...
// set all non-mult/div. routines to FieldZp-variants
SetProcs_nv(FieldZp, length,ord); // p_Delete, p_ShallowCopyDelete...
}
if (field==RingGeneral)
{
if (nCoeff_is_Domain(r->cf))
SetProcs_ring(FieldGeneral,length,ord);
// FieldGeneral vs. RingGeneral: HAVE_ZERODIVISORS
else
SetProcs_ring(RingGeneral,length,ord);
}
#endif
CheckProc(p_Copy);
CheckProc(p_Delete);
CheckProc(p_ShallowCopyDelete);
CheckProc(p_Mult_nn);
CheckProc(pp_Mult_nn);
CheckProc(pp_Mult_mm);
CheckProc(p_Mult_mm);
CheckProc(p_Minus_mm_Mult_qq);
CheckProc(pp_Mult_mm_Noether);
CheckProc(p_Add_q);
CheckProc(p_Neg);
CheckProc(pp_Mult_Coeff_mm_DivSelect);
CheckProc(pp_Mult_Coeff_mm_DivSelectMult);
CheckProc(p_Merge_q);
CheckProc(p_kBucketSetLm);
/*
assume(p_Procs->pp_Mult_mm_Noether != pp_Mult_mm_Noether__FieldGeneral_LengthGeneral_OrdGeneral ||
p_Procs->p_Minus_mm_Mult_qq == p_Minus_mm_Mult_qq__FieldGeneral_LengthGeneral_OrdGeneral ||
r->OrdSgn == 1 || r->LexOrder);
*/
{
_p_procs->p_mm_Mult=_p_procs->p_Mult_mm;
_p_procs->pp_mm_Mult=_p_procs->pp_Mult_mm;
}
#ifdef HAVE_PLURAL
#ifndef SING_NDEBUG
if (rIsPluralRing(r))
{
dReportError("Setting pProcs in p_ProcsSet (rDebugPrint!?)!!!");
nc_p_ProcsSet(r, _p_procs); // Setup non-commutative p_Procs table!
}
#endif
#endif
#ifdef HAVE_SHIFTBBA
if (r->isLPring)
{
_p_procs->pp_Mult_mm = shift_pp_Mult_mm;
_p_procs->p_Mult_mm = shift_p_Mult_mm;
_p_procs->p_mm_Mult = shift_p_mm_Mult;
_p_procs->pp_mm_Mult = shift_pp_mm_Mult;
_p_procs->p_Minus_mm_Mult_qq = shift_p_Minus_mm_Mult_qq;
// Unsupported procs:
_p_procs->pp_Mult_mm_Noether = shift_pp_Mult_mm_Noether_STUB;
_p_procs->pp_Mult_Coeff_mm_DivSelect = shift_pp_Mult_Coeff_mm_DivSelect_STUB;
_p_procs->pp_Mult_Coeff_mm_DivSelectMult = shift_pp_Mult_Coeff_mm_DivSelectMult_STUB;
}
#endif
}
#ifdef RDEBUG
void p_Debug_GetSpecNames(const ring r, const char* &field, const char* &length, const char* &ord)
{
/*p_Field e_field =*/ (void) p_FieldIs(r);
/*p_Length e_length =*/ (void) p_LengthIs(r);
/*p_Ord e_ord =*/ (void) p_OrdIs(r);
field = p_FieldEnum_2_String(p_FieldIs(r));
length = p_LengthEnum_2_String(p_LengthIs(r));
ord = p_OrdEnum_2_String(p_OrdIs(r));
}
void p_Debug_GetProcNames(const ring r, p_Procs_s* p_Procs)
{
set_names = 1;
p_ProcsSet(r, p_Procs); // changes p_Procs!!!
set_names = 0;
}
#endif // RDEBUG
sgn
int sgn(const Rational &a)
Definition GMPrat.cc:430
auxiliary.h
All the auxiliary stuff.
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
nCoeff_is_Domain
static FORCE_INLINE BOOLEAN nCoeff_is_Domain(const coeffs r)
returns TRUE, if r is a field or r has no zero divisors (i.e is a domain)
Definition coeffs.h:736
STATIC_VAR
#define STATIC_VAR
Definition globaldefs.h:7
length
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
assume
#define assume(x)
Definition mod2.h:389
dReportError
int dReportError(const char *fmt,...)
Definition dError.cc:44
NV_MAX_PRIME
#define NV_MAX_PRIME
Definition modulop.h:37
NULL
#define NULL
Definition omList.c:12
p_Length
p_Length
Definition p_Procs_Impl.h:123
LengthFive
@ LengthFive
Definition p_Procs_Impl.h:128
LengthFour
@ LengthFour
Definition p_Procs_Impl.h:129
LengthThree
@ LengthThree
Definition p_Procs_Impl.h:130
LengthEight
@ LengthEight
Definition p_Procs_Impl.h:125
LengthSix
@ LengthSix
Definition p_Procs_Impl.h:127
LengthGeneral
@ LengthGeneral
Definition p_Procs_Impl.h:124
LengthOne
@ LengthOne
Definition p_Procs_Impl.h:132
LengthSeven
@ LengthSeven
Definition p_Procs_Impl.h:126
LengthTwo
@ LengthTwo
Definition p_Procs_Impl.h:131
p_Field
p_Field
Definition p_Procs_Impl.h:107
FieldQ
@ FieldQ
Definition p_Procs_Impl.h:110
FieldZp
@ FieldZp
Definition p_Procs_Impl.h:109
RingGeneral
@ RingGeneral
Definition p_Procs_Impl.h:119
FieldZp_a
@ FieldZp_a
Definition p_Procs_Impl.h:116
FieldQ_a
@ FieldQ_a
Definition p_Procs_Impl.h:117
FieldLong_R
@ FieldLong_R
Definition p_Procs_Impl.h:114
FieldLong_C
@ FieldLong_C
Definition p_Procs_Impl.h:115
FieldR
@ FieldR
Definition p_Procs_Impl.h:111
FieldGeneral
@ FieldGeneral
Definition p_Procs_Impl.h:108
FieldGF
@ FieldGF
Definition p_Procs_Impl.h:112
p_FieldEnum_2_String
static const char * p_FieldEnum_2_String(p_Field field)
Definition p_Procs_Impl.h:198
SetProcs_ring
#define SetProcs_ring(field, length, ord)
Definition p_Procs_Impl.h:698
p_Ord
p_Ord
Definition p_Procs_Impl.h:136
OrdNomogZero
@ OrdNomogZero
Definition p_Procs_Impl.h:146
OrdPomogNegZero
@ OrdPomogNegZero
Definition p_Procs_Impl.h:158
OrdPosNomog
@ OrdPosNomog
Definition p_Procs_Impl.h:153
OrdNegPomogZero
@ OrdNegPomogZero
Definition p_Procs_Impl.h:157
OrdPosNomogPosZero
@ OrdPosNomogPosZero
Definition p_Procs_Impl.h:171
OrdNegPomog
@ OrdNegPomog
Definition p_Procs_Impl.h:149
OrdPomogNeg
@ OrdPomogNeg
Definition p_Procs_Impl.h:150
OrdPomog
@ OrdPomog
Definition p_Procs_Impl.h:140
OrdPosNomogZero
@ OrdPosNomogZero
Definition p_Procs_Impl.h:168
OrdPosPosNomogZero
@ OrdPosPosNomogZero
Definition p_Procs_Impl.h:170
OrdPosNomogPos
@ OrdPosNomogPos
Definition p_Procs_Impl.h:162
OrdGeneral
@ OrdGeneral
Definition p_Procs_Impl.h:137
OrdNomog
@ OrdNomog
Definition p_Procs_Impl.h:141
OrdNegPosNomogZero
@ OrdNegPosNomogZero
Definition p_Procs_Impl.h:172
OrdNomogPos
@ OrdNomogPos
Definition p_Procs_Impl.h:154
OrdPomogZero
@ OrdPomogZero
Definition p_Procs_Impl.h:145
OrdPosPosNomog
@ OrdPosPosNomog
Definition p_Procs_Impl.h:161
OrdNegPosNomog
@ OrdNegPosNomog
Definition p_Procs_Impl.h:163
OrdNomogPosZero
@ OrdNomogPosZero
Definition p_Procs_Impl.h:167
SetProcs
#define SetProcs(field, length, ord)
Definition p_Procs_Impl.h:662
p_OrdEnum_2_String
static const char * p_OrdEnum_2_String(p_Ord ord)
Definition p_Procs_Impl.h:237
p_LengthEnum_2_String
static const char * p_LengthEnum_2_String(p_Length length)
Definition p_Procs_Impl.h:219
p_IsPomog
static int p_IsPomog(long *sgn, int l)
Definition p_Procs_Set.h:65
p_LengthIs
static p_Length p_LengthIs(ring r)
Definition p_Procs_Set.h:40
p_OrdIs
static p_Ord p_OrdIs(ring r)
Definition p_Procs_Set.h:73
nc_p_ProcsSet
void nc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
Definition old.gring.cc:3161
p_IsNomog
static int p_IsNomog(long *sgn, int l)
Definition p_Procs_Set.h:56
set_names
STATIC_VAR int set_names
Definition p_Procs_Set.h:120
p_ProcsSet
void p_ProcsSet(ring r, p_Procs_s *p_Procs)
Definition p_Procs_Set.h:141
CheckProc
#define CheckProc(which)
Definition p_Procs_Set.h:124
_p_procs
STATIC_VAR p_Procs_s * _p_procs
Definition p_Procs_Set.h:116
p_Debug_GetProcNames
void p_Debug_GetProcNames(const ring r, p_Procs_s *p_Procs)
Definition p_Procs_Set.h:232
p_Debug_GetSpecNames
void p_Debug_GetSpecNames(const ring r, const char *&field, const char *&length, const char *&ord)
Definition p_Procs_Set.h:221
p_FieldIs
static p_Field p_FieldIs(ring r)
Definition p_Procs_Set.h:23
p_Neg
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
pp_Mult_mm
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1033
p_Merge_q
static poly p_Merge_q(poly p, poly q, const ring r)
Definition p_polys.h:1233
pp_Mult_nn
static poly pp_Mult_nn(poly p, number n, const ring r)
Definition p_polys.h:994
p_ShallowCopyDelete
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition p_polys.h:930
p_Mult_nn
static poly p_Mult_nn(poly p, number n, const ring r)
Definition p_polys.h:960
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
p_Mult_mm
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053
p_Minus_mm_Mult_qq
static poly p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, int lq, const poly spNoether, const ring r)
Definition p_polys.h:1077
pp_Mult_Coeff_mm_DivSelect
static poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r)
Definition p_polys.h:1097
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
reporter.h
rField_is_R
static BOOLEAN rField_is_R(const ring r)
Definition ring.h:524
rField_is_Zp_a
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:535
rField_is_Zp
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
p_Procs_s
struct p_Procs_s p_Procs_s
Definition ring.h:24
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
rField_is_long_C
static BOOLEAN rField_is_long_C(const ring r)
Definition ring.h:551
rField_is_Q_a
static BOOLEAN rField_is_Q_a(const ring r)
Definition ring.h:545
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
rField_is_long_R
static BOOLEAN rField_is_long_R(const ring r)
Definition ring.h:548
rField_is_GF
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:527
rField_is_Ring
#define rField_is_Ring(R)
Definition ring.h:491
shift_pp_Mult_Coeff_mm_DivSelect_STUB
poly shift_pp_Mult_Coeff_mm_DivSelect_STUB(poly, const poly, int &, const ring)
Definition shiftop.cc:319
shift_p_Minus_mm_Mult_qq
poly shift_p_Minus_mm_Mult_qq(poly p, poly m, poly q, int &Shorter, const poly, const ring ri)
Definition shiftop.cc:269
shift_pp_mm_Mult
poly shift_pp_mm_Mult(poly p, const poly m, const ring ri)
Definition shiftop.cc:145
shift_pp_Mult_mm_Noether_STUB
poly shift_pp_Mult_mm_Noether_STUB(poly p, const poly m, const poly, int &ll, const ring ri)
Definition shiftop.cc:288
shift_p_mm_Mult
poly shift_p_mm_Mult(poly p, const poly m, const ring ri)
Definition shiftop.cc:212
shift_p_Mult_mm
poly shift_p_Mult_mm(poly p, const poly m, const ring ri)
Definition shiftop.cc:89
shift_pp_Mult_mm
poly shift_pp_Mult_mm(poly p, const poly m, const ring ri)
Definition shiftop.cc:21
shift_pp_Mult_Coeff_mm_DivSelectMult_STUB
poly shift_pp_Mult_Coeff_mm_DivSelectMult_STUB(poly, const poly, const poly, const poly, int &, const ring)
Definition shiftop.cc:313
shiftop.h