My Project
Loading...
Searching...
No Matches
Macros | Functions
sparsmat.h File Reference

Go to the source code of this file.

Macros

#define SM_MULT   sm_MultDiv
 
#define SM_DIV   sm_SpecialPolyDiv
 

Functions

poly sm_MultDiv (poly, poly, const poly, const ring)
 
void sm_SpecialPolyDiv (poly, poly, const ring)
 
poly sm_CallDet (ideal I, const ring)
 
void sm_CallBareiss (ideal smat, int x, int y, ideal &M, intvec **iv, const ring)
 
ideal sm_CallSolv (ideal I, const ring)
 
ring sm_RingChange (const ring, long)
 
void sm_KillModifiedRing (ring r)
 
long sm_ExpBound (ideal, int, int, int, const ring)
 

Macro Definition Documentation

◆ SM_DIV

#define SM_DIV   sm_SpecialPolyDiv

Definition at line 24 of file sparsmat.h.

◆ SM_MULT

#define SM_MULT   sm_MultDiv

Definition at line 23 of file sparsmat.h.

Function Documentation

◆ sm_CallBareiss()

void sm_CallBareiss ( ideal  smat,
int  x,
int  y,
ideal &  M,
intvec **  iv,
const  ring 
)

Definition at line 347 of file sparsmat.cc.

348{
349 int r=id_RankFreeModule(I,R),t=r;
350 int c=IDELEMS(I),s=c;
351 long bound;
352 ring tmpR;
353 sparse_mat *bareiss;
354
355 if ((x>0) && (x<t))
356 t-=x;
357 if ((y>1) && (y<s))
358 s-=y;
359 if (t>s) t=s;
360 bound=sm_ExpBound(I,c,r,t,R);
361 tmpR=sm_RingChange(R,bound);
362 ideal II = idrCopyR(I, R, tmpR);
363 bareiss = new sparse_mat(II,tmpR);
364 if (bareiss->smGetAct() == NULL)
365 {
366 delete bareiss;
367 *iv=new intvec(1,rVar(tmpR));
368 }
369 else
370 {
371 id_Delete(&II,tmpR);
372 bareiss->smNewBareiss(x, y);
373 II = bareiss->smRes2Mod();
374 *iv = new intvec(bareiss->smGetRed());
375 bareiss->smToIntvec(*iv);
376 delete bareiss;
377 II = idrMoveR(II,tmpR,R);
378 }
380 M=II;
381}
Variable x
Definition: cfModGcd.cc:4082
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
Definition: intvec.h:23
void smToIntvec(intvec *)
Definition: sparsmat.cc:464
int smGetRed()
Definition: sparsmat.cc:173
smpoly * smGetAct()
Definition: sparsmat.cc:172
void smNewBareiss(int, int)
Definition: sparsmat.cc:549
ideal smRes2Mod()
Definition: sparsmat.cc:448
const CanonicalForm int s
Definition: facAbsFact.cc:51
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:53
#define NULL
Definition: omList.c:12
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:248
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:192
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define IDELEMS(i)
Definition: simpleideals.h:23
#define R
Definition: sirandom.c:27
#define M
Definition: sirandom.c:25
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition: sparsmat.cc:188
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:258
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:289

◆ sm_CallDet()

poly sm_CallDet ( ideal  I,
const  ring 
)

Definition at line 302 of file sparsmat.cc.

303{
304 if (I->ncols != I->rank)
305 {
306 Werror("det of %ld x %d module (matrix)",I->rank,I->ncols);
307 return NULL;
308 }
309 int r=id_RankFreeModule(I,R);
310 if (I->ncols != r) // some 0-lines at the end
311 {
312 return NULL;
313 }
314 long bound=sm_ExpBound(I,r,r,r,R);
315 number diag,h=n_Init(1,R->cf);
316 poly res;
317 ring tmpR;
318 sparse_mat *det;
319 ideal II;
320
321 tmpR=sm_RingChange(R,bound);
322 II = idrCopyR(I, R, tmpR);
323 diag = sm_Cleardenom(II,tmpR);
324 det = new sparse_mat(II,tmpR);
325 id_Delete(&II,tmpR);
326 if (det->smGetAct() == NULL)
327 {
328 delete det;
330 return NULL;
331 }
332 res=det->smDet();
333 if(det->smGetSign()<0) res=p_Neg(res,tmpR);
334 delete det;
335 res = prMoveR(res, tmpR, R);
337 if (!n_Equal(diag,h,R->cf))
338 {
339 p_Mult_nn(res,diag,R);
341 }
342 n_Delete(&diag,R->cf);
343 n_Delete(&h,R->cf);
344 return res;
345}
int smGetSign()
Definition: sparsmat.cc:171
poly smDet()
Definition: sparsmat.cc:475
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:535
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:457
CanonicalForm res
Definition: facAbsFact.cc:60
STATIC_VAR Poly * h
Definition: janet.cc:971
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3813
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1105
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:956
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:90
void Werror(const char *fmt,...)
Definition: reporter.cc:189
static number sm_Cleardenom(ideal, const ring)
Definition: sparsmat.cc:2223

◆ sm_CallSolv()

ideal sm_CallSolv ( ideal  I,
const  ring 
)

Definition at line 2316 of file sparsmat.cc.

2317{
2318 sparse_number_mat *linsolv;
2319 ring tmpR;
2320 ideal rr;
2321
2322 if (id_IsConstant(I,R)==FALSE)
2323 {
2324 WerrorS("symbol in equation");
2325 return NULL;
2326 }
2327 I->rank = id_RankFreeModule(I,R);
2328 if (smCheckSolv(I)) return NULL;
2329 tmpR=sm_RingChange(R,1);
2330 rr=idrCopyR(I,R, tmpR);
2331 linsolv = new sparse_number_mat(rr,tmpR);
2332 rr=NULL;
2333 linsolv->smTriangular();
2334 if (linsolv->smIsSing() == 0)
2335 {
2336 linsolv->smSolv();
2337 rr = linsolv->smRes2Ideal();
2338 }
2339 else
2340 WerrorS("singular problem for linsolv");
2341 delete linsolv;
2342 if (rr!=NULL)
2343 rr = idrMoveR(rr,tmpR,R);
2344 sm_KillModifiedRing(tmpR);
2345 return rr;
2346}
#define FALSE
Definition: auxiliary.h:96
ideal smRes2Ideal()
Definition: sparsmat.cc:2506
void WerrorS(const char *s)
Definition: feFopen.cc:24
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
static BOOLEAN smCheckSolv(ideal)
Definition: sparsmat.cc:2889

◆ sm_ExpBound()

long sm_ExpBound ( ideal  m,
int  di,
int  ra,
int  t,
const  ring 
)

Definition at line 188 of file sparsmat.cc.

189{
190 poly p;
191 long kr, kc;
192 long *r, *c;
193 int al, bl, i, j, k;
194
195 if (ra==0) ra=1;
196 al = di*sizeof(long);
197 c = (long *)omAlloc(al);
198 bl = ra*sizeof(long);
199 r = (long *)omAlloc0(bl);
200 for (i=di-1;i>=0;i--)
201 {
202 kc = 0;
203 p = m->m[i];
204 while(p!=NULL)
205 {
206 k = p_GetComp(p, currRing)-1;
207 kr = r[k];
208 for (j=currRing->N;j>0;j--)
209 {
210 long t=p_GetExp(p,j, currRing);
211 if(t /*p_GetExp(p,j, currRing)*/ >kc)
212 kc=t; /*p_GetExp(p,j, currRing);*/
213 if(t /*p_GetExp(p,j, currRing)s*/ >kr)
214 kr=t; /*p_GetExp(p,j, currRing);*/
215 }
216 r[k] = kr;
217 pIter(p);
218 }
219 c[i] = kc;
220 }
221 if (t<di) smMinSelect(c, t, di);
222 if (t<ra) smMinSelect(r, t, ra);
223 kr = kc = 0;
224 for (j=t-1;j>=0;j--)
225 {
226 kr += r[j];
227 kc += c[j];
228 }
229 omFreeSize((ADDRESS)c, al);
230 omFreeSize((ADDRESS)r, bl);
231 if (kr<kc) kc = kr;
232 if (kr<1) kr = 1;
233 return kr;
234}
void * ADDRESS
Definition: auxiliary.h:119
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
int p
Definition: cfModGcd.cc:4078
int j
Definition: facHensel.cc:110
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:467
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static void smMinSelect(long *, int, int)
Definition: sparsmat.cc:236

◆ sm_KillModifiedRing()

void sm_KillModifiedRing ( ring  r)

Definition at line 289 of file sparsmat.cc.

290{
291 if (r->qideal!=NULL) id_Delete(&(r->qideal),r);
292 for(int i=r->N-1;i>=0;i--) omFree(r->names[i]);
293 omFreeSize(r->names,r->N*sizeof(char*));
295}
#define omFree(addr)
Definition: omAllocDecl.h:261
void rKillModifiedRing(ring r)
Definition: ring.cc:3059

◆ sm_MultDiv()

poly sm_MultDiv ( poly  a,
poly  b,
const  poly,
const  ring 
)

Definition at line 1759 of file sparsmat.cc.

1760{
1761 poly pa, e, res, r;
1762 BOOLEAN lead;
1763
1764 if ((c == NULL) || p_LmIsConstantComp(c,R))
1765 {
1766 return pp_Mult_qq(a, b, R);
1767 }
1768 if (smSmaller(a, b))
1769 {
1770 r = a;
1771 a = b;
1772 b = r;
1773 }
1774 res = NULL;
1775 e = p_Init(R);
1776 lead = FALSE;
1777 while (!lead)
1778 {
1780 if (sm_IsNegQuot(e, b, c, R))
1781 {
1782 lead = p_LmDivisibleByNoComp(e, a, R);
1783 r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1784 }
1785 else
1786 {
1787 lead = TRUE;
1788 r = pp_Mult_mm(a, e,R);
1789 }
1790 if (lead)
1791 {
1792 if (res != NULL)
1793 {
1794 sm_FindRef(&pa, &res, r, R);
1795 if (pa == NULL)
1796 lead = FALSE;
1797 }
1798 else
1799 {
1800 pa = res = r;
1801 }
1802 }
1803 else
1804 res = p_Add_q(res, r, R);
1805 pIter(b);
1806 if (b == NULL)
1807 {
1808 p_LmFree(e, R);
1809 return res;
1810 }
1811 }
1812 do
1813 {
1815 if (sm_IsNegQuot(e, b, c, R))
1816 {
1817 r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1818 if (p_LmDivisibleByNoComp(e, a,R))
1819 sm_CombineChain(&pa, r, R);
1820 else
1821 pa = p_Add_q(pa,r,R);
1822 }
1823 else
1824 {
1825 r = pp_Mult_mm(a, e, R);
1826 sm_CombineChain(&pa, r, R);
1827 }
1828 pIter(b);
1829 } while (b != NULL);
1830 p_LmFree(e, R);
1831 return res;
1832}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
CanonicalForm b
Definition: cfModGcd.cc:4103
static BOOLEAN pa(leftv res, leftv args)
Definition: cohomo.cc:3723
#define pSetCoeff0(p, n)
Definition: monomials.h:59
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:934
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1029
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:1004
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1875
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1149
static void p_LmFree(poly p, ring)
Definition: p_polys.h:681
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1318
static void sm_CombineChain(poly *, poly, const ring)
Definition: sparsmat.cc:1973
static BOOLEAN smSmaller(poly, poly)
Definition: sparsmat.cc:1962
static poly sm_SelectCopy_ExpMultDiv(poly p, poly m, poly a, poly b, const ring currRing)
Definition: sparsmat.cc:98
static BOOLEAN sm_IsNegQuot(poly, const poly, const poly, const ring)
Definition: sparsmat.cc:1906
static void sm_FindRef(poly *, poly *, poly, const ring)
Definition: sparsmat.cc:2020

◆ sm_RingChange()

ring sm_RingChange ( const  ring,
long  bound 
)

Definition at line 258 of file sparsmat.cc.

259{
260// *origR =currRing;
261 ring tmpR=rCopy0(origR,FALSE,FALSE);
263 int *block0=(int*)omAlloc0(3*sizeof(int));
264 int *block1=(int*)omAlloc0(3*sizeof(int));
265 ord[0]=ringorder_c;
266 ord[1]=ringorder_dp;
267 tmpR->order=ord;
268 tmpR->OrdSgn=1;
269 block0[1]=1;
270 tmpR->block0=block0;
271 block1[1]=tmpR->N;
272 tmpR->block1=block1;
273 tmpR->bitmask = 2*bound;
274 tmpR->wvhdl = (int **)omAlloc0((3) * sizeof(int*));
275
276// ???
277// if (tmpR->bitmask > currRing->bitmask) tmpR->bitmask = currRing->bitmask;
278
279 rComplete(tmpR,1);
280 if (origR->qideal!=NULL)
281 {
282 tmpR->qideal= idrCopyR_NoSort(origR->qideal, origR, tmpR);
283 }
284 if (TEST_OPT_PROT)
285 Print("[%ld:%d]", (long) tmpR->bitmask, tmpR->ExpL_Size);
286 return tmpR;
287}
#define Print
Definition: emacs.cc:80
#define TEST_OPT_PROT
Definition: options.h:104
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:205
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3450
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1421
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_dp
Definition: ring.h:78
@ ringorder_c
Definition: ring.h:72

◆ sm_SpecialPolyDiv()

void sm_SpecialPolyDiv ( poly  a,
poly  b,
const  ring 
)

Definition at line 1840 of file sparsmat.cc.

1841{
1842 if (pNext(b) == NULL)
1843 {
1844 sm_PolyDivN(a, pGetCoeff(b),R);
1845 return;
1846 }
1847 sm_ExactPolyDiv(a, b, R);
1848}
#define pNext(p)
Definition: monomials.h:36
static void sm_ExactPolyDiv(poly, poly, const ring)
Definition: sparsmat.cc:1851
static void sm_PolyDivN(poly, const number, const ring)
Definition: sparsmat.cc:1949