Skip to content

Commit

Permalink
[ctc] added cpp files for CtcBox, CtcCartProd
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed May 17, 2022
1 parent 01a4d84 commit 5de05eb
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
${CMAKE_CURRENT_SOURCE_DIR}/serialize/codac_serialize_intervals.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_Ctc.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcBox.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcBox.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcCartProd.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcCartProd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcCompo.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcDist.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/static/codac_CtcDist.cpp
Expand Down
25 changes: 25 additions & 0 deletions src/core/contractors/static/codac_CtcBox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* CtcBox class
* ----------------------------------------------------------------------------
* \date 2022
* \author Quentin Brateau
* \copyright Copyright 2022 Codac Team
* \license This program is distributed under the terms of
* the GNU Lesser General Public License (LGPL).
*/

#include "codac_CtcBox.h"

using namespace std;

namespace codac
{
void CtcBox::contract(IntervalVector& x)
{
// Checking the dimension of the input box
assert(_b.size() == x.size());

// Contracting the input box around the support box
x &= _b;
}
}
9 changes: 0 additions & 9 deletions src/core/contractors/static/codac_CtcBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ namespace codac

const IntervalVector _b; //!< the support box
};

void CtcBox::contract(IntervalVector& x)
{
// Checking the dimension of the input box
assert(_b.size() == x.size());

// Contracting the input box around the support box
x &= _b;
}
}

#endif
35 changes: 35 additions & 0 deletions src/core/contractors/static/codac_CtcCartProd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* CtcCartProd class
* ----------------------------------------------------------------------------
* \date 2022
* \author Quentin Brateau
* \copyright Copyright 2022 Codac Team
* \license This program is distributed under the terms of
* the GNU Lesser General Public License (LGPL).
*/

#include "codac_CtcCartProd.h"

using namespace std;

namespace codac
{
void CtcCartProd::contract(IntervalVector& x)
{
std::size_t index = 0;
for (int i=0; i < m_v.size(); i++) {
IntervalVector sx(m_v[i].nb_var);
for (int k=0; k < m_v[i].nb_var; k++) {
sx[k] = x[index + k];
}
m_v[i].contract(sx);
x.put(index, sx);
index += m_v[i].nb_var;
}
}

CtcCartProd cart_prod(const ibex::Array<Ctc>& array)
{
return CtcCartProd(array);
}
}
19 changes: 1 addition & 18 deletions src/core/contractors/static/codac_CtcCartProd.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,6 @@ namespace codac
ibex::Array<Ctc> m_v; //!< vector containing the contractors
};

void CtcCartProd::contract(IntervalVector& x)
{
std::size_t index = 0;
for (int i=0; i < m_v.size(); i++) {
IntervalVector sx(m_v[i].nb_var);
for (int k=0; k < m_v[i].nb_var; k++) {
sx[k] = x[index + k];
}
m_v[i].contract(sx);
x.put(index, sx);
index += m_v[i].nb_var;
}
}

/**
* \fn template <typename ...Args> CtcCartProd<Args...> cart_prod(Args &...args)
* \brief Cartesian product of contractors
Expand All @@ -86,10 +72,7 @@ namespace codac
* \param array ibex::Array of contractors
* \return the Cartesian product of the contractors \f$\mathcal{C}_1\times\dots\times\mathcal{C}_n\f$
*/
CtcCartProd cart_prod(const ibex::Array<Ctc>& array)
{
return CtcCartProd(array);
}
CtcCartProd cart_prod(const ibex::Array<Ctc>& array);
}

#endif

0 comments on commit 5de05eb

Please sign in to comment.