]> www.ginac.de Git - cln.git/blob - tests/test_I_ash.cc
Remove the conversion step .tex -> .texi.
[cln.git] / tests / test_I_ash.cc
1 #include "test_I.h"
2
3 int test_I_ash (int iterations)
4 {
5         int error = 0;
6         int i;
7         // Check against "*" and floor1.
8         for (i = iterations; i > 0; i--) {
9                 cl_I a = testrandom_I();
10                 uintL b = random32() % 1024;
11                 cl_I pow2 = 1;
12                 for (uintL j = 0; j < b; j++)
13                         pow2 = pow2+pow2;
14                 ASSERT1(ash(1,(sintL)b) == pow2, b);
15                 ASSERT1(ash(1,(cl_I)b) == pow2, b);
16                 ASSERT2(ash(a,(sintL)b) == a*pow2, a,b);
17                 ASSERT2(ash(a,-(sintL)b) == floor1(a,pow2), a,b);
18         }
19         // Check homomorphism w.r.t. second argument.
20         for (i = iterations; i > 0; i--) {
21                 cl_I a = testrandom_I();
22                 sintL b = random32() % 1024;
23                 sintL c = random32() % 1024;
24                 ASSERT3(ash(ash(a,b),c) == ash(a,b+c), a,b,c);
25                 ASSERT3(ash(ash(a,b),-c) == ash(a,b-c), a,b,c);
26                 ASSERT3(ash(ash(a,-b),-c) == ash(a,-b-c), a,b,c);
27         }
28         // Check against each other.
29         for (i = iterations; i > 0; i--) {
30                 cl_I a = testrandom_I();
31                 uintL b = random32() % 1024;
32                 ASSERT2(ash(a,(cl_I)b) == ash(a,(sintL)b), a,b);
33                 ASSERT2(ash(a,-(cl_I)b) == ash(a,-(sintL)b), a,b);
34         }
35         return error;
36 }