Changeset 1893 for trunk/test
- Timestamp:
- Sep 9, 2012, 4:55:26 PM (8 years ago)
- Location:
- trunk/test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/math/pi.cpp
r1647 r1893 24 24 int main(int argc, char **argv) 25 25 { 26 printf("Pi: "); real::R_PI .print();27 printf("e: "); real::R_E .print();28 printf("ln(2): "); real::R_LN2 .print();29 printf("sqrt(2): "); real::R_SQRT2 .print();30 printf("sqrt(1/2): "); real::R_SQRT1_2 .print();26 printf("Pi: "); real::R_PI().print(); 27 printf("e: "); real::R_E().print(); 28 printf("ln(2): "); real::R_LN2().print(); 29 printf("sqrt(2): "); real::R_SQRT2().print(); 30 printf("sqrt(1/2): "); real::R_SQRT1_2().print(); 31 31 32 32 /* Gauss-Legendre computation of Pi -- doesn't work well at all, -
trunk/test/math/poly.cpp
r1647 r1893 85 85 { 86 86 return lol_sin(f); 87 //static float const k = (float)real::R_2_PI ;87 //static float const k = (float)real::R_2_PI(); 88 88 89 89 //f *= k; … … 120 120 121 121 printf("-- START --\n"); 122 for (flint u = { (float)real::R_PI_2 }; u.f > 1e-30; u.x -= 1)122 for (flint u = { (float)real::R_PI_2() }; u.f > 1e-30; u.x -= 1) 123 123 { 124 124 union { float f; uint32_t x; } s1 = { sinf(adjustf(u.f, 0)) }; -
trunk/test/unit/real.cpp
r1668 r1893 25 25 LOLUNIT_TEST(Constants) 26 26 { 27 double a0 = real::R_0 ;28 double a1 = real::R_1 ;29 double a2 = real::R_2 ;30 double a10 = real::R_10 ;27 double a0 = real::R_0(); 28 double a1 = real::R_1(); 29 double a2 = real::R_2(); 30 double a10 = real::R_10(); 31 31 32 32 LOLUNIT_ASSERT_EQUAL(a0, 0.0); … … 35 35 LOLUNIT_ASSERT_EQUAL(a10, 10.0); 36 36 37 double b1 = log(real::R_E );38 double b2 = log2(real::R_2 );37 double b1 = log(real::R_E()); 38 double b2 = log2(real::R_2()); 39 39 LOLUNIT_ASSERT_EQUAL(b1, 1.0); 40 40 LOLUNIT_ASSERT_EQUAL(b2, 1.0); 41 41 42 double c1 = exp(re(real::R_LOG2E ));43 double c2 = log(exp2(real::R_LOG2E ));42 double c1 = exp(re(real::R_LOG2E())); 43 double c2 = log(exp2(real::R_LOG2E())); 44 44 LOLUNIT_ASSERT_EQUAL(c1, 2.0); 45 45 LOLUNIT_ASSERT_EQUAL(c2, 1.0); 46 46 47 double d1 = exp(re(real::R_LOG10E ));47 double d1 = exp(re(real::R_LOG10E())); 48 48 LOLUNIT_ASSERT_EQUAL(d1, 10.0); 49 49 50 double e1 = exp(real::R_LN2 );50 double e1 = exp(real::R_LN2()); 51 51 LOLUNIT_ASSERT_EQUAL(e1, 2.0); 52 52 53 double f1 = exp(real::R_LN10 );53 double f1 = exp(real::R_LN10()); 54 54 LOLUNIT_ASSERT_EQUAL(f1, 10.0); 55 55 56 double g1 = sin(real::R_PI );57 double g2 = cos(real::R_PI );56 double g1 = sin(real::R_PI()); 57 double g2 = cos(real::R_PI()); 58 58 LOLUNIT_ASSERT_DOUBLES_EQUAL(g1, 0.0, 1e-100); 59 59 LOLUNIT_ASSERT_EQUAL(g2, -1.0); 60 60 61 double h1 = sin(real::R_PI_2 );62 double h2 = cos(real::R_PI_2 );61 double h1 = sin(real::R_PI_2()); 62 double h2 = cos(real::R_PI_2()); 63 63 LOLUNIT_ASSERT_EQUAL(h1, 1.0); 64 64 LOLUNIT_ASSERT_DOUBLES_EQUAL(h2, 0.0, 1e-100); 65 65 66 double i1 = sin(real::R_PI_4 ) * sin(real::R_PI_4);67 double i2 = cos(real::R_PI_4 ) * cos(real::R_PI_4);66 double i1 = sin(real::R_PI_4()) * sin(real::R_PI_4()); 67 double i2 = cos(real::R_PI_4()) * cos(real::R_PI_4()); 68 68 LOLUNIT_ASSERT_EQUAL(i1, 0.5); 69 69 LOLUNIT_ASSERT_EQUAL(i2, 0.5); … … 219 219 LOLUNIT_TEST(ExactDivision) 220 220 { 221 float m1 = real::R_1 / real::R_1;222 float m2 = real::R_2 / real::R_1;223 float m3 = real::R_1 / real::R_2;224 float m4 = real::R_2 / real::R_2;225 float m5 = real::R_1 / -real::R_2;221 float m1 = real::R_1() / real::R_1(); 222 float m2 = real::R_2() / real::R_1(); 223 float m3 = real::R_1() / real::R_2(); 224 float m4 = real::R_2() / real::R_2(); 225 float m5 = real::R_1() / -real::R_2(); 226 226 227 227 LOLUNIT_ASSERT_EQUAL(m1, 1.0f); … … 236 236 /* 1 / 3 * 3 should be close to 1... check that it does not differ 237 237 * by more than 2^-k where k is the number of bits in the mantissa. */ 238 real a = real::R_1 / real::R_3 * real::R_3;239 real b = ldexp(real::R_1 - a, real::BIGITS * real::BIGIT_BITS);238 real a = real::R_1() / real::R_3() * real::R_3(); 239 real b = ldexp(real::R_1() - a, real::BIGITS * real::BIGIT_BITS); 240 240 241 241 LOLUNIT_ASSERT_LEQUAL((double)fabs(b), 1.0); … … 260 260 LOLUNIT_TEST(Ulp) 261 261 { 262 real a1 = real::R_PI ;262 real a1 = real::R_PI(); 263 263 264 264 LOLUNIT_ASSERT_NOT_EQUAL((double)(a1 + ulp(a1) - a1), 0.0); … … 347 347 LOLUNIT_TEST(Pow) 348 348 { 349 double a1 = pow(-real::R_2 , real::R_2);349 double a1 = pow(-real::R_2(), real::R_2()); 350 350 double b1 = 4.0; 351 351 LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, 1.0e-13); 352 352 353 double a2 = pow(-real::R_2 , real::R_3);353 double a2 = pow(-real::R_2(), real::R_3()); 354 354 double b2 = -8.0; 355 355 LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, 1.0e-13);
Note: See TracChangeset
for help on using the changeset viewer.