1 | #include "config.h" |
---|
2 | |
---|
3 | #include <auxiliary.h> |
---|
4 | |
---|
5 | #include <coeffs.h> |
---|
6 | #include <numbers.h> |
---|
7 | #include <reporter.h> |
---|
8 | #include <omalloc.h> |
---|
9 | |
---|
10 | #include <longrat.h> |
---|
11 | #include <gnumpfl.h> |
---|
12 | #include <gnumpc.h> |
---|
13 | #include <shortfl.h> |
---|
14 | |
---|
15 | |
---|
16 | #include <rmodulon.h> |
---|
17 | #include <rmodulo2m.h> |
---|
18 | |
---|
19 | #include <iostream> |
---|
20 | using namespace std; |
---|
21 | |
---|
22 | |
---|
23 | bool Test(const coeffs r) |
---|
24 | { |
---|
25 | number a = n_Init(666, r); |
---|
26 | n_Test(a,r); |
---|
27 | |
---|
28 | number b = n_Add(a, a, r); |
---|
29 | n_Test(b,r); |
---|
30 | |
---|
31 | StringSetS("a: "); n_Write(a, r);PrintS(StringAppend("\n")); |
---|
32 | StringSetS("b: "); n_Write(b, r);PrintS(StringAppend("\n")); |
---|
33 | |
---|
34 | n_Delete(&a, r); |
---|
35 | n_Delete(&b, r); |
---|
36 | |
---|
37 | return false; |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | bool Test(const n_coeffType type, void* p = NULL) |
---|
43 | { |
---|
44 | |
---|
45 | cout << endl << "----------------------- Testing coeffs: [" << type << |
---|
46 | "]: -----------------------" << endl; |
---|
47 | |
---|
48 | const coeffs r = nInitChar( type, p ); |
---|
49 | |
---|
50 | assume( r != NULL ); |
---|
51 | |
---|
52 | nSetChar( r ); |
---|
53 | |
---|
54 | assume( getCoeffType(r) == type ); |
---|
55 | |
---|
56 | assume( r->cfInit != NULL ); |
---|
57 | assume( r->cfWrite != NULL ); |
---|
58 | assume( r->cfAdd != NULL ); |
---|
59 | assume( r->cfDelete != NULL ); |
---|
60 | |
---|
61 | |
---|
62 | if( type == n_Q ) |
---|
63 | { |
---|
64 | assume( r->cfInit == nlInit ); |
---|
65 | assume( r->cfWrite == nlWrite ); |
---|
66 | assume( r->cfAdd == nlAdd ); |
---|
67 | assume( r->cfDelete == nlDelete ); |
---|
68 | } |
---|
69 | else if( type == n_long_R ) |
---|
70 | { |
---|
71 | assume( r->cfInit == ngfInit ); |
---|
72 | assume( r->cfWrite == ngfWrite ); |
---|
73 | assume( r->cfAdd == ngfAdd ); |
---|
74 | assume( r->cfDelete == ngfDelete ); |
---|
75 | } |
---|
76 | else if( type == n_long_C ) |
---|
77 | { |
---|
78 | assume( r->cfInit == ngcInit ); |
---|
79 | assume( r->cfWrite == ngcWrite ); |
---|
80 | assume( r->cfAdd == ngcAdd ); |
---|
81 | assume( r->cfDelete == ngcDelete ); |
---|
82 | } |
---|
83 | else if( type == n_R ) |
---|
84 | { |
---|
85 | assume( r->cfInit == nrInit ); |
---|
86 | assume( r->cfWrite == nrWrite ); |
---|
87 | assume( r->cfAdd == nrAdd ); |
---|
88 | // assume( r->cfDelete == nrDelete ); // No? |
---|
89 | } |
---|
90 | #ifdef HAVE_RINGS |
---|
91 | else if( type == n_Z2m ) |
---|
92 | { |
---|
93 | assume( r->cfInit == nr2mInit ); |
---|
94 | assume( r->cfWrite == nr2mWrite ); |
---|
95 | assume( r->cfAdd == nr2mAdd ); |
---|
96 | assume( r->cfDelete == ndDelete ); |
---|
97 | } |
---|
98 | else if( type == n_Zn ) |
---|
99 | { |
---|
100 | assume( r->cfInit == nrnInit ); |
---|
101 | assume( r->cfWrite == nrnWrite ); |
---|
102 | assume( r->cfAdd == nrnAdd ); |
---|
103 | assume( r->cfDelete == nrnDelete ); |
---|
104 | } |
---|
105 | #endif |
---|
106 | else |
---|
107 | { |
---|
108 | // ... |
---|
109 | } |
---|
110 | |
---|
111 | bool ret = Test( r ); |
---|
112 | |
---|
113 | nKillChar( r ); |
---|
114 | |
---|
115 | return ret; |
---|
116 | } |
---|
117 | |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | int main() |
---|
122 | { |
---|
123 | int c = 0; |
---|
124 | |
---|
125 | n_coeffType type; |
---|
126 | |
---|
127 | // TODO: n_Zp, n_GF, n_Zp_a, n_Q_a ? |
---|
128 | |
---|
129 | type = nRegister( n_Q, nlInitChar); assume( type == n_Q ); |
---|
130 | if( Test(type) ) |
---|
131 | c ++; |
---|
132 | |
---|
133 | type = nRegister( n_long_R, ngfInitChar); assume( type == n_long_R ); |
---|
134 | if( Test(type) ) |
---|
135 | c ++; |
---|
136 | |
---|
137 | type = nRegister( n_long_C, ngcInitChar); assume( type == n_long_C ); |
---|
138 | if( Test(type) ) |
---|
139 | c ++; |
---|
140 | |
---|
141 | type = nRegister( n_R, nrInitChar); assume( type == n_R ); |
---|
142 | if( Test(type) ) |
---|
143 | c ++; |
---|
144 | |
---|
145 | |
---|
146 | #ifdef HAVE_RINGS |
---|
147 | type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m ); |
---|
148 | if( Test(type, (void*) 2) ) |
---|
149 | c ++; |
---|
150 | |
---|
151 | type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn ); |
---|
152 | if( Test(type, (void*) 3) ) |
---|
153 | c ++; |
---|
154 | |
---|
155 | // n_Z, // TODO? |
---|
156 | // n_Zpn, // no longer exists? |
---|
157 | #endif |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | return c; |
---|
162 | |
---|
163 | } |
---|