1 | |
---|
2 | #++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
3 | # |
---|
4 | # EMSO sample file of matrix functions |
---|
5 | # |
---|
6 | # ----------------------------- |
---|
7 | # Function | EMSO Built-In |
---|
8 | # ----------------------------- |
---|
9 | # sum |
---|
10 | # prod |
---|
11 | # sumt |
---|
12 | # prodt |
---|
13 | # transp |
---|
14 | # |
---|
15 | #++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
16 | |
---|
17 | #*--------------------------------------------------- |
---|
18 | * |
---|
19 | * Given the matrix A: |
---|
20 | * |
---|
21 | * |-1 -2 3 1 0| |
---|
22 | * | 0 -1 -1 0 2| |
---|
23 | * | 0 0 5 1 0| |
---|
24 | * |
---|
25 | *--------------------------------------------------*# |
---|
26 | |
---|
27 | FlowSheet Matrix_Function |
---|
28 | PARAMETERS |
---|
29 | M as Integer; |
---|
30 | N as Integer; |
---|
31 | A(M,N) as Real; |
---|
32 | |
---|
33 | VARIABLES |
---|
34 | Sumt_(M) as Real; |
---|
35 | Sum_(N) as Real; |
---|
36 | |
---|
37 | Prodt_(M) as Real; |
---|
38 | Prod_(N) as Real; |
---|
39 | |
---|
40 | Transp_(N,M)as Real; |
---|
41 | |
---|
42 | SET |
---|
43 | M = 5; # columns |
---|
44 | N = 3; # rows |
---|
45 | |
---|
46 | A(:,1) = [-1, -2, 3, 1, 0]; |
---|
47 | A(:,2) = [ 0, -1, -1, 0, 2]; |
---|
48 | A(:,3) = [ 0, 0, 5, 1, 0]; |
---|
49 | |
---|
50 | EQUATIONS |
---|
51 | "Function sum" |
---|
52 | Sum_ = sum(A); |
---|
53 | |
---|
54 | "Function sumt" |
---|
55 | Sumt_ = sumt(A); |
---|
56 | |
---|
57 | "Function prod" |
---|
58 | Prod_ = prod(A); |
---|
59 | |
---|
60 | "Function prod" |
---|
61 | Prodt_ = prodt(A); |
---|
62 | |
---|
63 | "Function transp" |
---|
64 | Transp_ = transp(A); |
---|
65 | |
---|
66 | OPTIONS |
---|
67 | mode = "steady"; |
---|
68 | relativeAccuracy = 1e-10; |
---|
69 | end |
---|