Macaulay2 Engine
Loading...
Searching...
No Matches
◆
CRA()
[4/5]
vec ChineseRemainder::CRA
(
const
PolyRing
*
R
,
vec
f
,
vec
g
,
mpz_srcptr
um
,
mpz_srcptr
vn
,
mpz_srcptr
mn
)
static
Definition at line
181
of file
cra.cpp
.
187
{
188
vecterm head;
189
vec
result
= &head;
190
191
while
(1)
192
{
193
if
(g ==
nullptr
)
194
{
195
// mult each term of f by n:
196
for
(; f !=
nullptr
; f = f->next)
197
{
198
result
->next = R->
new_vec
();
199
result
=
result
->next;
200
result
->next =
nullptr
;
201
result
->coeff =
CRA
(R, f->coeff,
nullptr
, um, vn, mn);
202
result
->comp = f->comp;
203
}
204
break
;
205
}
206
if
(f ==
nullptr
)
207
{
208
// mult each term of g by n:
209
for
(; g !=
nullptr
; g = g->next)
210
{
211
result
->next = R->
new_vec
();
212
result
=
result
->next;
213
result
->next =
nullptr
;
214
result
->coeff =
CRA
(R,
nullptr
, g->coeff, um, vn, mn);
215
result
->comp = g->comp;
216
}
217
break
;
218
}
219
if
(f->comp < g->comp)
220
{
221
result
->next = R->
new_vec
();
222
result
=
result
->next;
223
result
->next =
nullptr
;
224
result
->coeff =
CRA
(R,
nullptr
, g->coeff, um, vn, mn);
225
result
->comp = g->comp;
226
g = g->next;
227
}
228
else
if
(f->comp > g->comp)
229
{
230
result
->next = R->
new_vec
();
231
result
=
result
->next;
232
result
->next =
nullptr
;
233
result
->coeff =
CRA
(R, f->coeff,
nullptr
, um, vn, mn);
234
result
->comp = f->comp;
235
f = f->next;
236
}
237
else
238
{
239
result
->next = R->
new_vec
();
240
result
=
result
->next;
241
result
->next =
nullptr
;
242
result
->coeff =
CRA
(R, f->coeff, g->coeff, um, vn, mn);
243
result
->comp = f->comp;
244
f = f->next;
245
g = g->next;
246
}
247
}
248
result
->
next
=
nullptr
;
249
return
head.
next
;
250
}
ChineseRemainder::CRA
static ring_elem CRA(const PolyRing *R, const ring_elem f, const ring_elem g, mpz_srcptr um, mpz_srcptr vn, mpz_srcptr mn)
Definition
cra.cpp:53
Ring::new_vec
vec new_vec() const
vector operations ////////////////////
Definition
ring-vecs.cpp:54
result
VALGRIND_MAKE_MEM_DEFINED & result(result)
vecterm::next
vec next
Definition
ringelem.hpp:170
References
CRA()
,
Ring::new_vec()
,
vec::next
, and
result()
.
ChineseRemainder
Generated on
for Macaulay2 Engine by
1.15.0