|
| 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>`_. |
0 commit comments