1include "test.idp" 2 3cout << functionDEFINITION << "cos" << endl; 4real t; 5 6cout << typeDEFINITION << "real" << endl; 7 8real r1 = 0.; 9real r2 = pi; 10real r3 = pi/4; 11real r4 = pi/6; 12 13t = clock(); 14real resr1 = cos(r1); 15t = clock() - t; 16cout << timeELAPSED << t << endl; 17test(resr1 == 1.); 18 19t = clock(); 20real resr2 = cos(r2); 21t = clock() - t; 22cout << timeELAPSED << t << endl; 23test(resr2 == -1.); 24 25t = clock(); 26real resr3 = cos(r3); 27t = clock() - t; 28cout << timeELAPSED << t << endl; 29test(resr3 == sqrt(2)/2); 30 31t = clock(); 32real resr4 = cos(r4); 33t = clock() - t; 34cout << timeELAPSED << t << endl; 35test(abs(resr4 - sqrt(3)/2) < HWERROR); 36 37cout << typeDEFINITION << "complex" << endl; 38 39complex c1 = 1. + 1i; 40complex c2 = 4. + 2i; 41 42t = clock(); 43complex cr1 = cos(c1); 44t = clock() - t; 45cout << timeELAPSED << t << endl; 46test((cr1 - (exp(c1 * 1i) + exp(-(c1 * 1i))) /2) < HWERROR); 47 48t = clock(); 49complex cr2 = cos(c2); 50t = clock() - t; 51cout << timeELAPSED << t << endl; 52test((cr2 - (exp(c2 * 1i) + exp(-(c2 * 1i))) / 2) < HWERROR); 53