Tasks

A task unit is a program unit that is obeyed concurrently with the rest of an Ada program. The corresponding activity, a new locus of control, is called a task in Ada terminology, and is similar to a thread, for example in Java Threads. The execution of the main program is also a task, the anonymous environment task. A task unit has both a declaration and a body, which is mandatory. A task body may be compiled separately as a subunit, but a task may not be a library unit, nor may it be generic. Every task depends on a master, which is the immediately surrounding declarative region - a block, a subprogram, another task, or a package. The execution of a master does not complete until all its dependent tasks have terminated. The environment task is the master of all other tasks; it terminates only when all other tasks have terminated.

Task units are similar to packages in that a task declaration defines entities exported from the task, whereas its body contains local declarations and statements of the task.

A single task is declared as follows:

task Single is
     declarations of exported identifiers
  end Single;
  ...
  task body Single is
     local declarations and statements
  end Single;  

A task declaration can be simplified, if nothing is exported, thus:

task No_Exports;

  procedure Housekeeping is
  
     task Check_CPU;
     task Backup_Disk;
  
     task body Check_CPU is
        ...
     end Check_CPU;
  
     task body Backup_Disk is
        ...
     end Backup_Disk;
     -- the two tasks are automatically created and begin execution
  begin -- Housekeeping
     null;
     -- Housekeeping waits here for them to terminate
  end Housekeeping;

It is possible to declare task types, thus allowing task units to be created dynamically, and incorporated in data structures:

task type T is
  ...
end T;
  ...
Task_1, Task_2 : T;
  ...
  task body T is
     ...
end T;

Task types are limited, i.e. they are restricted in the same way as limited private types, so assignment and comparison are not allowed.

Five interlaced pentagons

An ornamental design of five alternately interlaced pentagons (a kind of five-fold counterpart to the three-fold Valknut). No two pentagons are directly interlinked, and any three adjacent pentagons (for example, red, blue and turquoise) are in a Borromean rings configuration, which means that two non-adjacent pentagons will have to be removed in order to free the remaining three.

%!
306 396 translate 12.5 setlinewidth/plr{.25 sub 2.47213472 12.5
mul mul dup 3 2 roll 72 mul 90 add dup 3 1 roll cos mul 3 1 roll
sin mul}def/P{4 4 plr 3 4 plr 2 4 plr 1 4 plr 0 4 plr moveto
4{lineto}repeat closepath stroke}def/half{plr currentpoint exch
4 1 roll exch .4 mul exch .6 mul add 3 1 roll .4 mul exch .6 mul
add exch lineto stroke}def
gsave 0 .75 .75 setrgbcolor 3.7526379 2.5 plr translate P grestore
gsave 0 0 1 setrgbcolor 4.7526379 2.5 plr translate P grestore
gsave 1 0 .2 setrgbcolor 0.7526379 2.5 plr translate P grestore
gsave 0 .9 0 setrgbcolor 2.7526379 2.5 plr translate P grestore
gsave 0 .75 .75 setrgbcolor 3.7526379 2.5 plr translate
3 4 plr moveto 2 4 half 2 4 plr moveto 1 4 half
1 4 plr moveto 2 4 half 0 4 plr moveto 1 4 half grestore
gsave 0 0 1 setrgbcolor 4.7526379 2.5 plr translate 
3 4 plr moveto 2 4 half 1 4 plr moveto 2 4 half grestore
gsave 1 0 .2 setrgbcolor 0.7526379 2.5 plr translate
4 4 plr moveto 3 4 half 2 4 plr moveto 3 4 half grestore
showpage
%EOF

Source: Wikipedia

Plane partition

In mathematics and especially in combinatorics, a plane partition is a two-dimensional array of nonnegative integers $ n_{i,j}} n_{{i,j}} $ (with positive integer indices i and j) that is nonincreasing in both indices, that is, that satisfies for all i and j, and for which only finitely many of the ni,j are nonzero. A plane partitions may be represented visually by the placement of a stack of unit cubes above each other giving a three-dimensional solid like the one shown at right.

Source: Wikipedia

Parametric polymorphism

The idea of code reuse arises from the necessity for constructing large software systems combining well-established building blocks. The reusability of code improves the productivity and the quality of software. The generic units are one of the ways in which the Ada language supports this characteristic. A generic unit is a subprogram or package that defines algorithms in terms of types and operations that are not defined until the user instantiates them.

Note to C++ programmers: generic units are similar to C++ templates.

For example, to define a procedure for swapping variables of any (non-limited) type:

generic
  type Element_T is private;  -- Generic formal type parameter
procedure Swap (X, Y : in out Element_T);
procedure Swap (X, Y : in out Element_T) is
  Temporary : constant Element_T := X;
begin
  X := Y;
  Y := Temporary;
end Swap;

The Swap subprogram is said to be generic. The subprogram specification is preceded by the generic formal part consisting of the reserved word generic followed by a list of generic formal parameters which may be empty. The entities declared as generic are not directly usable, it is necessary to instantiate them.

To be able to use Swap, it is necessary to create an instance for the wanted type. For example:

procedure Swap_Integers is new Swap (Integer);

Now the Swap_Integers procedure can be used for variables of type Integer.

The generic procedure can be instantiated for all the needed types. It can be instantiated with different names or, if the same identifier is used in the instantiation, each declaration overloads the procedure:

procedure Instance_Swap is new Swap (Float);
procedure Instance_Swap is new Swap (Day_T);
procedure Instance_Swap is new Swap (Element_T => Stack_T);

Similarly, generic packages can be used, for example, to implement a stack of any kind of elements:

generic
  Max: Positive; 
  type Element_T is private;
package Generic_Stack is
  procedure Push (E: Element_T);
  function Pop return Element_T;
end Generic_Stack;
package body Generic_Stack is
  Stack: array (1 .. Max) of Element_T;
  Top  : Integer range 0 .. Max := 0;  -- initialise to empty
  -- ...
end Generic_Stack;

A stack of a given size and type could be defined in this way.

Source: Ada Programming

Möbius strip

A parametric plot of a Möbius stripA parametric plot of a Möbius strip

The Möbius strip or Möbius band is a surface with only one side and only one boundary. The Möbius strip has the mathematical property of being non-orientable. It can be realized as a ruled surface. It was discovered independently by the German mathematicians August Ferdinand Möbius and Johann Benedict Listing in 1858.

An example of a Möbius strip can be created by taking a paper strip and giving it a half-twist, and then joining the ends of the strip to form a loop. However, the Möbius strip is not a surface of only one exact size and shape, such as the half-twisted paper strip depicted in the illustration. Rather, mathematicians refer to the closed Möbius band as any surface that is homeomorphic to this strip. Its boundary is a simple closed curve, i.e., homeomorphic to a circle. This allows for a very wide variety of geometric versions of the Möbius band as surfaces each having a definite size and shape. For example, any rectangle can be glued to itself (by identifying one edge with the opposite edge after a reversal of orientation) to make a Möbius band. Some of these can be smoothly modeled in Euclidean space, and others cannot.

A half-twist clockwise gives an embedding of the Möbius strip different from that of a half-twist counterclockwise — that is, as an embedded object in Euclidean space the Möbius strip is a chiral object with right- or left-handedness. However, the underlying topological spaces within the Möbius strip are homeomorphic in each case. There are an infinite number of topologically different embeddings of the same topological space into three-dimensional space, as the Möbius strip can also be formed by twisting the strip an odd number of times greater than one, or by knotting and twisting the strip, before joining its ends. The complete open Möbius band is an example of a topological surface that is closely related to the standard Möbius strip but that is not homeomorphic to it.

It is straightforward to find algebraic equations, the solutions of which have the topology of a Möbius strip, but in general these equations do not describe the same geometric shape that one gets from the twisted paper model described above. In particular, the twisted paper model is a developable surface, having zero Gaussian curvature. A system of differential-algebraic equations that describes models of this type was published in 2007 together with its numerical solution.[4]

Source: Wikipedia

Klein bottle

In mathematics, the Klein bottle /ˈklaɪn/ is an example of a non-orientable surface; it is a two-dimensional manifold against which a system for determining a normal vector cannot be consistently defined. Informally, it is a one-sided surface which, if traveled upon, could be followed back to the point of origin while flipping the traveler upside down. Other related non-orientable objects include the Möbius strip and the real projective plane. Whereas a Möbius strip is a surface with boundary, a Klein bottle has no boundary (for comparison, a sphere is an orientable surface with no boundary).

z(θ,φ)=rsin⁡θcos⁡(φ/2)z(\theta, \varphi) = r \sin \theta \cos({\varphi/2})

w(θ,φ)=rsin⁡θsin⁡(φ/2)w(\theta, \varphi) = r \sin \theta \sin({\varphi/2})

The Klein bottle was first described in 1882 by the German mathematician Felix Klein. It may have been originally named the Kleinsche Fläche (“Klein surface”) and then misinterpreted as Kleinsche Flasche (“Klein bottle”), which ultimately may have led to the adoption of this term in the German language as well.

The following square is a fundamental polygon of the Klein bottle. The idea is to ‘glue’ together the corresponding coloured edges so that the arrows match, as in the diagrams below. Note that this is an “abstract” gluing in the sense that trying to realize this in three dimensions results in a self-intersecting Klein bottle.

x(θ,φ)=(R+rcos⁡θ)cos⁡φx(\theta, \varphi) = (R + r \cos \theta) \cos{\varphi}

y(θ,φ)=(R+rcos⁡θ)sin⁡φy(\theta, \varphi) = (R + r \cos \theta) \sin{\varphi}

Construction

x(u,v)=−215cos⁡u(3cos⁡v−30sin⁡u+90cos⁡4usin⁡ux(u,v) = -\frac{2}{15} \cos u (3 \cos{v}-30 \sin{u}+90 \cos^4{u} \sin{u} \quad

y(u,v)=−115sin⁡u(3cos⁡v−3cos⁡2ucos⁡v−48cos⁡4ucos⁡v+48cos⁡6uy(u,v) = -\frac{1}{15} \sin u (3 \cos{v}-3 \cos^2{u} \cos{v}-48 \cos^4{u} \cos{v}+ 48 \cos^6{u}

z(u,v)=215(3+5cos⁡usin⁡u)sin⁡vz(u,v) = \frac{2}{15} (3+5 \cos{u} \sin{u}) \sin{v}

Source: Wikipedia

Kinds of Expressions

Among basic expressions are literals, for example, decimal (real), enumeration, string, and access value literals:

2.5e+3
False
"и"
null

Involving many of those one can write aggregates (a primary),

(X => 0.0,
 Y => 1.0,
 Z => 0.0)

Arbitrarily complex sub-components are possible, too, creating an aggregate from component expressions,

(Height => 1.89 * Meter,  
 Age    => Guess (Picture => Images.Load (Suspects, "P2012-Aug.PNG"),
 Tiles   => Grid'(1 .. 3 => Scan, 4 => Skip)),
 Name   => new Nickname'("Herbert"))

Age is associated with the value of a nested function call. The actual parameter for Tiles has type name Grid qualify the array aggregate following it; the component Name is associated with an allocator.

The well known ‘mathematical’ expressions have closely corresponding simple expressions in Ada syntax, for example 2.0πr, or the relation

Area = π*r**2

Other expressions test for membership in a range, or in a type:

X in 1 .. 10 | 12
Shape in Polygon'Class

Hexagonal Torus

In geometry, a torus (plural tori) is a surface of revolution generated by revolving a circle in three-dimensional space about an axis coplanar with the circle. If the axis of revolution does not touch the circle, the surface has a ring shape and is called a torus of revolution.

Real-world examples of toroidal objects include inner tubes, swim rings, and the surface of a ring doughnut or bagel.

A torus should not be confused with a solid torus, which is formed by rotating a disk, rather than a circle, around an axis. A solid torus is a torus plus the volume inside the torus. Real-world approximations include doughnuts, vadai or vada, many lifebuoys, and O-rings.

In topology, a ring torus is homeomorphic to the Cartesian product of two circles: S1 × S1, and the latter is taken to be the definition in that context. It is a compact 2-manifold of genus 1. The ring torus is one way to embed this space into three-dimensional Euclidean space, but another way to do this is the Cartesian product of the embedding of S1 in the plane. This produces a geometric object called the Clifford torus, a surface in 4-space.

In the field of topology, a torus is any topological space that is topologically equivalent to a torus.

Source: Wikipedia