Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/manual/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ User manual
* CtcGaussSeidel
* CtcLinearPrecond
* Set contractors
* :ref:`sec-ctc-set-ctcinter`
* CtcUnion
* CtcInter
* CtcQInter
* CtcCartProd
* CtcProj
Expand Down
129 changes: 128 additions & 1 deletion doc/manual/manual/contractors/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Contractors, separators

.. toctree::

CtcInter <set/ctcinter>
CtcInverse <analytic/ctcinverse>
CtcLohner <dynamic/ctclohner>
CtcDist <geometric/ctcdist>
Expand All @@ -18,4 +19,130 @@ Contractors, separators
.. analytic/index.rst
.. geometric/index.rst
.. shape/index.rst
.. temporal/index.rst
.. temporal/index.rst



Overview of contractors and separators
--------------------------------------

.. list-table::
:header-rows: 1
:widths: 50 50

* - **Contractors**
- **Separators**

* - ``CtcIdentity``
- —

* - ``CtcEmpty``
- —

* - ``CtcLazy``
- —

* - ``CtcFixpoint``
- —

* - ``CtcGaussElim``
- —

* - ``CtcGaussSeidel``
- —

* - ``CtcLinearPrecond``
- —

* - ``CtcUnion``
- ``SepUnion``

* - :ref:`CtcInter <sec-ctc-set-ctcinter>`
- ``SepInter``

* - ``CtcQInter``
- ``SepQInter``

* - ``CtcCartProd``
- ``SepCartProd``

* - ``CtcProj``
- ``SepProj``

* - ``CtcNot``
- ``SepNot``

* - ``CtcAction``
- ``SepAction``

* - :ref:`CtcInverse <sec-ctc-analytic-ctcinverse>`
- ``SepInverse``

* - ``CtcInverseNotIn``
- —

* - —
- ``SepTransform``

* - :ref:`CtcDist <sec-ctc-geom-ctcdist>`
- —

* - :ref:`CtcPolar <sec-ctc-geom-ctcpolar>`
- ``SepPolarCart`` / ``SepCartPolar``

* - ``CtcSegment``
- —

* - ``CtcPolygon``
- ``SepPolygon``

* - ``CtcPointCloud``
- —

* - ``CtcEllipse``
- ``SepEllipse``

* - ``CtcCross`` / ``CtcNoCross``
- ``SepCross``

* - ``CtcCtcBoundary``
- ``SepCtcBoundary``

* - ``CtcWrapper``
- ``SepWrapper``

* - ``CtcImage``
- ``SepImage``

* - ``CtcDiscreteSet``
- —

* - ``CtcDeriv``
- —

* - ``CtcEval``
- —

* - ``CtcDelay``
- —

* - ``CtcLinobs``
- —

* - ``CtcLohner``
- —

* - ``CtcPicard``
- —

* - ``CtcChain``
- —

* - ``CtcDiffInclusion``
- —

* - —
- ``SepCtcPair``

* - ``CtcInnerOuter``
- —
95 changes: 95 additions & 0 deletions doc/manual/manual/contractors/set/ctcinter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.. _sec-ctc-set-ctcinter:

The CtcInter contractor
=======================

Main author: `Simon Rohou <https://www.simon-rohou.fr/research/>`_


.. doxygenclass:: codac2::CtcInter
:project: codac

Basic usage
-----------

The most common way to create an intersection contractor is to combine two existing
contractors with ``&``.

.. tabs::

.. group-tab:: Python

.. literalinclude:: src.py
:language: py
:start-after: [ctcinter-1-beg]
:end-before: [ctcinter-1-end]
:dedent: 2

.. group-tab:: C++

.. literalinclude:: src.cpp
:language: c++
:start-after: [ctcinter-1-beg]
:end-before: [ctcinter-1-end]
:dedent: 2

Once built, the contractor can be applied as any other box contractor.

.. tabs::

.. group-tab:: Python

.. literalinclude:: src.py
:language: py
:start-after: [ctcinter-2-beg]
:end-before: [ctcinter-2-end]
:dedent: 2

.. group-tab:: C++

.. literalinclude:: src.cpp
:language: c++
:start-after: [ctcinter-2-beg]
:end-before: [ctcinter-2-end]
:dedent: 2

In this example, ``c1`` restricts the box to :math:`[-10,10]\times[-2,2]` and ``c2``
restricts it to :math:`[-12,2]\times[0,4]`. Their conjunction therefore contracts the
initial box to:

.. math::

[-10,10]\times[-2,2] \ \cap \ [-12,2]\times[0,4]
\,=\, [-10,2]\times[0,2].

Building a conjunction incrementally
------------------------------------

A ``CtcInter`` may also be created from a prescribed domain size and then populated later.
In that case, the object is initially neutral: as long as no sub-contractor is added, it
has no effect on the contracted box.

.. tabs::

.. group-tab:: Python

.. literalinclude:: src.py
:language: py
:start-after: [ctcinter-3-beg]
:end-before: [ctcinter-3-end]
:dedent: 2

.. group-tab:: C++

.. literalinclude:: src.cpp
:language: c++
:start-after: [ctcinter-3-beg]
:end-before: [ctcinter-3-end]
:dedent: 2

The method ``nb()`` returns the current number of sub-contractors stored in the
intersection.

.. admonition:: Technical documentation

See the `C++ API documentation of this class <../../api/html/classcodac2_1_1_ctc_inter.html>`_.
12 changes: 12 additions & 0 deletions doc/manual/manual/contractors/set/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Set contractors
===============

.. toctree::

CtcInter <ctcinter>
CtcUnion <http://codac.io>
CtcQInter <http://codac.io>
CtcCartProd <http://codac.io>
CtcProj <http://codac.io>
CtcNot <http://codac.io>
CtcAction <http://codac.io>
41 changes: 41 additions & 0 deletions doc/manual/manual/contractors/set/src.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Codac tests
* ----------------------------------------------------------------------------
* \date 2026
* \author Simon Rohou
* \copyright Copyright 2026 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#include <catch2/catch_test_macros.hpp>
#include <codac2_CtcInter.h>

using namespace std;
using namespace codac2;

TEST_CASE("CtcInter - manual")
{
// [ctcinter-1-beg]
CtcWrapper c1(IntervalVector({{-10,10},{-2,2}}));
CtcWrapper c2(IntervalVector({{-12,2},{0,4}}));

auto c3 = c1 & c2;
// c3 is a CtcInter<IntervalVector> gathering the two contractors.
// [ctcinter-1-end]

// [ctcinter-2-beg]
IntervalVector x({{-oo,oo},{-oo,oo}});
c3.contract(x);
// x = [ [-10, 2] ; [0, 2] ]
// [ctcinter-2-end]

// [ctcinter-3-beg]
CtcInter c4(2); // initially neutral conjunction on 2d boxes
c4 &= c1;
c4 &= c2;

auto n = c4.nb();
// n = 2
// [ctcinter-3-end]
CHECK(n == 2);
}
43 changes: 43 additions & 0 deletions doc/manual/manual/contractors/set/src.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python

# Codac tests
# ----------------------------------------------------------------------------
# \date 2026
# \author Simon Rohou
# \copyright Copyright 2026 Codac Team
# \license GNU Lesser General Public License (LGPL)

import sys, os
import unittest
import math
from codac import *

class TestCtcSetManual(unittest.TestCase):

def tests_CtcInter_manual(test):

# [ctcinter-1-beg]
c1 = CtcWrapper([[-10,10],[-2,2]])
c2 = CtcWrapper([[-12,2],[0,4]])

c3 = c1 & c2
# c3 is a CtcInter gathering the two contractors.
# [ctcinter-1-end]

# [ctcinter-2-beg]
x = IntervalVector([[-oo,oo],[-oo,oo]])
c3.contract(x)
# x = [ [-10, 2] ; [0, 2] ]
# [ctcinter-2-end]

# [ctcinter-3-beg]
c4 = CtcInter(2) # initially neutral conjunction on 2d boxes
c4 &= c1
c4 &= c2

n = c4.nb()
# n = 2
# [ctcinter-3-end]

if __name__ == '__main__':
unittest.main()
12 changes: 12 additions & 0 deletions doc/manual/manual/extensions/capd/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ The header of the ``codac-capd`` extension is not included by default. You need
#include <codac-capd.h>
#include <capd/capdlib.h>

Furthermore, you need to link the extension to your project, for instance by updating your ``CMakeLists.txt`` with::

add_executable(${PROJECT_NAME} main.cpp)
target_compile_options(${PROJECT_NAME} PUBLIC ${CODAC_CXX_FLAGS})
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CODAC_INCLUDE_DIRS} ${CODAC_CAPD_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE
${CODAC_LIBRARIES}
${CODAC_CAPD_LIBRARY} # linking to the codac-capd extension
capd::capd # linking to CAPD
Ibex::ibex
)

You can use the functions ``to_capd`` and ``to_codac`` to convert between CAPD and Codac objects as follows:

.. tabs::
Expand Down
14 changes: 14 additions & 0 deletions doc/manual/manual/extensions/sympy/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ The same package is also required by the C++ extension, since the symbolic backe
The Python interpreter is managed internally by the extension in C++, and is of course already available when Codac is used from Python.
No explicit interpreter initialization is needed in user code.

In C++ however, you need to link the extension to your project, for instance by updating your ``CMakeLists.txt`` with::

find_package(pybind11)

add_executable(${PROJECT_NAME} main.cpp)
target_compile_options(${PROJECT_NAME} PUBLIC ${CODAC_CXX_FLAGS})
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CODAC_INCLUDE_DIRS} ${CODAC_SYMPY_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE
${CODAC_LIBRARIES}
${CODAC_SYMPY_LIBRARY} # linking to the codac-sympy extension
pybind11::embed # linking to pybind11
Ibex::ibex
)

Finally, in order to include the features of the extension:

.. tabs::
Expand Down
Loading