MCPcopy Create free account
hub / github.com/Singular/Singular / TestSimpleRingArithmetcs

Function TestSimpleRingArithmetcs

kernel/combinatorics/test.cc:272–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270
271
272void TestSimpleRingArithmetcs()
273{
274 // Libpolys tests:
275
276 // construct the ring Z/32003[x,y,z]
277 // the variable names
278 char **n=(char**)omalloc(3*sizeof(char*));
279 n[0]=omStrDup("x");
280 n[1]=omStrDup("y");
281 n[2]=omStrDup("z2");
282
283 ring R = rDefault(32003,3,n); // ring R = rDefault(0,3,n);
284
285 rWrite(R); PrintLn();
286
287#ifdef RDEBUG
288 rDebugPrint(R);
289#endif
290
291
292 poly p = p_ISet(1,R); p_SetExp(p,1,1, R); p_Setm(p, R);
293
294 assume( p_GetExp(p,1, R) == 1 );
295
296 poly pp = pp_Mult_qq( p, p, R);
297
298 PrintS("p: "); p_Write0(p, R); Print(", deg(p): %ld", p_Totaldegree(p, R)); assume( 1 == p_Totaldegree(p, R) );
299
300 PrintS("; p*p : "); p_Write0(pp, R); Print("deg(pp): %ld\n", p_Totaldegree(pp, R)); assume( 2 == p_Totaldegree(pp, R) );
301
302
303 p_Delete(&p, R);
304
305 assume( p_GetExp(pp,1, R) == 2 );
306
307 p_Delete(&pp, R);
308
309
310// rDelete(R);
311
312 // make R the default ring:
313 rChangeCurrRing(R);
314
315 // create the polynomial 1
316 poly p1=pISet(1);
317
318 // create the polynomial 2*x^3*z^2
319 poly p2=p_ISet(2,R);
320 pSetExp(p2,1,3);
321 pSetExp(p2,3,2);
322 pSetm(p2);
323
324 // print p1 + p2
325 PrintS("p1: "); pWrite0(p1);
326 PrintS(" + p2: "); pWrite0(p2);
327 PrintS(" ---- >>>> ");
328
329 // compute p1+p2

Callers 1

mainFunction · 0.70

Calls 15

rWriteFunction · 0.85
rDebugPrintFunction · 0.85
p_ISetFunction · 0.85
p_SetExpFunction · 0.85
p_SetmFunction · 0.85
p_GetExpFunction · 0.85
pp_Mult_qqFunction · 0.85
PrintSFunction · 0.85
p_TotaldegreeFunction · 0.85
p_DeleteFunction · 0.85
rChangeCurrRingFunction · 0.85
pWrite0Function · 0.85

Tested by

no test coverage detected