Skip to content
Snippets Groups Projects
Commit 860d1e03 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Update doc to take into account the new syntax for R^d and R^dxd

parent c9459491
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
...@@ -74,10 +74,10 @@ mesh nodes according to a user-defined vector field $T: \mathbb{R}^2 ...@@ -74,10 +74,10 @@ mesh nodes according to a user-defined vector field $T: \mathbb{R}^2
let pi:R, pi = acos(-1); let pi:R, pi = acos(-1);
let theta:R^2 -> R, x -> 0.5*pi*(x[0]*x[0]-1)*(x[1]*x[1]-1); let theta:R^2 -> R, x -> 0.5*pi*(x[0]*x[0]-1)*(x[1]*x[1]-1);
let M:R^2 -> R^2x2, x -> (cos(theta(x)), -sin(theta(x)), let M:R^2 -> R^2x2, x -> [[cos(theta(x)), -sin(theta(x))],
sin(theta(x)), cos(theta(x))); [sin(theta(x)), cos(theta(x))]];
let T: R^2 -> R^2, x -> x + M(x)*x; let T: R^2 -> R^2, x -> x + M(x)*x;
let m:mesh, m = cartesian2dMesh((-1,-1), (1,1), (20,20)); let m:mesh, m = cartesian2dMesh([-1,-1], [1,1], (20,20));
m = transform(m, T); m = transform(m, T);
...@@ -856,10 +856,10 @@ are sorted by type of left hand side variable. ...@@ -856,10 +856,10 @@ are sorted by type of left hand side variable.
| ~R^2~ | | ~R^2~ |
| ~0~ (special value) | | ~0~ (special value) |
| list of 2 scalar (~B~, ~N~, ~Z~ or ~R~) expressions | | list of 2 scalar (~B~, ~N~, ~Z~ or ~R~) expressions |
An example of initialization using a list or the special value ~0~ is An example of initialization using an $\mathbb{R}^2$ value or the special value ~0~ is
#+NAME: affectation-to-R2-from-list #+NAME: affectation-to-R2-from-list
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let u:R^2, u = (-3, 2.5); let u:R^2, u = [-3, 2.5];
let z:R^2, z = 0; let z:R^2, z = 0;
cout << "u = " << u << "\n"; cout << "u = " << u << "\n";
cout << "z = " << z << "\n"; cout << "z = " << z << "\n";
...@@ -881,10 +881,10 @@ are sorted by type of left hand side variable. ...@@ -881,10 +881,10 @@ are sorted by type of left hand side variable.
| ~R^3~ | | ~R^3~ |
| ~0~ (special value) | | ~0~ (special value) |
| list of 3 scalar (~B~, ~N~, ~Z~ or ~R~) expressions | | list of 3 scalar (~B~, ~N~, ~Z~ or ~R~) expressions |
An example of initialization using a list is An example of initialization is
#+NAME: affectation-to-R3-from-list #+NAME: affectation-to-R3-from-list
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let u:R^3, u = (-3, 2.5, 1E-2); let u:R^3, u = [-3, 2.5, 1E-2];
let z:R^3, z = 0; let z:R^3, z = 0;
cout << "u = " << u << "\n"; cout << "u = " << u << "\n";
cout << "z = " << z << "\n"; cout << "z = " << z << "\n";
...@@ -907,11 +907,12 @@ are sorted by type of left hand side variable. ...@@ -907,11 +907,12 @@ are sorted by type of left hand side variable.
| ~R^2x2~ | | ~R^2x2~ |
| ~0~ (special value) | | ~0~ (special value) |
| list of 4 scalar (~B~, ~N~, ~Z~ or ~R~) expressions | | list of 4 scalar (~B~, ~N~, ~Z~ or ~R~) expressions |
An example of initialization using a list or the special value ~0~ is An example of initialization using an $\mathbb{R}^{2\times2}$ value or
the special value ~0~ is
#+NAME: affectation-to-R2x2-from-list #+NAME: affectation-to-R2x2-from-list
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let u:R^2x2, u = (-3, 2.5, let u:R^2x2, u = [[-3, 2.5],
4, 1.2); [ 4, 1.2]];
let z:R^2x2, z = 0; let z:R^2x2, z = 0;
cout << "u = " << u << "\n"; cout << "u = " << u << "\n";
cout << "z = " << z << "\n"; cout << "z = " << z << "\n";
...@@ -925,12 +926,12 @@ are sorted by type of left hand side variable. ...@@ -925,12 +926,12 @@ are sorted by type of left hand side variable.
| ~R^3x3~ | | ~R^3x3~ |
| ~0~ (special value) | | ~0~ (special value) |
| list of 9 scalar (~B~, ~N~, ~Z~ or ~R~) expressions | | list of 9 scalar (~B~, ~N~, ~Z~ or ~R~) expressions |
An example of initialization using a list is An example of initialization is
#+NAME: affectation-to-R3x3-from-list #+NAME: affectation-to-R3x3-from-list
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let u:R^3x3, u = (-3, 2.5, 1E-2, let u:R^3x3, u = [[ -3, 2.5, 1E-2],
2, 1.7, -2, [ 2, 1.7, -2],
1.2, 4, 2.3); [1.2, 4, 2.3]];
let z:R^3x3, z = 0; let z:R^3x3, z = 0;
cout << "u = " << u << "\n"; cout << "u = " << u << "\n";
cout << "z = " << z << "\n"; cout << "z = " << z << "\n";
...@@ -1256,8 +1257,8 @@ constructions. ...@@ -1256,8 +1257,8 @@ constructions.
operators. Their syntax is the following. operators. Their syntax is the following.
#+NAME: Rd-Rdxd-access-operator #+NAME: Rd-Rdxd-access-operator
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let x:R^2, x = (1,2); let x:R^2, x = [1,2];
let A:R^3x3, A = (1,2,3,4,5,6,7,8,9); let A:R^3x3, A = [[1,2,3],[4,5,6],[7,8,9]];
cout << "x[0] = " << x[0] << "\nx[1] = " << x[1] << "\n"; cout << "x[0] = " << x[0] << "\nx[1] = " << x[1] << "\n";
cout << "A[0,0] = " << A[0,0] << "\nA[2,1] = " << A[2,1] << "\n"; cout << "A[0,0] = " << A[0,0] << "\nA[2,1] = " << A[2,1] << "\n";
...@@ -1614,9 +1615,9 @@ illustrate this, let us consider the following example. ...@@ -1614,9 +1615,9 @@ illustrate this, let us consider the following example.
#+BEGIN_SRC pugs :exports both #+BEGIN_SRC pugs :exports both
import mesh; import mesh;
let m1:mesh, m1 = cartesian2dMesh(0, (1,1), (10,10)); let m1:mesh, m1 = cartesian2dMesh(0, [1,1], (10,10));
let m2:mesh, m2 = m1; let m2:mesh, m2 = m1;
let m3:mesh, m3 = cartesian2dMesh(0, (1,1), (10,10)); let m3:mesh, m3 = cartesian2dMesh(0, [1,1], (10,10));
m3 = m1; m3 = m1;
#+END_SRC #+END_SRC
...@@ -1653,8 +1654,8 @@ Let us provide an example to fix ideas. ...@@ -1653,8 +1654,8 @@ Let us provide an example to fix ideas.
#+NAME: compound-declaration #+NAME: compound-declaration
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let (A,x,n): R^2x2*R^3*N; let (A,x,n): R^2x2*R^3*N;
A = (1,2,3,4); A = [[1,2],[3,4]];
x = (2,4,6); x = [2,4,6];
n = 2; n = 2;
cout << "A = " << A << "\nx = " << x << "\nn = " << n << "\n"; cout << "A = " << A << "\nx = " << x << "\nn = " << n << "\n";
...@@ -1676,7 +1677,7 @@ different variables. ...@@ -1676,7 +1677,7 @@ different variables.
One can also use the following definition instruction One can also use the following definition instruction
#+NAME: compound-definition #+NAME: compound-definition
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let (A,x,n): R^2x2*R^3*N, (A,x,n) = ((1,2,3,4), (2,4,6), 2); let (A,x,n): R^2x2*R^3*N, (A,x,n) = ([[1,2],[3,4]], [2,4,6], 2);
cout << "A = " << A << "\nx = " << x << "\nn = " << n << "\n"; cout << "A = " << A << "\nx = " << x << "\nn = " << n << "\n";
#+END_SRC #+END_SRC
...@@ -1721,7 +1722,7 @@ example. ...@@ -1721,7 +1722,7 @@ example.
let x: R^3; let x: R^3;
let n: N; let n: N;
(A,x,n) = ((1,2,3,4), (2,4,6), 2); (A,x,n) = ([[1,2],[3,4]], [2,4,6], 2);
cout << "A = " << A << "\nx = " << x << "\nn = " << n << "\n"; cout << "A = " << A << "\nx = " << x << "\nn = " << n << "\n";
#+END_SRC #+END_SRC
...@@ -1772,7 +1773,7 @@ Executing this code, one gets ...@@ -1772,7 +1773,7 @@ Executing this code, one gets
The definition syntax is also possible. The definition syntax is also possible.
#+NAME: tuple-definition #+NAME: tuple-definition
#+BEGIN_SRC pugs :exports both :results output #+BEGIN_SRC pugs :exports both :results output
let x:(R^2), x = ((1,2),(3.4,2), 0, (2,3)); let x:(R^2), x = ([1,2],[3.4,2], 0, [2,3]);
cout << x << "\n"; cout << x << "\n";
#+END_SRC #+END_SRC
This code gives This code gives
...@@ -2130,17 +2131,17 @@ Using compound types as input and output, one can write ...@@ -2130,17 +2131,17 @@ Using compound types as input and output, one can write
let f : R^2x2*R*string -> R*string*R^3x3, let f : R^2x2*R*string -> R*string*R^3x3,
(A,x,s) -> (x*A[0,0]*A[1,1]-A[1,0], (A,x,s) -> (x*A[0,0]*A[1,1]-A[1,0],
A+","+x+","+s, A+","+x+","+s,
(A[0,0], A[0,1], 0, [[A[0,0], A[0,1], 0],
A[1,0], A[1,1], 0, [A[1,0], A[1,1], 0],
0, 0, x)); [ 0, 0, x]]);
let x : R, x=0; let x : R, x=0;
let s : string, s= ""; let s : string, s= "";
let A : R^3x3, A = 0; let A : R^3x3, A = 0;
(x,s,A) = f((1,2,3,4), 2.3, "foo"); (x,s,A) = f([[1,2],[3,4]], 2.3, "foo");
cout << "x = " << x cout << "x = " << x
<< "\ns = " << s << "\ns = " << s
<< "\nA = " << A << "\n"; << "\nA = " << A << "\n";
let (y,t,A2):R*string*R^3x3, (y,t,A2) = f((3,1,4,2), -5.2, "bar"); let (y,t,A2):R*string*R^3x3, (y,t,A2) = f([[3,1],[4,2]], -5.2, "bar");
cout << "y = " << y cout << "y = " << y
<< "\nt = " << t << "\nt = " << t
<< "\nA2 = " << A2 << "\n"; << "\nA2 = " << A2 << "\n";
...@@ -2201,7 +2202,7 @@ function expressions. ...@@ -2201,7 +2202,7 @@ function expressions.
let minus: R -> R, x -> -(x<0)*x; let minus: R -> R, x -> -(x<0)*x;
let pm : R -> R*R, x -> (plus(x), minus(x)); let pm : R -> R*R, x -> (plus(x), minus(x));
let toR2: R*R -> R^2, (x,y) -> (x,y); let toR2: R*R -> R^2, (x,y) -> [x,y];
cout << "pm(2) = " << toR2(pm(2)) << " pm(-3) = " << toR2(pm(-3)) << "\n"; cout << "pm(2) = " << toR2(pm(2)) << " pm(-3) = " << toR2(pm(-3)) << "\n";
#+END_SRC #+END_SRC
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment