Skip to content

Commit b125268

Browse files
committed
Merge branch 'codac2_dev' of github.com:codac-team/codac into parallelization
2 parents 086057d + c8f38a7 commit b125268

19 files changed

Lines changed: 816 additions & 63 deletions

File tree

doc/manual/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ User manual
233233
* CtcGaussSeidel
234234
* CtcLinearPrecond
235235
* Set contractors
236+
* :ref:`sec-ctc-set-ctcinter`
236237
* CtcUnion
237-
* CtcInter
238238
* CtcQInter
239239
* CtcCartProd
240240
* CtcProj

doc/manual/manual/contractors/index.rst

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Contractors, separators
44

55
.. toctree::
66

7+
CtcInter <set/ctcinter>
78
CtcInverse <analytic/ctcinverse>
89
CtcLohner <dynamic/ctclohner>
910
CtcDist <geometric/ctcdist>
@@ -18,4 +19,130 @@ Contractors, separators
1819
.. analytic/index.rst
1920
.. geometric/index.rst
2021
.. shape/index.rst
21-
.. temporal/index.rst
22+
.. temporal/index.rst
23+
24+
25+
26+
Overview of contractors and separators
27+
--------------------------------------
28+
29+
.. list-table::
30+
:header-rows: 1
31+
:widths: 50 50
32+
33+
* - **Contractors**
34+
- **Separators**
35+
36+
* - ``CtcIdentity``
37+
- —
38+
39+
* - ``CtcEmpty``
40+
- —
41+
42+
* - ``CtcLazy``
43+
- —
44+
45+
* - ``CtcFixpoint``
46+
- —
47+
48+
* - ``CtcGaussElim``
49+
- —
50+
51+
* - ``CtcGaussSeidel``
52+
- —
53+
54+
* - ``CtcLinearPrecond``
55+
- —
56+
57+
* - ``CtcUnion``
58+
- ``SepUnion``
59+
60+
* - :ref:`CtcInter <sec-ctc-set-ctcinter>`
61+
- ``SepInter``
62+
63+
* - ``CtcQInter``
64+
- ``SepQInter``
65+
66+
* - ``CtcCartProd``
67+
- ``SepCartProd``
68+
69+
* - ``CtcProj``
70+
- ``SepProj``
71+
72+
* - ``CtcNot``
73+
- ``SepNot``
74+
75+
* - ``CtcAction``
76+
- ``SepAction``
77+
78+
* - :ref:`CtcInverse <sec-ctc-analytic-ctcinverse>`
79+
- ``SepInverse``
80+
81+
* - ``CtcInverseNotIn``
82+
- —
83+
84+
* - —
85+
- ``SepTransform``
86+
87+
* - :ref:`CtcDist <sec-ctc-geom-ctcdist>`
88+
- —
89+
90+
* - :ref:`CtcPolar <sec-ctc-geom-ctcpolar>`
91+
- ``SepPolarCart`` / ``SepCartPolar``
92+
93+
* - ``CtcSegment``
94+
- —
95+
96+
* - ``CtcPolygon``
97+
- ``SepPolygon``
98+
99+
* - ``CtcPointCloud``
100+
- —
101+
102+
* - ``CtcEllipse``
103+
- ``SepEllipse``
104+
105+
* - ``CtcCross`` / ``CtcNoCross``
106+
- ``SepCross``
107+
108+
* - ``CtcCtcBoundary``
109+
- ``SepCtcBoundary``
110+
111+
* - ``CtcWrapper``
112+
- ``SepWrapper``
113+
114+
* - ``CtcImage``
115+
- ``SepImage``
116+
117+
* - ``CtcDiscreteSet``
118+
- —
119+
120+
* - ``CtcDeriv``
121+
- —
122+
123+
* - ``CtcEval``
124+
- —
125+
126+
* - ``CtcDelay``
127+
- —
128+
129+
* - ``CtcLinobs``
130+
- —
131+
132+
* - ``CtcLohner``
133+
- —
134+
135+
* - ``CtcPicard``
136+
- —
137+
138+
* - ``CtcChain``
139+
- —
140+
141+
* - ``CtcDiffInclusion``
142+
- —
143+
144+
* - —
145+
- ``SepCtcPair``
146+
147+
* - ``CtcInnerOuter``
148+
- —
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
.. _sec-ctc-set-ctcinter:
2+
3+
The CtcInter contractor
4+
=======================
5+
6+
Main author: `Simon Rohou <https://www.simon-rohou.fr/research/>`_
7+
8+
9+
.. doxygenclass:: codac2::CtcInter
10+
:project: codac
11+
12+
Basic usage
13+
-----------
14+
15+
The most common way to create an intersection contractor is to combine two existing
16+
contractors with ``&``.
17+
18+
.. tabs::
19+
20+
.. group-tab:: Python
21+
22+
.. literalinclude:: src.py
23+
:language: py
24+
:start-after: [ctcinter-1-beg]
25+
:end-before: [ctcinter-1-end]
26+
:dedent: 2
27+
28+
.. group-tab:: C++
29+
30+
.. literalinclude:: src.cpp
31+
:language: c++
32+
:start-after: [ctcinter-1-beg]
33+
:end-before: [ctcinter-1-end]
34+
:dedent: 2
35+
36+
Once built, the contractor can be applied as any other box contractor.
37+
38+
.. tabs::
39+
40+
.. group-tab:: Python
41+
42+
.. literalinclude:: src.py
43+
:language: py
44+
:start-after: [ctcinter-2-beg]
45+
:end-before: [ctcinter-2-end]
46+
:dedent: 2
47+
48+
.. group-tab:: C++
49+
50+
.. literalinclude:: src.cpp
51+
:language: c++
52+
:start-after: [ctcinter-2-beg]
53+
:end-before: [ctcinter-2-end]
54+
:dedent: 2
55+
56+
In this example, ``c1`` restricts the box to :math:`[-10,10]\times[-2,2]` and ``c2``
57+
restricts it to :math:`[-12,2]\times[0,4]`. Their conjunction therefore contracts the
58+
initial box to:
59+
60+
.. math::
61+
62+
[-10,10]\times[-2,2] \ \cap \ [-12,2]\times[0,4]
63+
\,=\, [-10,2]\times[0,2].
64+
65+
Building a conjunction incrementally
66+
------------------------------------
67+
68+
A ``CtcInter`` may also be created from a prescribed domain size and then populated later.
69+
In that case, the object is initially neutral: as long as no sub-contractor is added, it
70+
has no effect on the contracted box.
71+
72+
.. tabs::
73+
74+
.. group-tab:: Python
75+
76+
.. literalinclude:: src.py
77+
:language: py
78+
:start-after: [ctcinter-3-beg]
79+
:end-before: [ctcinter-3-end]
80+
:dedent: 2
81+
82+
.. group-tab:: C++
83+
84+
.. literalinclude:: src.cpp
85+
:language: c++
86+
:start-after: [ctcinter-3-beg]
87+
:end-before: [ctcinter-3-end]
88+
:dedent: 2
89+
90+
The method ``nb()`` returns the current number of sub-contractors stored in the
91+
intersection.
92+
93+
.. admonition:: Technical documentation
94+
95+
See the `C++ API documentation of this class <../../api/html/classcodac2_1_1_ctc_inter.html>`_.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Set contractors
2+
===============
3+
4+
.. toctree::
5+
6+
CtcInter <ctcinter>
7+
CtcUnion <http://codac.io>
8+
CtcQInter <http://codac.io>
9+
CtcCartProd <http://codac.io>
10+
CtcProj <http://codac.io>
11+
CtcNot <http://codac.io>
12+
CtcAction <http://codac.io>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Codac tests
3+
* ----------------------------------------------------------------------------
4+
* \date 2026
5+
* \author Simon Rohou
6+
* \copyright Copyright 2026 Codac Team
7+
* \license GNU Lesser General Public License (LGPL)
8+
*/
9+
10+
#include <catch2/catch_test_macros.hpp>
11+
#include <codac2_CtcInter.h>
12+
13+
using namespace std;
14+
using namespace codac2;
15+
16+
TEST_CASE("CtcInter - manual")
17+
{
18+
// [ctcinter-1-beg]
19+
CtcWrapper c1(IntervalVector({{-10,10},{-2,2}}));
20+
CtcWrapper c2(IntervalVector({{-12,2},{0,4}}));
21+
22+
auto c3 = c1 & c2;
23+
// c3 is a CtcInter<IntervalVector> gathering the two contractors.
24+
// [ctcinter-1-end]
25+
26+
// [ctcinter-2-beg]
27+
IntervalVector x({{-oo,oo},{-oo,oo}});
28+
c3.contract(x);
29+
// x = [ [-10, 2] ; [0, 2] ]
30+
// [ctcinter-2-end]
31+
32+
// [ctcinter-3-beg]
33+
CtcInter c4(2); // initially neutral conjunction on 2d boxes
34+
c4 &= c1;
35+
c4 &= c2;
36+
37+
auto n = c4.nb();
38+
// n = 2
39+
// [ctcinter-3-end]
40+
CHECK(n == 2);
41+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
3+
# Codac tests
4+
# ----------------------------------------------------------------------------
5+
# \date 2026
6+
# \author Simon Rohou
7+
# \copyright Copyright 2026 Codac Team
8+
# \license GNU Lesser General Public License (LGPL)
9+
10+
import sys, os
11+
import unittest
12+
import math
13+
from codac import *
14+
15+
class TestCtcSetManual(unittest.TestCase):
16+
17+
def tests_CtcInter_manual(test):
18+
19+
# [ctcinter-1-beg]
20+
c1 = CtcWrapper([[-10,10],[-2,2]])
21+
c2 = CtcWrapper([[-12,2],[0,4]])
22+
23+
c3 = c1 & c2
24+
# c3 is a CtcInter gathering the two contractors.
25+
# [ctcinter-1-end]
26+
27+
# [ctcinter-2-beg]
28+
x = IntervalVector([[-oo,oo],[-oo,oo]])
29+
c3.contract(x)
30+
# x = [ [-10, 2] ; [0, 2] ]
31+
# [ctcinter-2-end]
32+
33+
# [ctcinter-3-beg]
34+
c4 = CtcInter(2) # initially neutral conjunction on 2d boxes
35+
c4 &= c1
36+
c4 &= c2
37+
38+
n = c4.nb()
39+
# n = 2
40+
# [ctcinter-3-end]
41+
42+
if __name__ == '__main__':
43+
unittest.main()

0 commit comments

Comments
 (0)