Commit b21fb00e authored by Olivier Mullier's avatar Olivier Mullier
Browse files

ajout d'exemples

parent 42f4baff
......@@ -51,16 +51,25 @@ std::list<ibex::Interval *>& IntegralII::compute_list_of_zeros(ibex::Interval se
return *res;
}
bool p_interval_compare(const ibex::Interval* a, const ibex::Interval* b)
{
return a->ub() < b->lb();
}
std::list<ibex::Interval *>& IntegralII::compute_list_of_zeros_inf()
{
std::list<ibex::Interval *>& res = compute_list_of_zeros(_inf_endpoint);
res.sort();
res.sort(p_interval_compare);
return res;
}
std::list<ibex::Interval *>& IntegralII::compute_list_of_zeros_sup()
{
return compute_list_of_zeros(_sup_endpoint);
std::list<ibex::Interval *>& res = compute_list_of_zeros(_sup_endpoint);
// for (auto * elem : res){
// cout << *elem << endl;
// }
return res;
}
......
......@@ -21,7 +21,7 @@
#include <ibex.h>
#define __EPS__ (1e-4)
#define __EPS__ (1e-5)
/**
* @todo write docs
......
......@@ -2,15 +2,58 @@
#include "integralii.h"
int main(){
cout << setprecision(15);
void example1(){
ibex::Variable x(1);
ibex::Function f(x, ibex::cos(x));
ibex::Function f(x, x*ibex::cos(x));
ibex::Interval inf_inter(0, 5);
ibex::Interval sup_inter(7, 15);
IntegralII integ_inter(inf_inter, sup_inter, &f);
cout << "Result: " << endl;
cout << integ_inter << endl;
ibex::Function g(x, x*ibex::sin(x) + ibex::cos(x));
cout << "Calcul avec la solution analytique : " << g << endl;
ibex::IntervalVector x_vec(1), y_vec(1);
x_vec[0] = integ_inter.get_solution().first.get_inf_endpoint();
y_vec[0] = integ_inter.get_solution().first.get_sup_endpoint();
cout << "\tmin : (" << x_vec << ", " << y_vec << ") : " << g.eval_vector(y_vec) - g.eval_vector(x_vec) << endl;
x_vec[0] = integ_inter.get_solution().second.get_inf_endpoint();
y_vec[0] = integ_inter.get_solution().second.get_sup_endpoint();
cout << "\tmax : (" << x_vec << ", " << y_vec << ") : " << g.eval_vector(y_vec) - g.eval_vector(x_vec) << endl;
}
void example2(){
ibex::Variable x(1);
ibex::Function f(x, x*ibex::sin(x));
ibex::Interval inf_inter(0, 5);
ibex::Interval sup_inter(7, 15);
IntegralII integ_inter(inf_inter, sup_inter, &f);
cout << "Result: " << endl;
cout << integ_inter << endl;
ibex::Function g(x, -x*ibex::cos(x) + ibex::sin(x));
cout << "Calcul avec la solution analytique : " << g << endl;
ibex::IntervalVector x_vec(1), y_vec(1);
x_vec[0] = integ_inter.get_solution().first.get_inf_endpoint();
y_vec[0] = integ_inter.get_solution().first.get_sup_endpoint();
cout << "\tmin : (" << x_vec << ", " << y_vec << ") : " << g.eval_vector(y_vec) - g.eval_vector(x_vec) << endl;
x_vec[0] = integ_inter.get_solution().second.get_inf_endpoint();
y_vec[0] = integ_inter.get_solution().second.get_sup_endpoint();
cout << "\tmax : (" << x_vec << ", " << y_vec << ") : " << g.eval_vector(y_vec) - g.eval_vector(x_vec) << endl;
}
int main(){
cout << setprecision(15);
example2();
return EXIT_SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment