source: git/dyn_modules/syzextra/DebugPrint.cc @ 4676d5

spielwiese
Last change on this file since 4676d5 was 4676d5, checked in by Oleksandr Motsak <motsak@…>, 10 years ago
Moved timer.*, feread.cc and febase.* from /kernel/ to /Singular/ (also corrected the option(prot); handling) NOTE: also removes line breakes and timings in the output due to option (prot), which were unaccounted and undocumented
  • 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 *
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>
27#include <polys/monomials/p_polys.h>
28
29#include <Singular/febase.h>
30#include <kernel/ideals.h>
31
32
33
34BEGIN_NAMESPACE()
35/// debug-print monomial poly/vector p, assuming that it lives in the ring R
36static 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}
46END_NAMESPACE
47
48BEGIN_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.
52void 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
84void 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
104END_NAMESPACE               END_NAMESPACE_SINGULARXX
105
106
107// Vi-modeline: vim: filetype=c:syntax:shiftwidth=2:tabstop=8:textwidth=0:expandtab
Note: See TracBrowser for help on using the repository browser.