Skip to content

Commit

Permalink
[ctc] added CtcEmpty and CtcIdentity + binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed Oct 22, 2024
1 parent 255d94b commit 60a397e
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
contractors/codac2_py_Ctc.h
contractors/codac2_py_CtcAction.cpp
contractors/codac2_py_CtcCartProd.cpp
contractors/codac2_py_CtcEmpty.cpp
contractors/codac2_py_CtcFixpoint.cpp
contractors/codac2_py_CtcInnerOuter.cpp
contractors/codac2_py_CtcIdentity.cpp
contractors/codac2_py_CtcInter.cpp
contractors/codac2_py_CtcInverse.h
contractors/codac2_py_CtcInverseNotIn.h
Expand Down
4 changes: 4 additions & 0 deletions python/src/core/codac2_py_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ void export_OctaSym(py::module& m);
py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector> export_CtcIntervalVector(py::module& m/*, py::class_<Ctc,pyCtc>& py_ctc*/);
void export_CtcAction(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
void export_CtcCartProd(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
void export_CtcEmpty(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
void export_CtcFixpoint(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
void export_CtcIdentity(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
void export_CtcInnerOuter(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
void export_CtcInter(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
void export_CtcLazy(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& ctc);
Expand Down Expand Up @@ -121,7 +123,9 @@ PYBIND11_MODULE(_core, m)
auto py_ctc_iv = export_CtcIntervalVector(m/*,py_ctc*/);
export_CtcAction(m, py_ctc_iv);
export_CtcCartProd(m, py_ctc_iv);
export_CtcEmpty(m, py_ctc_iv);
export_CtcFixpoint(m, py_ctc_iv);
export_CtcIdentity(m, py_ctc_iv);
export_CtcInnerOuter(m, py_ctc_iv);
export_CtcInter(m, py_ctc_iv);
export_CtcInverse<Interval>(m,"CtcInverse_Interval",py_ctc_iv);
Expand Down
35 changes: 35 additions & 0 deletions python/src/core/contractors/codac2_py_CtcEmpty.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Codac binding (core)
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include <codac2_CtcEmpty.h>
#include "codac2_py_Ctc.h"
#include "codac2_py_CtcEmpty_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py):

using namespace std;
using namespace codac2;
namespace py = pybind11;
using namespace pybind11::literals;

void export_CtcEmpty(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& pyctc)
{
py::class_<CtcEmpty> exported(m, "CtcEmpty", pyctc, CTCEMPTY_MAIN);
exported

.def(py::init<size_t>(),
CTCEMPTY_CTCEMPTY_SIZET
"n"_a)

.def(CONTRACT_BOX_METHOD(CtcEmpty,
VOID_CTCEMPTY_CONTRACT_INTERVALVECTOR_REF_CONST))

;
}
35 changes: 35 additions & 0 deletions python/src/core/contractors/codac2_py_CtcIdentity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Codac binding (core)
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include <codac2_CtcIdentity.h>
#include "codac2_py_Ctc.h"
#include "codac2_py_CtcIdentity_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py):

using namespace std;
using namespace codac2;
namespace py = pybind11;
using namespace pybind11::literals;

void export_CtcIdentity(py::module& m, py::class_<CtcBase<IntervalVector>,pyCtcIntervalVector>& pyctc)
{
py::class_<CtcIdentity> exported(m, "CtcIdentity", pyctc, CTCIDENTITY_MAIN);
exported

.def(py::init<size_t>(),
CTCIDENTITY_CTCIDENTITY_SIZET
"n"_a)

.def(CONTRACT_BOX_METHOD(CtcIdentity,
VOID_CTCIDENTITY_CONTRACT_INTERVALVECTOR_REF_CONST))

;
}
4 changes: 4 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcDist.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcEllipse.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcEllipse.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcEmpty.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcEmpty.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcFixpoint.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcFixpoint.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcIdentity.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcIdentity.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcInnerOuter.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcInter.h
${CMAKE_CURRENT_SOURCE_DIR}/contractors/codac2_CtcInverse.h
Expand Down
22 changes: 22 additions & 0 deletions src/core/contractors/codac2_CtcEmpty.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* codac2_CtcEmpty.cp
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#include "codac2_CtcEmpty.h"

using namespace std;
using namespace codac2;

CtcEmpty::CtcEmpty(size_t n)
: Ctc<CtcEmpty,IntervalVector>(n)
{ }

void CtcEmpty::contract(IntervalVector& x) const
{
x.set_empty();
}
25 changes: 25 additions & 0 deletions src/core/contractors/codac2_CtcEmpty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* \file codac2_CtcEmpty.h
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#pragma once

#include "codac2_CtcWrapper.h"
#include "codac2_IntervalVector.h"

namespace codac2
{
class CtcEmpty : public Ctc<CtcEmpty,IntervalVector>
{
public:

CtcEmpty(size_t n);

void contract(IntervalVector& x) const;
};
}
2 changes: 1 addition & 1 deletion src/core/contractors/codac2_CtcFixpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \file codac2_CtcFixpoint.h
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \author Simon Rohou, Luc Jaulin
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/
Expand Down
20 changes: 20 additions & 0 deletions src/core/contractors/codac2_CtcIdentity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* codac2_CtcIdentity.cp
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#include "codac2_CtcIdentity.h"

using namespace std;
using namespace codac2;

CtcIdentity::CtcIdentity(size_t n)
: Ctc<CtcIdentity,IntervalVector>(n)
{ }

void CtcIdentity::contract(IntervalVector& x) const
{ }
25 changes: 25 additions & 0 deletions src/core/contractors/codac2_CtcIdentity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* \file codac2_CtcIdentity.h
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#pragma once

#include "codac2_CtcWrapper.h"
#include "codac2_IntervalVector.h"

namespace codac2
{
class CtcIdentity : public Ctc<CtcIdentity,IntervalVector>
{
public:

CtcIdentity(size_t n);

void contract(IntervalVector& x) const;
};
}

0 comments on commit 60a397e

Please sign in to comment.