source: git/dyn_modules/syzextra/DebugPrint.cc @ ff7993

spielwiese
Last change on this file since ff7993 was 72a01e, checked in by Hans Schoenemann <hannes@…>, 10 years ago
removed unused febase.h, moved parts to ipshell.h/subexpr.h/structs.h
  • 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 <kernel/ideals.h>
30
31
32
33BEGIN_NAMESPACE()
34/// debug-print monomial poly/vector p, assuming that it lives in the ring R
35static 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}
45END_NAMESPACE
46
47BEGIN_NAMESPACE_SINGULARXX    BEGIN_NAMESPACE(DEBUG)
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.
51void 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
83void 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
103END_NAMESPACE               END_NAMESPACE_SINGULARXX
104
105
106// Vi-modeline: vim: filetype=c:syntax:shiftwidth=2:tabstop=8:textwidth=0:expandtab
Note: See TracBrowser for help on using the repository browser.