DebugPrint.cc
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 /*****************************************************************************\
3  * Computer Algebra System SINGULAR
4 \*****************************************************************************/
5 /** @file DebugPrint.cc
6  *
7  * Here we implement dPrint-s.
8  *
9  * ABSTRACT: debug-detailed-printing
10  *
11  * @author Oleksandr Motsak
12  *
13  *
14  **/
15 /*****************************************************************************/
16 
17 
18 
19 
20 
21 // include header file
22 #include <kernel/mod2.h>
23 
24 #include "DebugPrint.h"
25 
26 #include <omalloc/omalloc.h>
28 
29 #include <kernel/ideals.h>
30 
31 
32 
34 /// debug-print monomial poly/vector p, assuming that it lives in the ring R
35 static inline void m_DebugPrint(const poly p, const ring R)
36 {
37  Print("\nexp[0..%d]\n", R->ExpL_Size - 1);
38  for(int i = 0; i < R->ExpL_Size; i++)
39  Print("%09lx ", p->exp[i]);
40  PrintLn();
41  Print("v0:%9ld ", p_GetComp(p, R));
42  for(int i = 1; i <= R->N; i++) Print(" v%d:%5ld",i, p_GetExp(p, i, R));
43  PrintLn();
44 }
46 
48 
49 // debug-print at most nTerms (2 by default) terms from poly/vector p,
50 // assuming that lt(p) lives in lmRing and tail(p) lives in tailRing.
51 void dPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms)
52 {
53  assume( nTerms >= 0 );
54  if( p != NULL )
55  {
56  assume( p != NULL );
57 
58  p_Write(p, lmRing, tailRing);
59 
60  if( (p != NULL) && (nTerms > 0) )
61  {
62  assume( p != NULL );
63  assume( nTerms > 0 );
64 
65  // debug pring leading term
66  m_DebugPrint(p, lmRing);
67 
68  poly q = pNext(p); // q = tail(p)
69 
70  // debug pring tail (at most nTerms-1 terms from it)
71  for(int j = nTerms - 1; (q !=NULL) && (j > 0); pIter(q), --j)
72  m_DebugPrint(q, tailRing);
73 
74  if (q != NULL)
75  PrintS("...\n");
76  }
77  }
78  else
79  PrintS("0\n");
80 }
81 
82 // output an ideal
83 void dPrint(const ideal id, const ring lmRing, const ring tailRing, const int nTerms)
84 {
85  assume( nTerms >= 0 );
86 
87  if( id == NULL )
88  PrintS("(NULL)");
89  else
90  {
91  Print("Module of rank %ld,real rank %ld and %d generators.\n",
92  id->rank,id_RankFreeModule(id, lmRing, tailRing),IDELEMS(id));
93 
94  int j = (id->ncols*id->nrows) - 1;
95  while ((j > 0) && (id->m[j]==NULL)) j--;
96  for (int i = 0; i <= j; i++)
97  {
98  Print("generator %d: ",i); dPrint(id->m[i], lmRing, tailRing, nTerms);
99  }
100  }
101 }
102 
104 
105 
106 // Vi-modeline: vim: filetype=c:syntax:shiftwidth=2:tabstop=8:textwidth=0:expandtab
BEGIN_NAMESPACE_SINGULARXX const ring lmRing
Definition: DebugPrint.h:30
return P p
Definition: myNF.cc:203
Detailed print for debugging.
#define p_GetComp(p, r)
Definition: monomials.h:72
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
Definition: DebugPrint.h:30
static void m_DebugPrint(const poly p, const ring R)
debug-print monomial poly/vector p, assuming that it lives in the ring R
Definition: ring.cc:4263
#define BEGIN_NAMESPACE_SINGULARXX
#define pIter(p)
Definition: monomials.h:44
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:465
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
#define END_NAMESPACE_SINGULARXX
const ring R
Definition: DebugPrint.cc:36
Print("v0:%9ld ", p_GetComp(p, R))
BEGIN_NAMESPACE_SINGULARXX const ring const ring const int nTerms
Definition: DebugPrint.h:30
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
BEGIN_NAMESPACE() static inline void m_DebugPrint(const poly p
debug-print monomial poly/vector p, assuming that it lives in the ring R
#define END_NAMESPACE
#define pNext(p)
Definition: monomials.h:43
#define const
Definition: fegetopt.c:41
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:206
polyrec * poly
Definition: hilb.h:10
void dPrint(const ideal id, const ring lmRing=currRing, const ring tailRing=currRing, const int nTerms=0)
prints an ideal, optionally with details
PrintLn()
Definition: reporter.cc:327