-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'codac2_dev' of github.com:codac-team/codac into codac2_…
…eigen
- Loading branch information
Showing
26 changed files
with
987 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
python/src/core/domains/interval/codac2_py_IntervalRow.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Interval Python binding | ||
* Originated from the former pyIbex library (Benoît Desrochers) | ||
* ---------------------------------------------------------------------------- | ||
* \date 2024 | ||
* \author Benoît Desrochers, Simon Rohou, Fabrice Le Bars | ||
* \copyright Copyright 2024 Codac Team | ||
* \license GNU Lesser General Public License (LGPL) | ||
*/ | ||
|
||
#include <sstream> | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/operators.h> | ||
#include <pybind11/stl.h> | ||
#include <codac2_Row.h> | ||
#include <codac2_IntervalRow.h> | ||
#include <codac2_IntervalMatrix.h> | ||
|
||
#include "codac2_py_doc.h" | ||
#include "codac2_py_Matrix_addons_Base_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
//#include "codac2_py_Matrix_addons_IntervalMatrix_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_Matrix_addons_IntervalMatrixBase_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_Matrix_addons_IntervalVector_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
//#include "codac2_py_Matrix_addons_Matrix_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_Matrix_addons_MatrixBase_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_Matrix_addons_Vector_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_Matrix_addons_VectorBase_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_MatrixBase_addons_Base_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
//#include "codac2_py_MatrixBase_addons_IntervalMatrix_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_MatrixBase_addons_IntervalMatrixBase_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_MatrixBase_addons_IntervalVector_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
//#include "codac2_py_MatrixBase_addons_Matrix_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
//#include "codac2_py_MatrixBase_addons_MatrixBase_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_MatrixBase_addons_Vector_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_MatrixBase_addons_VectorBase_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_matrices_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py) | ||
#include "codac2_py_IntervalVector_docs.h" | ||
|
||
#include "codac2_py_IntervalVector_templ.h" | ||
|
||
using namespace std; | ||
using namespace codac2; | ||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
py::class_<IntervalRow> export_IntervalRow(py::module& m) | ||
{ | ||
py::class_<IntervalRow> exported_intervalrow_class(m, "IntervalRow", DOC_TO_BE_DEFINED); | ||
export_IntervalVector_<IntervalRow,Row>(m, exported_intervalrow_class); | ||
return exported_intervalrow_class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
python/src/core/domains/interval/codac2_py_IntervalVector_templ.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/** | ||
* IV_templ binding | ||
* ---------------------------------------------------------------------------- | ||
* \date 2024 | ||
* \author Simon Rohou | ||
* \copyright Copyright 2024 Codac Team | ||
* \license GNU Lesser General Public License (LGPL) | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <sstream> | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/operators.h> | ||
#include <pybind11/stl.h> | ||
|
||
#include <codac2_IntervalVector.h> | ||
|
||
#include "codac2_py_MatrixBase.h" | ||
#include "codac2_py_IntervalMatrixBase.h" | ||
#include "codac2_py_VectorBase.h" | ||
|
||
using namespace std; | ||
using namespace codac2; | ||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
|
||
template<typename IV,typename V> | ||
void export_IntervalVector_(py::module& m, py::class_<IV>& pyclass) | ||
{ | ||
export_IntervalMatrixBase<IV,V,true>(m, pyclass); | ||
export_VectorBase<IV,IntervalMatrix,Interval>(m, pyclass); | ||
|
||
pyclass | ||
|
||
.def(py::init( | ||
[](Index_type n) | ||
{ | ||
matlab::test_integer(n); | ||
return std::make_unique<IV>(n); | ||
}), | ||
DOC_TO_BE_DEFINED, | ||
"n"_a) | ||
|
||
.def(py::init<const IV&>(), | ||
"x"_a) | ||
|
||
.def(py::init<const V&>(), | ||
"x"_a) | ||
|
||
.def(py::init<const V&,const V&>(), | ||
MATRIX_ADDONS_INTERVALMATRIXBASE_MATRIX_CONST_MATRIX_DOUBLERC_REF_CONST_MATRIX_DOUBLERC_REF, | ||
"lb"_a, "ub"_a) | ||
|
||
.def(py::init( // this constructor must be the last one to be declared | ||
[](const std::vector<Interval>& v) | ||
{ | ||
auto iv = std::make_unique<IV>(v.size()); | ||
for(size_t i = 0 ; i < v.size() ; i++) | ||
(*iv)[i] = v[i]; | ||
return iv; | ||
}), | ||
MATRIX_ADDONS_INTERVALVECTOR_MATRIX_CONST_INITIALIZER_LIST_INTERVAL_REF, | ||
"v"_a) | ||
|
||
.def("complementary", [](const IV& x) { return x.complementary(); }, | ||
MATRIXBASE_ADDONS_INTERVALVECTOR_AUTO_COMPLEMENTARY_CONST) | ||
|
||
.def("diff", [](const IV& x, const IV& y, bool compactness = true) { return x.diff(y,compactness); }, | ||
MATRIXBASE_ADDONS_INTERVALVECTOR_LIST_MATRIX_INTERVALRC_DIFF_CONST_MATRIXBASE_OTHERDERIVED_REF_BOOL_CONST, | ||
"y"_a, "compactness"_a = true) | ||
|
||
.def_static("empty", [](Index_type n) | ||
{ | ||
matlab::test_integer(n); | ||
return IV::empty(n); | ||
}, | ||
MATRIX_ADDONS_INTERVALVECTOR_STATIC_AUTO_EMPTY_INDEX, | ||
"n"_a) | ||
|
||
.def("__repr__", [](const IV& x) | ||
{ | ||
std::ostringstream s; | ||
s << x; | ||
return string(s.str()); | ||
}, | ||
OSTREAM_REF_OPERATOROUT_OSTREAM_REF_CONST_INTERVALVECTOR_REF) | ||
|
||
; | ||
|
||
py::implicitly_convertible<py::list,IV>(); | ||
py::implicitly_convertible<V,IV>(); | ||
|
||
if constexpr(std::is_same_v<IntervalVector,IV>) | ||
{ | ||
m.def("cart_prod_boxes", [](const std::list<IV>& l) | ||
{ | ||
IV c = *l.begin(); | ||
for(auto it = std::next(l.cbegin()); it != l.cend(); it++) | ||
c = cart_prod(c,*it); | ||
return c; | ||
}, | ||
INTERVALVECTOR_CART_PROD_CONST_X_REF_VARIADIC); | ||
// The variadic version of this function is defined in __init__.py file | ||
} | ||
|
||
m.def("hull", [](const std::list<IV>& l) { return hull(l); }, | ||
AUTO_HULL_CONST_LIST_EIGEN_MATRIX_SCALARROWSATCOMPILETIMECOLSATCOMPILETIME_REF, | ||
"l"_a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.