ampsci
c++ program for high-precision atomic structure calculations of single-valence systems
Loading...
Searching...
No Matches
Widgets.hpp
1#pragma once
2#include <iostream>
3
4namespace qip {
5
6inline void progbar(int i, int max, int length = 50) {
7 const int len = (length - 2) / 2; // total bar length is 2*len+2
8 const int current = int(len * double(i) / double(max));
9 std::cout << "[";
10 for (auto j = 0; j < current; ++j) {
11 std::cout << "**";
12 }
13 for (auto j = current; j < len; ++j) {
14 std::cout << " ";
15 }
16 std::cout << "] \r" << std::flush;
17}
18
19inline void progbar50(int i, int max) {
20 const int len = 49;
21 const int prev = int(len * double(i) / double(max) + 1.0e-6);
22 const int current = int(len * double(i + 1) / double(max) + 1.0e-6);
23 // this ensures progbar line always exactly 50 chars long
24 for (int j = prev; j < current; ++j)
25 std::cout << "=" << std::flush;
26 if (current == len)
27 std::cout << "|\n" << std::flush;
28}
29
30} // namespace qip
qip library: A collection of useful functions
Definition Array.hpp:9
T max(T first, Args... rest)
Returns maximum of any number of parameters (variadic function)
Definition Maths.hpp:22