integrale_sol.cpp 2.22 KB
/*
 * <one line to give the library's name and an idea of what it does.>
 * Copyright (C) 2019  <copyright holder> <email>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "integrale_sol.h"

integrale_sol::integrale_sol(zero* inf, zero* sup, const ibex::Interval& res) : _res_integrale(res)
{
    _inf = (inf);
    _sup = (sup);
    _min_candidate = false;
    _max_candidate = false;
    if (res.ub() < 0.){
        _min_candidate = true;
    }
    if (res.lb() > 0.){
        _max_candidate = true;
    }
}

integrale_sol::~integrale_sol()
{
//     if (_inf)
//         delete _inf;
//     if (_sup)
//         delete _sup;
}


integrale_sol & integrale_sol::operator+=(const integrale_sol &rhs){
    *this =  *this + rhs;
    return *this;
}

integrale_sol operator+(const integrale_sol& lhs, const integrale_sol& rhs)
{
    
    if (lhs.get_sup_bound() == rhs.get_inf_bound()){
        return integrale_sol(lhs.get_inf_bound(), rhs.get_sup_bound(), (lhs.get_res_integrale() + rhs.get_res_integrale()));
    } else {
        return integrale_sol(rhs.get_inf_bound(), lhs.get_sup_bound(), (lhs.get_res_integrale() + rhs.get_res_integrale()));
    }
    
}

std::ostream & operator<<(std::ostream& os, const integrale_sol& inte)
{
    os << "Integral from (" << *(inte.get_inf_bound()) << ") to (" << *inte.get_sup_bound() << ") : " << inte.get_res_integrale();
    return os;
}

bool operator==(const integrale_sol& lhs, const integrale_sol& rhs)
{
    return (lhs.get_inf_bound() == rhs.get_inf_bound() && lhs.get_sup_bound() == rhs.get_sup_bound());
}

bool operator!=(const integrale_sol& lhs, const integrale_sol& rhs)
{
    return !(lhs == rhs);
}