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 | #ifdef HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif /* HAVE_CONFIG_H */ |
---|
20 | |
---|
21 | // include header file |
---|
22 | #include <kernel/mod2.h> |
---|
23 | |
---|
24 | #include "DebugPrint.h" |
---|
25 | |
---|
26 | #include <omalloc/omalloc.h> |
---|
27 | #include <polys/monomials/p_polys.h> |
---|
28 | |
---|
29 | #include <kernel/febase.h> |
---|
30 | #include <kernel/ideals.h> |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | BEGIN_NAMESPACE() |
---|
35 | /// debug-print monomial poly/vector p, assuming that it lives in the ring R |
---|
36 | static inline void m_DebugPrint(const poly p, const ring R) |
---|
37 | { |
---|
38 | Print("\nexp[0..%d]\n", R->ExpL_Size - 1); |
---|
39 | for(int i = 0; i < R->ExpL_Size; i++) |
---|
40 | Print("%09lx ", p->exp[i]); |
---|
41 | PrintLn(); |
---|
42 | Print("v0:%9ld ", p_GetComp(p, R)); |
---|
43 | for(int i = 1; i <= R->N; i++) Print(" v%d:%5ld",i, p_GetExp(p, i, R)); |
---|
44 | PrintLn(); |
---|
45 | } |
---|
46 | END_NAMESPACE |
---|
47 | |
---|
48 | BEGIN_NAMESPACE_SINGULARXX BEGIN_NAMESPACE(DEBUG) |
---|
49 | |
---|
50 | // debug-print at most nTerms (2 by default) terms from poly/vector p, |
---|
51 | // assuming that lt(p) lives in lmRing and tail(p) lives in tailRing. |
---|
52 | void dPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms) |
---|
53 | { |
---|
54 | assume( nTerms >= 0 ); |
---|
55 | if( p != NULL ) |
---|
56 | { |
---|
57 | assume( p != NULL ); |
---|
58 | |
---|
59 | p_Write(p, lmRing, tailRing); |
---|
60 | |
---|
61 | if( (p != NULL) && (nTerms > 0) ) |
---|
62 | { |
---|
63 | assume( p != NULL ); |
---|
64 | assume( nTerms > 0 ); |
---|
65 | |
---|
66 | // debug pring leading term |
---|
67 | m_DebugPrint(p, lmRing); |
---|
68 | |
---|
69 | poly q = pNext(p); // q = tail(p) |
---|
70 | |
---|
71 | // debug pring tail (at most nTerms-1 terms from it) |
---|
72 | for(int j = nTerms - 1; (q !=NULL) && (j > 0); pIter(q), --j) |
---|
73 | m_DebugPrint(q, tailRing); |
---|
74 | |
---|
75 | if (q != NULL) |
---|
76 | PrintS("...\n"); |
---|
77 | } |
---|
78 | } |
---|
79 | else |
---|
80 | PrintS("0\n"); |
---|
81 | } |
---|
82 | |
---|
83 | // output an ideal |
---|
84 | void dPrint(const ideal id, const ring lmRing, const ring tailRing, const int nTerms) |
---|
85 | { |
---|
86 | assume( nTerms >= 0 ); |
---|
87 | |
---|
88 | if( id == NULL ) |
---|
89 | PrintS("(NULL)"); |
---|
90 | else |
---|
91 | { |
---|
92 | Print("Module of rank %ld,real rank %ld and %d generators.\n", |
---|
93 | id->rank,id_RankFreeModule(id, lmRing, tailRing),IDELEMS(id)); |
---|
94 | |
---|
95 | int j = (id->ncols*id->nrows) - 1; |
---|
96 | while ((j > 0) && (id->m[j]==NULL)) j--; |
---|
97 | for (int i = 0; i <= j; i++) |
---|
98 | { |
---|
99 | Print("generator %d: ",i); dPrint(id->m[i], lmRing, tailRing, nTerms); |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | END_NAMESPACE END_NAMESPACE_SINGULARXX |
---|
105 | |
---|
106 | |
---|
107 | // Vi-modeline: vim: filetype=c:syntax:shiftwidth=2:tabstop=8:textwidth=0:expandtab |
---|