Changeset 1104
 Timestamp:
 Dec 5, 2011, 9:24:01 AM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/tutorial/tut03.cpp
r1102 r1104 354 354 { 355 355 f64cmplx z0 = m_center + TexelToWorldOffset(ivec2(i, j)); 356 f64cmplx r0 = z0;356 f64cmplx z1, z2, z3, r0 = z0; 357 357 //f64cmplx r0(0.28693186889504513, 0.014286693904085048); 358 358 //f64cmplx r0(0.001643721971153, 0.822467633298876); … … 360 360 //f64cmplx r0(0.79192956889854, 0.14632423080102); 361 361 //f64cmplx r0(0.3245046418497685, 0.04855101129280834); 362 f64cmplx z; 363 int iter = MAX_ITERATIONS; 364 for (z = z0; iter && z.sqlen() < maxsqlen; z = z * z + r0) 365 iter; 362 int iter = MAX_ITERATIONS  4; 363 for (;;) 364 { 365 /* Unroll the loop: tests are more expensive to do at each 366 * iteration than the few extra multiplications. */ 367 z1 = z0 * z0 + r0; 368 z2 = z1 * z1 + r0; 369 z3 = z2 * z2 + r0; 370 z0 = z3 * z3 + r0; 371 if (z0.sqlen() >= maxsqlen) 372 break; 373 iter = 4; 374 if (iter < 4) 375 break; 376 } 366 377 367 378 if (iter) 368 379 { 369 double f = iter; 370 double n = z.sqlen(); 380 double n = z0.sqlen(); 381 382 if (z1.sqlen() >= maxsqlen) { iter += 3; n = z1.sqlen(); } 383 else if (z2.sqlen() >= maxsqlen) { iter += 2; n = z2.sqlen(); } 384 else if (z3.sqlen() >= maxsqlen) { iter += 1; n = z3.sqlen(); } 385 371 386 if (n > maxsqlen * maxsqlen) 372 387 n = maxsqlen * maxsqlen; 373 388 374 389 /* Approximate log(sqrt(n))/log(sqrt(maxsqlen)) */ 390 double f = iter; 375 391 union { double n; uint64_t x; } u = { n }; 376 392 double k = (u.x >> 42)  (((1 << 10)  1) << 10);
Note: See TracChangeset
for help on using the changeset viewer.