This shows you the differences between two versions of the page.
tutorial_subsystem [2014/07/12 07:00] guillaume Part 1 posted |
tutorial_subsystem [2017/04/19 13:31] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======SubSystem in Alpha====== | ||
- | In this tutorial, we will present how to write structured alpha programs with subsystems, and we will present the associated transformations. | ||
- | |||
- | |||
- | ====Syntax of Use Equation (without extension domain)==== | ||
- | |||
- | Let us assume that we want to compute the mean of the values of a vector. It is feasible through the following Alpha system: | ||
- | <sxh alphabets; gutter: | ||
- | affine mean {N | N>0} | ||
- | input | ||
- | float A {k | 0< | ||
- | output | ||
- | float C {|}; | ||
- | local | ||
- | float temp {|}; | ||
- | let | ||
- | temp = reduce(+, [k], A[k]); | ||
- | C = temp / N; | ||
- | . | ||
- | </ | ||
- | |||
- | However, let us assume that you already have another Alpha system which computes the sum of the elements of a vector. It is possible to use this affine system (instead of rewriting its equation in the main system), by calling it through a "use equation": | ||
- | <sxh alphabets; gutter: | ||
- | affine sum {P| P>0} // Computes the sum of the elements of a vector of size P | ||
- | input | ||
- | float vect {i | 0< | ||
- | output | ||
- | float Res; | ||
- | let | ||
- | Res = reduce(+, [k], vect[k]); | ||
- | . | ||
- | |||
- | affine mean {N | N>0} | ||
- | input | ||
- | float A {k | 0< | ||
- | output | ||
- | float C {|}; | ||
- | local | ||
- | float temp {|}; | ||
- | let | ||
- | use sum[N] (A) returns (temp); // Compute " | ||
- | C = temp / N; | ||
- | . | ||
- | </ | ||
- | |||
- | The system " | ||
- | |||
- | |||
- | In general, the syntax of a use equation is the following: | ||
- | <sxh alphabets; gutter: | ||
- | use subsystem_name[list of parameters] (list of input expressions) returns (list of output variables); | ||
- | </ | ||
- | |||
- | If your subsystem have several parameters/ | ||
- | |||
- | |||
- | |||
- | ====Extension domain==== | ||
- | |||
- | (incoming) | ||
- | |||
- | |||
- | ====Transformations involving subsystems==== | ||
- | |||
- | (incoming, after the previous incoming) |