My Project
numstats.h
Go to the documentation of this file.
1/*! \file coeffs/numstats.h Count number operarions over coefficient rings, fields and other domains suitable for Singular polynomials
2
3 Optional addition for the main interface for Singular coefficients,
4 i.e. to n_[A-Z].* (..., const coeffs) functions
5*/
6#ifndef NUMSTATS_H
7#define NUMSTATS_H
8
9#include "misc/auxiliary.h"
10#include "reporter/reporter.h"
11
12#ifndef HAVE_NUMSTATS
13
14// Nothing will happen if HAVE_NUMSTATS was not defined
15#define ALL_STATISTIC(FUN)
16#define STATISTIC(f) do{}while(0)
17#else
18
19// Otherwise we will treat the following wrappers:
20
21#define ALL_STATISTIC(FUN) \
22 FUN(n_Test); \
23 FUN(n_Size); \
24 FUN(n_Normalize); \
25 FUN(n_NormalizeHelper); \
26 FUN(n_GetChar); \
27 FUN(n_SetMap); \
28 FUN(n_Delete); \
29 FUN(n_Copy); \
30 FUN(n_Init); \
31 FUN(n_InitMPZ); \
32 FUN(n_Int); \
33 FUN(n_MPZ); \
34 FUN(n_Invers); \
35 FUN(n_Div); \
36 FUN(n_DivBy); \
37 FUN(n_ExactDiv); \
38 FUN(n_IntMod); \
39 FUN(n_Mult); \
40 FUN(n_InpMult); \
41 FUN(n_Power); \
42 FUN(n_Add); \
43 FUN(n_InpAdd); \
44 FUN(n_Sub); \
45 FUN(n_InpNeg); \
46 FUN(n_Equal); \
47 FUN(n_IsZero); \
48 FUN(n_IsOne); \
49 FUN(n_IsMOne); \
50 FUN(n_GreaterZero); \
51 FUN(n_Greater); \
52 FUN(n_DivComp); \
53 FUN(n_IsUnit); \
54 FUN(n_GetUnit); \
55 FUN(n_CoeffRingQuot1); \
56 FUN(n_Lcm); \
57 FUN(n_Gcd); \
58 FUN(n_ExtGcd); \
59 FUN(n_XExtGcd); \
60 FUN(n_SubringGcd); \
61 FUN(n_EucNorm); \
62 FUN(n_Ann); \
63 FUN(n_QuotRem); \
64 FUN(n_Farey); \
65 FUN(n_ChineseRemainderSym); \
66 FUN(n_RePart); \
67 FUN(n_ImPart); \
68 FUN(n_ParDeg); \
69 FUN(n_Param); \
70 FUN(n_NumberOfParameters); \
71 FUN(n_ParameterNames); \
72 FUN(n_GetDenom); \
73 FUN(n_GetNumerator); \
74 FUN(n_ClearContent); \
75 FUN(n_ClearDenominators); \
76 FUN(n_Read); \
77 FUN(n_Write); \
78 FUN(n_ReadFd); \
79 FUN(n_WriteFd); \
80 FUN(n_WriteLong); \
81 FUN(n_WriteShort); \
82 FUN(nCoeffString); \
83 FUN(nCoeffName); \
84 FUN(nSetChar); \
85 FUN(nKillChar); \
86 FUN(n_convFactoryNSingN); \
87 FUN(n_convSingNFactoryN); \
88 FUN(n_Random); \
89 FUN(n_CoeffWrite)
90
91
92
93struct SNumberStatistic
94{
95 public:
96 SNumberStatistic(){ Init(); }
97
98 inline void Init(const unsigned long defaultvalue = 0)
99 {
100#define _Z(F) this->F = defaultvalue
101 ALL_STATISTIC(_Z);
102 _Z(n_CancelOut);
103#undef _Z
104 }
105
106 inline void Print() const
107 {
108#define _P(F) if(this->F > 0) ::Print("%21s: %13lu\n", # F, this->F)
109 ALL_STATISTIC(_P);
110 _P(n_CancelOut);
111#undef _P
112 }
113
114#define _UL(F) unsigned long F
115 ALL_STATISTIC(_UL);
116 _UL(n_CancelOut);
117#undef _UL
118};
119
120#define STATISTIC(F) {extern struct SNumberStatistic number_stats; number_stats.F += 1;}
121#endif
122
123/// set all counters to zero
124static inline void number_stats_Init(const unsigned long defaultvalue = 0)
125{
126#ifndef HAVE_NUMSTATS
127 WarnS("Please enable NUMSTATS first!");
128 (void)(defaultvalue);
129#else
130 EXTERN_VAR struct SNumberStatistic number_stats;
131 number_stats.Init(defaultvalue);
132#endif
133}
134
135/// print out all counters
136static inline void number_stats_Print(const char * const msg = NULL)
137{
138 ::Print("%s:\n", (msg == NULL) ? "Statistic about number operations" : msg);
139#ifndef HAVE_NUMSTATS
140 WarnS("Please enable NUMSTATS first!");
141#else
142 EXTERN_VAR struct SNumberStatistic number_stats;
143 number_stats.Print();
144#endif
145 ::PrintLn();
146}
147#endif /* NUMSTAT */
148
All the auxiliary stuff.
#define NULL
Definition: auxiliary.h:104
#define Print
Definition: emacs.cc:80
#define WarnS
Definition: emacs.cc:78
static number Init(long i, const coeffs)
Definition: flintcf_Q.cc:118
#define EXTERN_VAR
Definition: globaldefs.h:6
static void number_stats_Print(const char *const msg=NULL)
print out all counters
Definition: numstats.h:136
#define ALL_STATISTIC(FUN)
Definition: numstats.h:15
static void number_stats_Init(const unsigned long defaultvalue=0)
set all counters to zero
Definition: numstats.h:124
void PrintLn()
Definition: reporter.cc:310