#include #include "candidate.hpp" int main() { using namespace ivl; using namespace std; // a first array array a = arr(0.1, 0.2, 0.3, 0.2, 0.1); cout << "a = " << a << endl; // operators array b; b = a + 1; cout << "b = a + 1 = " << b << endl; array c = arr(1, 2, 3, 2, 1); array d = b + c; cout << "d = b + c = " << d << endl; cout << "d = " << (d += b) << endl; array f = d > 4; cout << "f = d > 4 = " << f << endl; // type abstraction array list = arr( cand("bob",7,10), cand("carol",8,7), cand("ted",5,9), cand("alice",8,3) ); cand ch("charlie",7,2); f = list > ch; cout << "candidates " << f << " are better than " << ch << endl; // functions cout << "there are " << list.length() << " candidates" << endl; list.push_back(ch); cout << list.back() << " is the most recent candidate" << endl; using ivl::max; cout << "but " << max(list) << " is the best" << endl; cout << "d = " << d << endl; cout << "floor(d) = " << floor(d) << endl; cout << "round(d) = " << round(d) << endl; array e = 1.0 / (d - 4.4); cout << "e = " << e << endl; cout << "isinf(e) = " << isinf(e) << endl; // ranges range r(1,5); cout << "r = " << r << endl; array ra = (1,_,5); cout << "ra = " << ra << endl; range q(1,2,9); array qa = (1,_,2,_,9); cout << "q = " << q << endl; cout << "qa = " << qa << endl; // complex arrays using ivl::math::i; array > x = a + b * i; cout << "a = " << a << endl; cout << "b = " << b << endl; cout << "x = " << x << endl; array > y = conj(x); cout << "y = conj(x) = " << y << endl; double n = 8; array > z = exp(2 * pi * (0.0,_,n-1) / n * i); cout << "sum(z) = " << sum(z) << endl; // expressions double mu = 0.3, sigma = 0.1; array N = 1.0 / (sigma * sqrt(2 * pi)) * exp(-1.0 / (2.0 * _[sigma] ->* 2) * (a - mu) ->* 2); cout << "a = " << a << endl; cout << "N = " << N << endl; }