%description:

This test contains basic checks for integration.

%includes:
#include "inet/common/math/Functions.h"

%global:

using namespace inet;
using namespace inet::math;
using namespace inet::units::values;

%activity:
// 1 dimensional
Ptr<const IFunction<double, Domain<simtime_t>>> c2 = makeShared<Boxcar1DFunction<double, simtime_t>>(-1, 1, 5);
std::cout << "f(s) = 5: f(0) = " << c2->getValue(Point<simtime_t>(0)) << ", max(f) = " << c2->getMax(Interval<simtime_t>(Point<simtime_t>(-1), Point<simtime_t>(1), 0b1, 0b0, 0b0)) << std::endl;
Ptr<const IFunction<double, Domain<>>> i2 = integrate<double, Domain<simtime_t>, 0b0, double, Domain<>>(c2);
std::cout << "f(s) = 5: I(f, s)() = " << i2->getValue(Point<>()) << std::endl;

// 2 dimensional
Ptr<const IFunction<double, Domain<simtime_t, Hz>>> c3 = makeShared<Boxcar2DFunction<double, simtime_t, Hz>>(-1, 1, Hz(-1), Hz(1), 5);
std::cout << "f(s, Hz) = 5: f(0, 0) = " << c3->getValue(Point<simtime_t, Hz>(0, Hz(0))) << ", max(f) = " << c3->getMax(Interval<simtime_t, Hz>(Point<simtime_t, Hz>(-1, Hz(-1)), Point<simtime_t, Hz>(1, Hz(1)), 0b11, 0b00, 0b00)) << std::endl;
Ptr<const IFunction<double, Domain<simtime_t>>> i3 = integrate<double, Domain<simtime_t, Hz>, 0b10, double, Domain<simtime_t>>(c3);
std::cout << "f(s, Hz) = 5: I(f, Hz)(0) = " << i3->getValue(Point<simtime_t>(0)) << ", max(f) = " << i3->getMax(Interval<simtime_t>(Point<simtime_t>(-1), Point<simtime_t>(1), 0b1, 0b0, 0b0)) << std::endl;
Ptr<const IFunction<double, Domain<>>> i4 = integrate<double, Domain<simtime_t>, 0b0, double, Domain<>>(i3);
std::cout << "f(s, Hz) = 5: I(I(f, Hz), s)() = " << i4->getValue(Point<>()) << std::endl;

%contains: stdout
f(s) = 5: f(0) = 5, max(f) = 5
f(s) = 5: I(f, s)() = 10
f(s, Hz) = 5: f(0, 0) = 5, max(f) = 5
f(s, Hz) = 5: I(f, Hz)(0) = 10, max(f) = 10
f(s, Hz) = 5: I(I(f, Hz), s)() = 20
