449 /// $b$ is indicated logarithmic base. So, with $b=10$, |
449 /// $b$ is indicated logarithmic base. So, with $b=10$, |
450 /// * every iteration for first 10 iterations, |
450 /// * every iteration for first 10 iterations, |
451 /// * every 10 iterations from there on until 100 iterations, |
451 /// * every 10 iterations from there on until 100 iterations, |
452 /// * every 100 iteartinos frmo there on until 1000 iterations, etc. |
452 /// * every 100 iteartinos frmo there on until 1000 iterations, etc. |
453 Logarithmic(usize), |
453 Logarithmic(usize), |
|
454 /// Same as `Logarithmic`, but $\log_b(n)$ is replaced by $min\{c, \log_b(n)\}$ where $c$ |
|
455 /// is the given `cap`. For example, with `base=10` and `cap=2`, the first ten iterations |
|
456 /// will be output, then every tenth iteration, and after 100 iterations, every 100th iteration, |
|
457 /// without further logarithmic progression. |
|
458 LogarithmicCap{ base : usize, cap : u32 }, |
454 } |
459 } |
455 |
460 |
456 impl Verbose { |
461 impl Verbose { |
457 /// Indicates whether given iteration number is verbose |
462 /// Indicates whether given iteration number is verbose |
458 pub fn is_verbose(&self, iter : usize) -> bool { |
463 pub fn is_verbose(&self, iter : usize) -> bool { |
463 &Verbose::EveryAndInitial{ every, initial } => { |
468 &Verbose::EveryAndInitial{ every, initial } => { |
464 iter <= initial || (every != 0 && iter % every == 0) |
469 iter <= initial || (every != 0 && iter % every == 0) |
465 }, |
470 }, |
466 &Verbose::Logarithmic(base) => { |
471 &Verbose::Logarithmic(base) => { |
467 let every = base.pow((iter as float).log(base as float).floor() as u32); |
472 let every = base.pow((iter as float).log(base as float).floor() as u32); |
|
473 iter % every == 0 |
|
474 } |
|
475 &Verbose::LogarithmicCap{base, cap} => { |
|
476 let every = base.pow(((iter as float).log(base as float).floor() as u32).min(cap)); |
468 iter % every == 0 |
477 iter % every == 0 |
469 } |
478 } |
470 } |
479 } |
471 } |
480 } |
472 } |
481 } |