This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
tutorial_subsystem [2014/07/12 07:00] guillaume Part 1 posted |
tutorial_subsystem [2017/04/19 13:31] (current) |
||
|---|---|---|---|
| Line 7: | Line 7: | ||
| Let us assume that we want to compute the mean of the values of a vector. It is feasible through the following Alpha system: | 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:false> | + | <sxh alphabets; gutter:true> |
| affine mean {N | N>0} | affine mean {N | N>0} | ||
| input | input | ||
| Line 21: | Line 21: | ||
| </ | </ | ||
| - | 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": | + | 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:false> | + | <sxh alphabets; gutter:true> |
| affine sum {P| P>0} // Computes the sum of the elements of a vector of size P | affine sum {P| P>0} // Computes the sum of the elements of a vector of size P | ||
| input | input | ||
| Line 49: | Line 49: | ||
| In general, the syntax of a use equation is the following: | In general, the syntax of a use equation is the following: | ||
| - | <sxh alphabets; gutter:false> | + | <sxh alphabets; gutter:true> |
| use subsystem_name[list of parameters] (list of input expressions) returns (list of output variables); | use subsystem_name[list of parameters] (list of input expressions) returns (list of output variables); | ||
| </ | </ | ||
| - | If your subsystem | + | If your subsystem |
| Line 59: | Line 59: | ||
| ====Extension domain==== | ====Extension domain==== | ||
| - | (incoming) | + | |
| + | Let us assume that you have a system which computes a dot product of two vectors: | ||
| + | <sxh alphabets; gutter: | ||
| + | affine dotProduct {N | N>0} | ||
| + | input | ||
| + | float v1 {k | 0< | ||
| + | float v2 {k | 0< | ||
| + | output | ||
| + | float Res {|}; | ||
| + | let | ||
| + | Res = reduce(+, [k], v1[k]*v2[k]); | ||
| + | . | ||
| + | </ | ||
| + | |||
| + | If you want to compute a matrix vector multiplication using this affine system, you will need to instanciate it once per rows of the matrix. Thus, you will need a parametrised number of call to the " | ||
| + | |||
| + | It is possible to do it by using an extension domain: | ||
| + | <sxh alphabets; gutter: | ||
| + | affine dotProduct {N | N>0} | ||
| + | input | ||
| + | float v1 {k | 0< | ||
| + | float v2 {k | 0< | ||
| + | output | ||
| + | float Res {|}; | ||
| + | let | ||
| + | Res = reduce(+, [k], v1[k]*v2[k]); | ||
| + | . | ||
| + | |||
| + | affine matrixVectorProduct {R,S | (R, | ||
| + | input | ||
| + | float mat {i,j | 0< | ||
| + | float vect {j | 0< | ||
| + | output | ||
| + | float vectRes {i | 0< | ||
| + | let | ||
| + | use {k | 0< | ||
| + | . | ||
| + | </ | ||
| + | |||
| + | The set "{k | 0≤k< | ||
| + | - the indexes can be used to specify the parameters (ex: " | ||
| + | - the first dimensions of the input expressions correspond to the dimensions of the extension domain. For example, each row of " | ||
| + | - the first dimensions of the output variables correspond to the dimensions of the extension domain. All the results from every subsystem call are gathered inside common variables (ex: " | ||
| + | |||
| + | |||
| + | Apart from the compatibility of dimensions, the input expressions must be defined at least on the points asked by the subsystem, and the output variable must be defined on a subset of the domain of the subsystem output. | ||
| ====Transformations involving subsystems==== | ====Transformations involving subsystems==== | ||
| - | (incoming, after the previous incoming) | + | **InlineSubSystem: |
| + | |||
| + | The command is: '' | ||
| + | |||
| + | |||
| + | **OutlineSubSystem: | ||
| + | |||
| + | The command is '' | ||