source: git/dyn_modules/syzextra/DebugPrint.cc @ 0917a96

fieker-DuValspielwiese
Last change on this file since 0917a96 was 0917a96, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
adaptation of dyn_modules/syzextra for spielwiese fix: fixed dyn_modules/syzextra to work with spielwiese chg: use n_Init for long -> bigint conversion NOTE: the resulting bigint may be negative for (implicitly) casted unsigned longs (e.g. for raw poly/vector exponents) chg: further minor adaptations
  • Property mode set to 100644
File size: 2.6 KB
Line 
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 * @internal @version \$Id$
14 *
15 **/
16/*****************************************************************************/
17
18// include header file
19#include <kernel/mod2.h>
20
21#include "DebugPrint.h"
22
23#include <omalloc/omalloc.h>
24#include <polys/monomials/p_polys.h>
25
26#include <kernel/febase.h>
27#include <kernel/ideals.h>
28
29
30
31BEGIN_NAMESPACE()
32/// debug-print monomial poly/vector p, assuming that it lives in the ring R
33static inline void m_DebugPrint(const poly p, const ring R)
34{
35  Print("\nexp[0..%d]\n", R->ExpL_Size - 1);
36  for(int i = 0; i < R->ExpL_Size; i++)
37    Print("%09lx ", p->exp[i]);
38  PrintLn();
39  Print("v0:%9ld ", p_GetComp(p, R));
40  for(int i = 1; i <= R->N; i++) Print(" v%d:%5ld",i, p_GetExp(p, i, R));
41  PrintLn();
42}
43END_NAMESPACE
44
45BEGIN_NAMESPACE_SINGULARXX    BEGIN_NAMESPACE(DEBUG)
46
47// debug-print at most nTerms (2 by default) terms from poly/vector p,
48// assuming that lt(p) lives in lmRing and tail(p) lives in tailRing.
49void dPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms)
50{
51  assume( nTerms >= 0 );
52  if( p != NULL )
53  {
54    assume( p != NULL );
55
56    p_Write(p, lmRing, tailRing);
57
58    if( (p != NULL) && (nTerms > 0) )
59    {
60      assume( p != NULL );
61      assume( nTerms > 0 );
62
63      // debug pring leading term
64      m_DebugPrint(p, lmRing);
65
66      poly q = pNext(p); // q = tail(p)
67
68      // debug pring tail (at most nTerms-1 terms from it)
69      for(int j = nTerms - 1; (q !=NULL) && (j > 0); pIter(q), --j)
70        m_DebugPrint(q, tailRing);
71
72      if (q != NULL)
73        PrintS("...\n");
74    }
75  }
76  else
77    PrintS("0\n");
78}
79
80// output an ideal
81void dPrint(const ideal id, const ring lmRing, const ring tailRing, const int nTerms)
82{
83  assume( nTerms >= 0 );
84
85  if( id == NULL )
86    PrintS("(NULL)");
87  else
88  {
89    Print("Module of rank %ld,real rank %ld and %d generators.\n",
90          id->rank,id_RankFreeModule(id, lmRing, tailRing),IDELEMS(id));
91
92    int j = (id->ncols*id->nrows) - 1;
93    while ((j > 0) && (id->m[j]==NULL)) j--;
94    for (int i = 0; i <= j; i++)
95    {
96      Print("generator %d: ",i); dPrint(id->m[i], lmRing, tailRing, nTerms);
97    }
98  }
99}
100
101END_NAMESPACE               END_NAMESPACE_SINGULARXX
102
103
104// Vi-modeline: vim: filetype=c:syntax:shiftwidth=2:tabstop=8:textwidth=0:expandtab
Note: See TracBrowser for help on using the repository browser.