Skip to content

Commit 1506907

Browse files
committed
[doc] CtcInverse in Matlab
1 parent cfd93f2 commit 1506907

9 files changed

Lines changed: 65 additions & 16 deletions

File tree

doc/manual/manual/contractors/analytic/ctcinverse.rst

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ To represent the vectors :math:`\mathbf{x}\in\mathbb{R}^n` consistent with the c
8484
:end-before: [ctcinv-1-end]
8585
:dedent: 4
8686

87+
.. group-tab:: Matlab
88+
89+
.. literalinclude:: src.m
90+
:language: matlab
91+
:start-after: [ctcinv-1-beg]
92+
:end-before: [ctcinv-1-end]
93+
:dedent: 0
94+
8795
The contractor can be used as an operator to contract a 2d box :math:`[\mathbf{x}]`. It can also be involved in a paver in order to reveal the constraint:
8896

8997
.. tabs::
@@ -104,6 +112,14 @@ The contractor can be used as an operator to contract a 2d box :math:`[\mathbf{x
104112
:end-before: [ctcinv-2-end]
105113
:dedent: 4
106114

115+
.. group-tab:: Matlab
116+
117+
.. literalinclude:: src.m
118+
:language: matlab
119+
:start-after: [ctcinv-2-beg]
120+
:end-before: [ctcinv-2-end]
121+
:dedent: 0
122+
107123
Which produces the following output:
108124

109125
.. figure:: ./himmelblau_50.png
@@ -131,6 +147,15 @@ We recall that for thick solution sets, one should prefer the use of the ``SepIn
131147
:end-before: [ctcinv-3-end]
132148
:dedent: 4
133149

150+
.. group-tab:: Matlab
151+
152+
.. literalinclude:: src.m
153+
:language: matlab
154+
:start-after: [ctcinv-3-beg]
155+
:end-before: [ctcinv-3-end]
156+
:dedent: 0
157+
158+
134159
.. figure:: ./himmelblau_50_inner.png
135160
:width: 400px
136161

@@ -163,6 +188,14 @@ can be easily approximated by the following union of contractors:
163188
:end-before: [ctcinv-4-end]
164189
:dedent: 4
165190

191+
.. group-tab:: Matlab
192+
193+
.. literalinclude:: src.m
194+
:language: matlab
195+
:start-after: [ctcinv-4-beg]
196+
:end-before: [ctcinv-4-end]
197+
:dedent: 0
198+
166199
.. figure:: ./himmelblau_50_150_250.png
167200
:width: 400px
168201

@@ -302,14 +335,22 @@ When the constraint is a complement constraint :math:`\mathbf{f}(\mathbf{x})\not
302335
:end-before: [ctcinv-5-end]
303336
:dedent: 4
304337

338+
.. group-tab:: Matlab
339+
340+
.. literalinclude:: src.m
341+
:language: matlab
342+
:start-after: [ctcinv-5-beg]
343+
:end-before: [ctcinv-5-end]
344+
:dedent: 0
345+
305346

306347
Miscellaneous
307348
-------------
308349

309350
Access to the underlying function
310351
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311352

312-
The underlying analytic function can be accessed through ``.function()`` (useful for dimension checks or meta-programming).
353+
The underlying analytic function can be accessed through ``.f()`` (useful for dimension checks or meta-programming).
313354

314355
.. tabs::
315356

@@ -329,6 +370,14 @@ The underlying analytic function can be accessed through ``.function()`` (useful
329370
:end-before: [ctcinv-6-end]
330371
:dedent: 4
331372

373+
.. group-tab:: Matlab
374+
375+
.. literalinclude:: src.m
376+
:language: matlab
377+
:start-after: [ctcinv-6-beg]
378+
:end-before: [ctcinv-6-end]
379+
:dedent: 0
380+
332381
Centered form option
333382
^^^^^^^^^^^^^^^^^^^^
334383

doc/manual/manual/contractors/analytic/src.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ TEST_CASE("CtcInverse - manual")
6464
VectorVar x(2);
6565
AnalyticFunction f({x}, x[0]-x[1]);
6666
CtcInverse c(f, 0);
67-
// c.function().input_size() == 2
68-
// c.function().output_size() == 1
67+
// c.f().input_size() == 2
68+
// c.f().output_size() == 1
6969
// [ctcinv-6-end]
7070

71-
CHECK(c.function().input_size() == 2);
72-
CHECK(c.function().output_size() == 1);
71+
CHECK(c.f().input_size() == 2);
72+
CHECK(c.f().output_size() == 1);
7373
}
7474
}

doc/manual/manual/contractors/analytic/src.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
x = VectorVar(2);
4949
f = AnalyticFunction({x}, x(1)-x(2));
5050
c = CtcInverse(f, 0);
51-
assert(c.function().input_size()==2);
52-
assert(c.function().output_size()==1);
51+
assert(c.f().input_size()==2);
52+
assert(c.f().output_size()==1);
5353
% [ctcinv-6-end]

doc/manual/manual/contractors/analytic/src.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def tests_CtcInverse_manual(test):
5656
x = VectorVar(2)
5757
f = AnalyticFunction([x], x[0]-x[1])
5858
c = CtcInverse(f, 0)
59-
assert c.function().input_size() == 2
60-
assert c.function().output_size() == 1
59+
assert c.f().input_size() == 2
60+
assert c.f().output_size() == 1
6161
# [ctcinv-6-end]
6262

6363
if __name__ == '__main__':

python/codac/core/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def contract_tube(self,*x):
183183
def copy(self):
184184
return self.c.copy()
185185

186-
def function(self):
187-
return self.c.function()
186+
def f(self):
187+
return self.c.f()
188188

189189

190190
class CtcInverseNotIn(Ctc_IntervalVector):

python/src/core/contractors/codac2_py_CtcInverse.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ void export_CtcInverse(py::module& m, const std::string& export_name, py::class_
6565
VOID_CTCBASE_X_CONTRACT_TUBE_SLICEDTUBE_X_REF_VARIADIC_CONST,
6666
"x"_a)
6767

68-
.def("function", &C::function,
69-
CONST_ANALYTICFUNCTION_TYPENAME_EXPRTYPE_Y_TYPE_REF_CTCINVERSE_YX_FUNCTION_CONST)
68+
.def("f", &C::f,
69+
CONST_ANALYTICFUNCTION_TYPENAME_EXPRTYPE_Y_TYPE_REF_CTCINVERSE_YX_F_CONST)
7070

7171
;
7272
}

src/core/contractors/codac2_CtcInverse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ namespace codac2
117117
_f.intersect_from_args(v, x...); // updating input values
118118
}
119119

120-
const AnalyticFunction<typename ExprType<Y>::Type>& function() const
120+
const AnalyticFunction<typename ExprType<Y>::Type>& f() const
121121
{
122122
return _f;
123123
}

tests/core/contractors/codac2_tests_CtcInverse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TEST_CASE("CtcInverse")
4343
ScalarVar x,y;
4444
AnalyticFunction f { {x,y}, x-y };
4545
CtcInverse<Interval,Interval,Interval> c(f, Interval(0.));
46-
CHECK(c.function().input_size() == 2);
46+
CHECK(c.f().input_size() == 2);
4747

4848
Interval a,b;
4949

tests/core/contractors/codac2_tests_CtcInverse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_CtcInverse_1(self):
3030
x = VectorVar(2)
3131
f = AnalyticFunction([x], x[0]-x[1])
3232
c = CtcInverse(f, 0)
33-
self.assertTrue(c.function().input_size() == 2)
33+
self.assertTrue(c.f().input_size() == 2)
3434

3535
b = IntervalVector(2)
3636

0 commit comments

Comments
 (0)